Hi,
I am pretty new to xml and xsl, so I might be asking a dumb question, but I am trying to write some an xslt to convert a nested xml into a comma seperated one.
My xml looks similar to this:
and I'd like to convert it to this:
name1,blah1,Enumeration,2,bla2h,1,blah
So I wrote the following xsl:
Unfortunately, this gives:
name1,blah1,Enumeration, 2 bla2h 1 blah
What am I doing wrong?
I am pretty new to xml and xsl, so I might be asking a dumb question, but I am trying to write some an xslt to convert a nested xml into a comma seperated one.
My xml looks similar to this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<Field>
<Name>name1</Name>
<Fid>blah1</Fid>
<Type>Enumeration</Type>
<Enumeration>
<Enum>
<Number>2</Number>
<Value>bla2h</Value>
</Enum>
<Enum>
<Number>1</Number>
<Value>blah</Value>
</Enum>
</Enumeration>
</Field>
and I'd like to convert it to this:
name1,blah1,Enumeration,2,bla2h,1,blah
So I wrote the following xsl:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output method="text"/>
<xsl:template match="Field">
<xsl:for-each select="*">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:value-of select="','"/>
</xsl:if>
</xsl:for-each>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
Unfortunately, this gives:
name1,blah1,Enumeration, 2 bla2h 1 blah
What am I doing wrong?