Input XML:
<Data>
<BPP>
<CP>A</CP>
<Name>Joe</Name>
</BPP>
<BPP>
<CP>A</CP>
<Name>Show</Name>
</BPP>
<BPP>
<CP>B</CP>
<Name>Cunny</Name>
</BPP>
<BPP>
<CP>D</CP>
<Name>Johny</Name>
</BPP>
<BPP>
<CP>C</CP>
<Name>Bunny</Name>
</BPP>
<BPP>
<CP>B</CP>
<Name>Sunny</Name>
</BPP>
<BPP>
<CP>C</CP>
<Name>Neha</Name>
</BPP>
<BPP>
<CP>D</CP>
<Name>Josh</Name>
</BPP>
<BPP>
<CP>B</CP>
<Name>Ash</Name>
</BPP>
<BPP>
<CP>A</CP>
<Name>Isha</Name>
</BPP>
</Data>
My Code In XSL-FO:
<fo:table table-layout="fixed" border-width="1mm" border-style="solid">
<fo:table-column column-width="25%"/>
<fo:table-column column-width="25%"/>
<fo:table-column column-width="25%"/>
<fo:table-column column-width="25%"/>
<fo:table-body>
<!-- Repeatable row-->
<fo:table-row>
<fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
<fo:block font-weight="bold">Header</fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
**<fo:block font-weight="bold"><!--Serial Value of 'A' or 'B'--></fo:block>**
</fo:table-cell>
<fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
<fo:block><xsl:value-of select='Data/BPP/Name'/></fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
<fo:block><xsl:value-of select='Data/BPP/CP'/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
My requirement:
if Data/BPP/CP=’A’ or Data/BPP/CP=’B’
then in Each row, 2nd column of the table serial number should be displayed
The resultant output has to be in the following table format
Header 1
Joe A
Header 2
Show A
Header 3
Cunny B
Header 4
Sunny B
Header 5
Ash B
Header 6
Isha A
How to achieve the above serial number for ‘A’ or ‘B'(not for ‘C’,’D’ etc)? i’ve tried to get this with xslt but i failed. Any help either with xslt or xsl-fo regarding this is really Commendable..
I can’t test this, but try:
(I edited away my previous answer, as it was wrong. I now understand your question)
The above XSL will select all BPP nodes where CP is A or is B. The
position()will output the position of the current node. I’m just not sure if it will output the position of the node in the entire node list, or in the result of our for-each.