Hi,
 
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>
  </author>
  <!-- This is a very long comment the purpose is
       to test the default stylesheet for long comments-->
  <author period="classical">
    <name>Sophocles</name>
    <nationality>Greek</nationality>
  </author>
  <author>
    <name>Leo Tolstoy</name>
    <nationality>Russian</nationality>
  </author>
  <author>
    <name>Alexander Pushkin</name>
    <nationality>Russian</nationality>
  </author>
  <author period="classical">
    <name>Plato</name>
    <nationality>Greek</nationality>
  </author>
</authors>
 
 
and this XSLT 3.0 (or 2.0 -- doesn't matter) transformation:
 
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema" 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]]"/>
 </xsl:template>
</xsl:stylesheet>
 
The result with Saxon-EE 9.5.0.1J ( 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?
 


--
Cheers,
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.