Re: [xsl] what am I doing wrong with except and intersect?

Subject: Re: [xsl] what am I doing wrong with except and intersect?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sun, 20 Mar 2011 08:03:40 -0700
As others have noted, union, except and intersect use node-identity
based comparison.

You can have a look at the set datatype I implemented recently in
XPath 3.0 -- this should be usable with early implementations of XPath
3.0 and is working fine with Saxon EE 9.3.04 -- XQuery 3.0.

https://dnovatchev.wordpress.com/2011/02/20/the-set-datatype-implemented-in-x
path-3-0/


I expect that a few bugs uncovered in the XSLT processor of Saxon EE
9.3.04 will be fixed soon and then the set datatype will be usable
from XSLT 3.0 too.


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




On Sun, Mar 20, 2011 at 5:48 AM, Alex Muir <alex.g.muir@xxxxxxxxx> wrote:
> Hi,
>
> I'm confused as to why I'm not able to get intersect and except to
> work with the following node sets.
>
> Given list of new an old office codes:
> B  B  B  B <newOfficeCodeList>PT,BX,FR</newOfficeCodeList>
> B  B  B  B <oldOfficeCodeList>BX,FR</oldOfficeCodeList>
>
>
> I create some node sets:
>
> <xsl:template name="codeListAsXML">
> B  B <xsl:param name="OfficeCodeList"/>
> B  B <xsl:param name="OfficeCodeArgSeperator"/>
> B  B <xsl:variable name="result" as="node()*">
> B  B <xsl:analyze-string select="$OfficeCodeList"
> regex="{$OfficeCodeArgSeperator}">
> B  B  B <xsl:non-matching-substring>
> B  B  B  B <code>
> B  B  B  B  B <xsl:value-of select="normalize-space(.)"/>
> B  B  B  B </code>
> B  B  B </xsl:non-matching-substring>
> B  B </xsl:analyze-string>
> B  B </xsl:variable>
> B  B <xsl:sequence select="$result"/>
> B </xsl:template>
>
> The old set of office codes:
> B <xsl:variable name="oldOfficeCodeListXML" as="node()*">
> B  B  B <xsl:call-template name="codeListAsXML">
> B  B  B  B <xsl:with-param name="OfficeCodeList"
select="$oldOfficeCodeList"/>
> B  B  B  B <xsl:with-param name="OfficeCodeArgSeperator" select="','"/>
> B  B  B </xsl:call-template>
> B  B </xsl:variable>
>
> The new set of office codes:
> <xsl:variable name="newOfficeCodeListXML" as="node()*">
> B  B  B <xsl:call-template name="codeListAsXML">
> B  B  B  B <xsl:with-param name="OfficeCodeList"
select="$newOfficeCodeList"/>
> B  B  B  B <xsl:with-param name="OfficeCodeArgSeperator" select="','"/>
> B  B  B </xsl:call-template>
> B  B </xsl:variable>
>
>
> I tried some different ways to get the except and or intersect in the
> following variables with the result following the ==>
> B  B  B <newOfficeCodeList>PT,BX,FR</newOfficeCodeList>
> B  B  B  B <oldOfficeCodeList>BX,FR</oldOfficeCodeList>
>
> B <xsl:variable name="exceptOldNewOfficeCode"
> select="$newOfficeCodeListXML B except $oldOfficeCodeListXML"/>
> B  B  B  B  ==> <exceptOldNewOfficeCode>PT BX FR</exceptOldNewOfficeCode>
>
>
> B <xsl:variable name="intersectOldNewOfficeCode"
> select="$newOfficeCodeListXML B intersect $oldOfficeCodeListXML"/>
> B  B  B  ==> B  B <intersectOldNewOfficeCode/>
>
>
> B  <xsl:variable name="DSexceptOldNewOfficeCode"
> select="distinct-values($newOfficeCodeListXML[not(. =
> $oldOfficeCodeListXML)])"/>
> B  B  B ==> B  B  <DSexceptOldNewOfficeCode>PT</DSexceptOldNewOfficeCode>
>
>
>
> B  B <xsl:variable name="DSintersectOldNewOfficeCode"
> select="distinct-values($newOfficeCodeListXML[. =
> $oldOfficeCodeListXML])"/>
> B  B  B  ==> <DSintersectOldNewOfficeCode>BX
FR</DSintersectOldNewOfficeCode>
>
> It would seem that the variables that use the distinct method are
> correct and the variables using except and intersect are incorrect.
>
> So what am I doing wrong?
>
> Regards
>
>
> --
> Alex
> -----
> Currently:
> Freelance Software Engineer 6+ yrs exp
>
> Previously:
> https://sites.google.com/a/utg.edu.gm/alex/
>
>
> A Bafila, is two rivers flowing together as one:
> http://www.facebook.com/pages/Bafila/125611807494851
>
> --
> Alex
> -----
> Currently:
> Freelance Software Engineer 6+ yrs exp
>
> Previously:
> https://sites.google.com/a/utg.edu.gm/alex/
>
>
> A Bafila, is two rivers flowing together as one:
> http://www.facebook.com/pages/Bafila/125611807494851

Current Thread