[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: what am I doing wrong with except and intersect?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sun, 20 Mar 2011 08:03:40 -0700
Re:  what am I doing wrong with except and intersect?
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.