I have 3 employee records as below. In my XSLT I have created a variable with line numbers 1, 2, & 3 and then looping through each of these lines to print fname. But it is not working.
Below is the input xml:
<tns:empLines>
<tns:empLine>
<can:fname>John</can:fname>
<can:lname>Doe</can:lname>
<can:age>20</can:age>
<can:lineNumber>1</can:lineNumber>
</tns:empLine>
<tns:empLine>
<can:fname>James</can:fname>
<can:lname>Douglas</can:lname>
<can:age>24</can:age>
<can:lineNumber>2</can:lineNumber>
</tns:empLine>
<tns:empLine>
<can:fname>Joe</can:fname>
<can:lname>Sims</can:lname>
<can:age>30</can:age>
<can:lineNumber>3</can:lineNumber>
</tns:empLine>
</tns:empLines>
Below is my xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR" xmlns:fo="http://ift.tt/vyPH5E">
<xsl:template match="/">
<xsl:variable name="lines">
<line num="1"/>
<line num="2"/>
<line num="3"/>
</xsl:variable>
<root>
<xsl:for-each select="$lines/line">
<pc>
<xsl:value-of select="//*[local-name()='empLines']/*[local-name()='empLine'][*[local-name()='lineNumber']=current()/@num]/*[local-name()='fname']/text()"/>
</pc>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
No comments:
Post a Comment