For the third xsl:sequence to be equivalent to the second it would have to be written

<xsl:sequence select="(//nationality)[index-of(//nationality,.)[2]]"/>

because "/" binds more tightly than "[]".

Having said that, filter expressions where the filter is numeric and is also a function of the context item are pretty rare, so bugs are not impossible!

Michael Kay

On 25 Aug 2013, at 00:30, Dimitre Novatchev wrote:

I have this XML document:
<authors xmlns:user="mynamespace">
  <?ttt This is a PI ?>
  <author xmlns:user2="mynamespace2">
    <name idd="VH">Victor Hugo</name>
 <user2:name idd="VH">Victor Hugo</user2:name>
    <nationality xmlns:user3="mynamespace3">French</nationality>
  <!-- This is a very long comment the purpose is
       to test the default stylesheet for long comments-->
  <author period="classical">
    <name>Leo Tolstoy</name>
    <name>Alexander Pushkin</name>
  <author period="classical">
and this XSLT 3.0 (or 2.0 -- doesn't matter) transformation:
<xsl:stylesheet version="3.0" xmlns:xsl=""
 xmlns:xs="" exclude-result-prefixes="xs">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>
 <xsl:variable name="vInts" as="xs:integer+" select="1, 2, 2, 3, 4, 5, 5, 6, 7"/>
 <xsl:variable name="vElems" as="element()+" select="//nationality"/>
 <xsl:template match="/">
   <xsl:sequence select="$vInts[index-of($vInts,.)[2]]"/>
   <xsl:sequence select="$vElems[index-of($vElems,.)[2]]"/>
   <xsl:sequence select="//nationality[index-of(//nationality,.)[2]]"/>
The result with Saxon-EE ( and also with Saxon 9.1.08) is:
2 5
   <nationality xmlns:user="mynamespace">Russian</nationality>
<nationality xmlns:user="mynamespace">Greek</nationality>
Do notice that the expression in the third <xsl:sequence> is produced by the expression in the second <xsl:sequence> by substituting the variable $vElems by its defining expression "//nationality"
Also, note that the third <xsl:sequence> produces nothing, while one would expect it to produce the same result as the second <xsl:sequence>
Is this a bug or is this correct behavior? If the latter is true, how could we explain this behavior?

Dimitre Novatchev
Truly great madness cannot be achieved without significant intelligence.
To invent, you need a good imagination and a pile of junk
Never fight an inanimate object
To avoid situations in which you might make mistakes may be the
biggest mistake of all
Quality means doing it right when no one is looking.
You've achieved success in your field when you don't know whether what you're doing is work or play
Facts do not cease to exist because they are ignored.
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write all patents, too? :)
I finally figured out the only reason to be alive is to enjoy it.
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
saxon-help mailing list archived at