xsl-list
[Top] [All Lists]

Positional predicates in pattern matching

2004-07-02 08:34:35

I have seen some behaviour in Saxon 6.5.2 and Xalan that I can't really 
explain by reading the standard. I have probably just missed something but 
would appreciate some second opinions.

If you execute,

   <xsl:template match="/">
        <xsl:variable name="foo" select="a/b[position()>1]"/>
        <top>
            <xsl:apply-templates select="$foo" mode="one"/>
            <xsl:apply-templates select="$foo" mode="two"/>
        </top>
    </xsl:template>

    <xsl:template match="b[1]" mode="one">P1</xsl:template>
    <xsl:template match="b[2]" mode="one">P2</xsl:template>
    <xsl:template match="b[3]" mode="one">P3</xsl:template>

    <xsl:template match="b[true()][1]" mode="two">R1</xsl:template>
    <xsl:template match="b[true()][2]" mode="two">R2</xsl:template>
    <xsl:template match="b[true()][3]" mode="two">R3</xsl:template>

Against,

<a>
  <b/>
  <b/>
  <b/>
</a>

The result is P2P3R2R3. I was expecting either P2P3R1R2 or perhaps even 
P2P3R1R1. It is obvious why you get P2P3 but that is only true for the first 
predicate of a StepPattern. In the second set of templates I would expect the 
positions should be 1 & 2 or perhaps even just 1 twice since pattern matching 
is defined as being a processes applied to individual nodes.

Thanks,
Kev.