xsl-list
[Top] [All Lists]

Re: position() returns doubled result - what do i miss?

2003-03-31 13:18:49
jian wrote:
i have :

<?xml version="1.0" encoding="UTF-8" ?>
<root>
      <item>item1</item>
      <item>item2</item>
      <item>item3</item>
      <item>item4</item>
      <item>item5</item>
      <item>item6</item>
      <item>item7</item>
      <item>item8</item>
      <item>item9</item>
</root>



to which i apply:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

<xsl:output method="html" version="4.01" encoding="UTF-8"/>

 <xsl:template match="/">
   <xsl:apply-templates match="root/item"/>
 </xsl:template>

 <xsl:template match="item">
   <xsl:value-of select="position()"/>
   <xsl:value-of select="."/>
 </xsl:template>

</xsl:stylesheet>


and for some reason i get :

      2item1
      4item2
      6item3
      8item4
      10item5
      12item6
      14item7
      16item8
      18item9

what do i miss?
Which processor are you using? Both saxon and msxml produce
1item12item23item34item45item56item67item78item89item9

Looking at <xsl:apply-templates match="root/item"/>, which is syntax error (match attribute on xsl:apply-templates) I presume you didn't show us your real xsl stylesheet. Such output could be achieved using <xsl:apply-templates/>, then you have missed whitespace-only text node, consisting of a new line and couple of tabs after each item element.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list