Nick,
strange though it seems, this is correct behaviour. For instance, the
<product> node really is the second out of 3 children of its
<allproducts> parent. The first and the third child are text nodes
consisting entirely of whitespace.

Of course, the position information about the text children is not being
output, because there's no explicit rule matching "text()" to do it.
Hence the contents of the text nodes are displayed by an implicit rule,
but being all whitespace, they're invisible.

Hope that helps.

Tom Kaiser

Nick Vincent wrote:
> 
> Hi,
> 
> I've been experiencing some curious behaviour when using 0.42, elements
> below the second level do not seem to enumerate properly when the position()
> or last() functions are used, the results are as below:
> 
> odd.xml
> ------------
> <?xml version="1.0" standalone="no"?>
> 
> <allproducts>
>         <product>
>                 <link></link>
>         </product>
> </allproducts>
> 
> odd.xsl
> -----------
> 
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:template match="/">
>         ROOT
>         <xsl:value-of select="position()"/> of <xsl:value-of
> select="last()"/>
>         <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="allproducts">
>                 ALLPRODUCT
>                 <xsl:value-of select="position()"/> of <xsl:value-of
> select="last()"/>
>                 <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="product">
>                         PRODUCT
>                         <xsl:value-of select="position()"/> of <xsl:value-of
> select="last()"/>
>                         <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="link">
>                                 LINK
>                                 <xsl:value-of select="position()"/> of
> <xsl:value-of select="last()"/>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> When this is run (sabcmd odd.xsl odd.xml) Sablotron returns:
> ------------------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
>         ROOT
>         1 of 1
>                 ALLPRODUCT
>                 1 of 1
> 
>                         PRODUCT
>                         2 of 3
> 
>                                 LINK
>                                 2 of 3
> 
> Which doesn't seem right to me.  This can be worked around by changing
> <xsl:apply-templates select="product"/> at the <allproduct> level and
> <xsl:apply-templates select="link"/> at the product level.
> 
> Can anyone shed light on whether this is a bug, or is there some meaning to
> this behaviour?
> 
> Thanks,
> 
> Nick Vincent
> NeoWorks


Reply via email to