View Single Post
  #1 (permalink)  
Old July 9th, 2009, 06:22 PM
navik_pathak navik_pathak is offline
Authorized User
Points: 75, Level: 1
Points: 75, Level: 1 Points: 75, Level: 1 Points: 75, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2009
Posts: 19
Thanks: 4
Thanked 0 Times in 0 Posts
Default XSLT for XML to Text

Hi Guys,

Need your help on following....

I have following XML which i want to covert it as Text with Numbering added to it.

Code:

<?xml version="1.0"?>
<ROWSET>
<ROW>
<ERROR_MESSAGE>Error</ERROR_MESSAGE>
</ROW>
<ROW>
<ERROR_MESSAGE>Error</ERROR_MESSAGE>
</ROW>
<ROW>
<ERROR_MESSAGE>Error</ERROR_MESSAGE>
</ROW>
</ROWSET>
XSLT code

Code:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="ROWSET">
<xsl:apply-templates select="ROW"/>
</xsl:template>
<xsl:variable name="ItemIndex" select="0"/>
<xsl:template match="ROW">
<xsl:for-each select="*">
<xsl:variable name="pos" select="position()"/><xsl:value-of select="$ItemIndex[$pos]"/>
<xsl:value-of select="."/>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

Using XSLT on above XML ...i am getting following output...

0Error
0Error
0Error

desired output...
1Error
2Error
3Error

thanks in advance for pointing out the error in my XSLT...
Reply With Quote