|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Question on expected XQuery return per standardsMichael Kay mike at saxonica.comSun Mar 29 10:03:52 PST 2009
The xsl:value-of instruction in XSLT 1.0, or in XSLT 2.0 when running in backwards-compatibility mode, only displays the first item in the selected node-set. To display all the nodes, use xsl:copy-of. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Geert Josten [mailto:http://x-query.com/mailman/listinfo/talk] > Sent: 28 March 2009 15:24 > To: Michael Kay; http://x-query.com/mailman/listinfo/talk > Subject: RE: Question on expected XQuery return > per standards > > 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:http://x-query.com/mailman/listinfo/talk] > > Sent: zaterdag 28 maart 2009 16:07 > > To: Geert Josten; http://x-query.com/mailman/listinfo/talk > > Subject: RE: 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/ > > > > >
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






