xsl-list
[Top] [All Lists]

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

2011-03-20 07:53:46
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:
        <newOfficeCodeList>PT,BX,FR</newOfficeCodeList>
        <oldOfficeCodeList>BX,FR</oldOfficeCodeList>


I create some node sets:

<xsl:template name="codeListAsXML">
    <xsl:param name="OfficeCodeList"/>
    <xsl:param name="OfficeCodeArgSeperator"/>
    <xsl:variable name="result" as="node()*">
    <xsl:analyze-string select="$OfficeCodeList"
regex="{$OfficeCodeArgSeperator}">
      <xsl:non-matching-substring>
        <code>
          <xsl:value-of select="normalize-space(.)"/>
        </code>
      </xsl:non-matching-substring>
    </xsl:analyze-string>
    </xsl:variable>
    <xsl:sequence select="$result"/>
  </xsl:template>

The old set of office codes:
 <xsl:variable name="oldOfficeCodeListXML" as="node()*">
      <xsl:call-template name="codeListAsXML">
        <xsl:with-param name="OfficeCodeList" select="$oldOfficeCodeList"/>
        <xsl:with-param name="OfficeCodeArgSeperator" select="','"/>
      </xsl:call-template>
    </xsl:variable>

The new set of office codes:
<xsl:variable name="newOfficeCodeListXML" as="node()*">
      <xsl:call-template name="codeListAsXML">
        <xsl:with-param name="OfficeCodeList" select="$newOfficeCodeList"/>
        <xsl:with-param name="OfficeCodeArgSeperator" select="','"/>
      </xsl:call-template>
    </xsl:variable>


I tried some different ways to get the except and or intersect in the
following variables with the result following the ==>
      <newOfficeCodeList>PT,BX,FR</newOfficeCodeList>
        <oldOfficeCodeList>BX,FR</oldOfficeCodeList>

 <xsl:variable name="exceptOldNewOfficeCode"
select="$newOfficeCodeListXML  except $oldOfficeCodeListXML"/>
         ==> <exceptOldNewOfficeCode>PT BX FR</exceptOldNewOfficeCode>


 <xsl:variable name="intersectOldNewOfficeCode"
select="$newOfficeCodeListXML  intersect $oldOfficeCodeListXML"/>
       ==>    <intersectOldNewOfficeCode/>


   <xsl:variable name="DSexceptOldNewOfficeCode"
select="distinct-values($newOfficeCodeListXML[not(. =
$oldOfficeCodeListXML)])"/>
      ==>     <DSexceptOldNewOfficeCode>PT</DSexceptOldNewOfficeCode>



    <xsl:variable name="DSintersectOldNewOfficeCode"
select="distinct-values($newOfficeCodeListXML[. =
$oldOfficeCodeListXML])"/>
       ==> <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

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

<Prev in Thread] Current Thread [Next in Thread>