[xquery-talk] Question on expected XQuery return per standards

Geert Josten Geert.Josten at daidalos.nl
Sat Mar 28 16:23:56 PST 2009


Hi Michael,

I ran it against msxsl 4.0, Xalan 2.7.0, Saxon 8 and Saxon 9. They all returned p2 in all cases..

Test.xml:

<?xml version="1.0"?>
<root>
     <div>
       <p>p1</p>
       <p>p2</p>
     </div>
     <div>
       <p>p3</p>
       <p>p4</p>
     </div>
   </root>

Test.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output encoding="utf-8" indent="no" />

<xsl:template match="/">
<!-- set1 - return all p's with position() = 2. Expected result: (p2, p4).  -->

   <set1><xsl:value-of select=" /descendant-or-self::node()/p[position() = 2] "/></set1>,

   <!-- set2 - XPath abbreviation // is equivalent to /descendant-or-self::node()/
      by definition. Result should still be (p2, p4) -->

   <set2><xsl:value-of select=" //p[position() = 2] "/></set2>,

   <!-- set3 - XPath predicate [2] is equivalent to [position() = 2]. Results
      should be identical to set1/set2 -->

   <set3><xsl:value-of select=" /descendant-or-self::node()/p[2] "/></set3>,

   <!-- set4 - final syntax variation with full abbreviation. Results should
      still be identical to set1/set2/set3 -->

   <set4><xsl:value-of select=" //p[2] "/></set4>,

   <!--set5 - This is the only one that should return a single node, p2.
     The XPath should return the second instance of all <p> descendants
     of . -->
   <set5><xsl:value-of select=" /descendant::p[2] "/></set5>
</xsl:template>

</xsl:stylesheet>

Changing the version of the XSL to 2.0 and running it again with Saxon did return the expected results. But with version 1.0 even Saxon was strangely enough returning p2 only..

Kind regards,
Geert

>


Drs. G.P.H. Josten
Consultant


http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.


> From: Michael Kay [mailto:mike at saxonica.com]
> Sent: zaterdag 28 maart 2009 16:07
> To: Geert Josten; talk at xquery.com
> Subject: RE: [xquery-talk] Question on expected XQuery return
> per standards
>
>
> > Is it true that Xpath 2.0 has changed the meaning of such
> expressions
> > compared to Xpath 1.0?
>
> No, this is unchanged since XPath 1.0.
>
> Which processors did you try, and can we see your code?
>
> Michael Kay
> http://www.saxonica.com/
>
>




More information about the talk mailing list