[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: surprised about the results of a filter expression
It's actually giving different results under Saxon-B and Saxon-SA (the join optimizer in Saxon-SA is kicking in and getting something wrong). I'll look into it. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: alan.painter@xxxxxxxxx [mailto:alan.painter@xxxxxxxxx] > Sent: 11 May 2006 17:30 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: surprised about the results of a filter > expression in XSLT2.0 > > I'm surprised to see that a filter expression, applied in > this case to a variable, produces more elements in the result > than there are elements in the variable. In this case, it > produces the cartesian product of the number of elements in > the variable and the number of combinations in the list that > comprises the predicate. I'm assuming that this is normal. > Where can I find this behavio(u)r described in the XSLT spec? > Thanks for any pointers. > > In Saxon 8.7.1 (perhaps elsewhere but haven't tested), in the > below stylesheet, the instruction > > <xsl:copy-of select="$idElements[@id=$hrefs]"/> > > produces > > <idElement id="_123"/> > <idElement id="_123"/> > <idElement id="_123"/> > <idElement id="_456"/> > <idElement id="_456"/> > <idElement id="_456"/> > > whereas the instruction > > <xsl:copy-of select="$idElements[@id=distinct-values($hrefs)]"/> > > produces > > <idElement id="_123"/> > <idElement id="_456"/> > > Here's the stylesheet > > <?xml version="1.0" encoding="UTF-8"?> > > <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > version="2.0"> > > <xsl:output method="xml" encoding="ISO-8859-1" indent="yes"/> > > <xsl:variable name="testdoc"> > <root> > <refElement name="element1"> <ref > href="_123"/> </refElement> > <refElement name="element2"> <ref > href="_123"/> </refElement> > <refElement name="element3"> <ref > href="_123"/> </refElement> > <refElement name="element4"> <ref > href="_456"/> </refElement> > <refElement name="element5"> <ref > href="_456"/> </refElement> > <refElement name="element6"> <ref > href="_456"/> </refElement> > <idElement id="_123"/> > <idElement id="_456"/> > <idElement id="_789"/> > </root> > </xsl:variable> > > <xsl:variable name="idElements" select="$testdoc//idElement"/> > > <xsl:template match="/"> > <xsl:apply-templates select="$testdoc" mode="inTestDoc"/> > </xsl:template> > > <xsl:template match="*" mode="inTestDoc"> > <xsl:variable name="hrefs" as="xs:string*" > select="$testdoc//@href"/> > <xsl:copy> > <!-- Case 1 --> > <xsl:copy-of select="$idElements[@id=$hrefs]"/> > <!-- Case 2 --> > <!-- <xsl:copy-of > select="$idElements[@id=distinct-values($hrefs)]"/> --> > </xsl:copy> > </xsl:template> > > </xsl:stylesheet> > > Output of case 1: > > <?xml version="1.0" encoding="ISO-8859-1"?> <root > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <idElement id="_123"/> > <idElement id="_123"/> > <idElement id="_123"/> > <idElement id="_456"/> > <idElement id="_456"/> > <idElement id="_456"/> > </root> > > Output of case 2: > > <?xml version="1.0" encoding="ISO-8859-1"?> <root > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <idElement id="_123"/> > <idElement id="_456"/> > </root> > > -alan > ************************************************************** > *********** > This message and any attachments (the "message") are > confidential and intended solely for the addressee(s). > Any unauthorised use or dissemination is prohibited. E-mails > are susceptible to alteration. > Neither SOCIETE GENERALE nor any of its subsidiaries or > affiliates shall be liable for the message if altered, > changed or falsified. > ************ Ce message et > toutes les pieces jointes (ci-apres le "message") sont > confidentiels et etablis a l'intention exclusive de ses > destinataires. Toute utilisation ou diffusion non autorisee > est interdite. Tout message electronique est susceptible > d'alteration. > La SOCIETE GENERALE et ses filiales declinent toute > responsabilite au titre de ce message s'il a ete altere, > deforme ou falsifie. > ************************************************************** > ***********
|
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
|