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(_dot_)painter(_at_)sgcib(_dot_)com
[mailto:alan(_dot_)painter(_at_)sgcib(_dot_)com]
Sent: 11 May 2006 17:30
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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[(_at_)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[(_at_)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[(_at_)id=$hrefs]"/>
<!-- Case 2 -->
<!-- <xsl:copy-of
select="$idElements[(_at_)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.
**************************************************************
***********
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--