I am working on the XSLT.
Depending upon the values in the table I have to write the XML file.
Rules:
1.If the values in columns of I row are in strong(Enclosed in<strong> tags).
Then I have to add attribute as "FirstRowIsStrong".
2.If all the values in the I column are in strong.
Then I have to add attribute as "FirstCoulmnIsStrong".
3.If the values in any row are in Strong,
then I have to add attribute as "RowIsStrong".
If its the first row I need not add attribute.
If the values in First row are in strong I should not add attribute.
For the rows other than First row, I have to add the attribute.
I have source XML like this.
<table style="WIDTH: 100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td><strong xmlns="http://www.w3.org/1999/xhtml">A</strong></td>
<td><strong xmlns="http://www.w3.org/1999/xhtml">B</strong></td>
<td><strong xmlns="http://www.w3.org/1999/xhtml">C</strong></td>
</tr>
<tr>
<td><strong xmlns="http://www.w3.org/1999/xhtml">D</strong></td>
<td>E</td>
<td>F</td>
</tr>
<tr>
<td><strong xmlns="http://www.w3.org/1999/xhtml">G</strong></td>
<td><strong xmlns="http://www.w3.org/1999/xhtml">H</strong></td>
<td><strong xmlns="http://www.w3.org/1999/xhtml">I</strong></td>
</tr>
<tr>
<td><strong xmlns="http://www.w3.org/1999/xhtml">J</strong></td>
<td>K</td>
<td>L</td>
</tr>
</table>
I should have the output as
<tabledata FirstRowIsStrong="true" FirstCoulmnIsStrong="true">
<row>
<column>A</column>
<column>B</column>
<column>C</column>
</row>
<row>
<column>D</column>
<column>E</column>
<column>F</column>
</row>
<row RowIsStrong="true">
<column>G</column>
<column>H</column>
<column>I</column>
</row>
<row>
<column>J</column>
<column>K</column>
<column>L</column>
</row>
</tabledata>
I could able to get the values, but I am not sure how to add the attributes as per the requirement.
Can any one help me out how it can be done.
Thank you.
For the FirstRowIsStrong you need a test to check there the first row does not contain a td element which has no strong element
Similary, for the FirstColumnIsStrong you need a test to check there is no row first a first cell that does not contain a strong element
And for the RowIsStrong you can use a template match to check the non-first row does not contain any such td elements
Here is the full XSLT
When applied to your input XML, the following is output
Do note the extra code to remove the namespace from the strong element