Subject: RE: Positional predicates in pattern matching
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 2 Jul 2004 17:03:46 +0100
|
Sorry, but I don't understand why you would expect anything different.
b[true()] selects the same nodes as b, so you would surely expect
b[true()][1] to match the same nodes as b[1]?
Remember that the position in the match pattern predicate relates to the
position of the node relative to its siblings; it has nothing to do with the
position of the node in the node-list selected by apply-templates.
Michael Kay
> -----Original Message-----
> From: Kevin Jones [mailto:kjones@xxxxxxxxxxx]
> Sent: 02 July 2004 16:35
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Positional predicates in pattern matching
>
>
> 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.
>
>
> --+------------------------------------------------------------------
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
>
>
| Current Thread |
|
Michael Kay - Fri, 2 Jul 2004 17:03:46 +0100 <=
|
|