XSLT: Trouble combining elements from different nodes in one xsl:for-each loop



I need to transform something like the following (snippet from a FileMaker FMPXMLRESULT export)



<ROW>
<COL>
<DATA>A</DATA>
<DATA>B</DATA>
<DATA>C</DATA>
</COL>
<COL>
<DATA>1</DATA>
<DATA>2</DATA>
<DATA>3</DATA>
</COL>
</ROW>


into an xls.file, where the corresponding DATA elements are put in separate cells next to each other.


Using the following code



<xsl:for-each select="FMP:COL[1]/FMP:DATA">
<xsl:variable name="p"><xsl:value-of select="position()"/></xsl:variable>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="."/>
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="../../FMP:COL[2]/FMP:DATA[$p]"/>
</Data>
</Cell>
</xsl:for-each>


only returns


A 1


B 1


C 1


instead


A 1


B 2


C 3


and I don't know why...


Any help is highly appreciated!


best Florian


No comments:

Post a Comment