[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Positional predicates in pattern matching

Subject: Positional predicates in pattern matching
From: Kevin Jones <kjones@xxxxxxxxxxx>
Date: Fri, 2 Jul 2004 16:34:35 +0100
how to pattern match 16
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.


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.