Это преобразование :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:template match="children">
<xsl:if test="not(position()=1)">, </xsl:if>
<xsl:value-of select="concat(@name,'=',values)"/>
</xsl:template>
<xsl:template match="children[@name='batch']">
<xsl:variable name="vNum">
<xsl:number count="children[@name='batch']" level="single"/>
</xsl:variable>
<xsl:if test="not(position()=1)">, </xsl:if>
<xsl:value-of select="concat('batch', $vNum, '=', values)"/>
<xsl:apply-templates select="children"/>
</xsl:template>
<xsl:template match=
"children[@name='batch']/children">
<xsl:variable name="vNum">
<xsl:for-each select="..">
<xsl:number count="children[@name='batch']" level="single"/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select=
"concat(', ',@name,$vNum,'=',values)"/>
</xsl:template>
</xsl:stylesheet>
при применении к предоставленному XML-документу :
<extendedDataElements name="Feed" type="string">
<children name="fileId" type="string">
<values>TXT123</values>
</children>
<children name="processedTime" type="dateTime">
<values>2011-07-08T20:15:38</values>
</children>
<children name="batch" type="string">
<values>0000001</values>
<children name="statusCode" type="string">
<values>new</values>
</children>
</children>
<children name="batch" type="string">
<values>0000002</values>
<children name="statusCode" type="string">
<values>start</values>
</children>
</children>
<children name="batch" type="string">
<values>0000003</values>
<children name="statusCode" type="string">
<values>new</values>
</children>
</children>
<children name="count" type="long">
<values>26</values>
</children>
<children name="value" type="double">
<values>83171.650</values>
</children>
</extendedDataElements>
создает искомое, правильный результат :
fileId=TXT123, processedTime=2011-07-08T20:15:38, batch1=0000001, statusCode1=new, batch2=0000002, statusCode2=start, batch3=0000003, statusCode3=new, count=26, value=83171.650
Пояснение : хорошее использование следующих основных функций XSLT:
Шаблоны исопоставление с образцом .
<xsl:number>