My XSL:
XML:
Why do I get this dump:
I expected it to produce 1,2,3,4... so one so forth. Why is "2" repeated 3 times?
Code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
version="1.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="w:body">
<xsl:for-each select="//w:p">
<xsl:variable name="COUNTER2" select="count(preceding-sibling::*) + 1" />
<xsl:message><xsl:value-of select="$COUNTER2"/>
</xsl:message>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XML:
Code:
<?xml version="1.0"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
<w:p>
</w:p>
<w:p>
</w:p>
<w:p>
</w:p>
<w:tbl>
<w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
<w:trPr>
<w:cnfStyle w:val="100000000000"/>
</w:trPr>
<w:tc>
<w:tcPr>
<w:cnfStyle w:val="001000000000"/>
<w:tcW w:w="2394" w:type="dxa"/>
</w:tcPr>
<w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C"><ADDED>1-2</ADDED>
<w:r>
<w:t>Header</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="2394" w:type="dxa"/>
</w:tcPr>
<w:p w:rsidR="0065563E" w:rsidRDefault="0065563E" w:rsidP="0015368C">
<w:pPr>
<w:cnfStyle w:val="100000000000"/>
</w:pPr>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="2394" w:type="dxa"/>
</w:tcPr>
<w:p w:rsidR="0065563E" w:rsidRDefault="0065563E" w:rsidP="0015368C">
<w:pPr>
<w:cnfStyle w:val="100000000000"/>
</w:pPr>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
<w:p>
</w:p>
<w:p>
<w:r>
<w:t>Image inserted</w:t>
</w:r>
</w:p>
</w:body>
</w:document>
1
2
3
2
2
2
5
6
2
3
2
2
2
5
6
Comment