Sign In/My Account | View Cart  
advertisement

Article:
 XSLT 2 and Delimited Lists
Subject: Wondering whether brackets are needed to have a sequence
Date: 2003-05-20 10:31:11
From: Martin Honnen

For the XML input


<colors>
<color>red</color>
<color>green</color>
<color>blue</color>
<color>yellow</color>
</colors>


the author claims that the XPath


(color)


is needed to have the sequence of <color> elements but I think that the brackets are not needed, it would suffice to use


<xsl:template match="colors">
{<xsl:value-of select="item-at(color,3)"/>}
{<xsl:value-of select="index-of(color,'green')"/>}
</xsl:template>


to apply the function item-at respectively index-of to the sequence of <color> elements.


No Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • Wondering whether brackets are needed to have a sequence
    2003-05-20 18:06:17 Bob DuCharme [Reply]

    To identify a sequence, I was following the model at http://www.w3.org/TR/xpath20/#id-sequence-expressions, which shows that parentheses are required. I never tried it without them.


    Bob

    • Wondering whether brackets are needed to have a sequence
      2003-05-21 02:44:46 Martin Honnen [Reply]

      But the section you refer to is about constructing sequences from atomar values, there you need () to construct a sequence. Your example however uses an XPath expression with an element name as a node test and in XPath 1.0 that results in a node set why it is my understanding that in XPath 2.0 it results in a sequence of nodes.
      Indeed if I try the example with Saxon 7.5 without the () around color then the result is the same as with (color).

Sponsored By: