View Single Post
  #1 (permalink)  
Old March 29th, 2006, 01:18 PM
kapy_kal kapy_kal is offline
Authorized User
 
Join Date: Mar 2006
Location: , , Canada.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default intersect operator

Hi,
I have two variables:
======
The first
=======
<xsl:variable name="v_areaBySRCCD">
    <WVS:areaBySRCCDCollection>
        <xsl:for-each-group select="//WVS:Src" group-by="WVS:srccode">
            <WVS:areaGroup>
                <xsl:attribute name="srccode" select="WVS:srccode"/>
                <xsl:for-each-group select="current-group()" group-by="WVS:areaCode">
                    <WVS:areaCode>
                        <xsl:value-of select="current-grouping-key()"/>
                    </WVS:areaCode>
                </xsl:for-each-group>
            </WVS:areaGroup>
        </xsl:for-each-group>
    </WVS:areaBySRCCDCollection>
</xsl:variable>
========
The second
========
<xsl:variable name="v_sizecoll">
    <xsl:variable name="v_coll">
        <WVS:Collection>
            <xsl:for-each-group select="//WVS:Src" group-by="WVS:areaCode">
                <WVS:area>
                    <WVS:areaCode>
                    <xsl:value-of select="current-grouping-key()"/>
                    </WVS:areaCode>
                    <xsl:variable name="v_cnt" select="sum(current-group()/WVS:count[string(.)!=''])"/>
                    <WVS:size>
                        <xsl:if test="$v_cnt &gt; 0">
                            <xsl:choose>
                              <xsl:when test="$v_cnt &lt;= 24">1</xsl:when>
              <xsl:when test="$v_cnt &lt;= 49">2</xsl:when>
    <xsl:when test="$v_cnt &lt;= 99">3</xsl:when>
    <xsl:when test="$v_cnt &gt;= 249">4</xsl:when>
                            </xsl:choose>
                            </xsl:if>
                        </WVS:size>
                    </WVS:area>
                </xsl:for-each-group>
            </WVS:Collection>
        </xsl:variable>
        <WVS:sizeCollection>
            <xsl:for-each-group select="$v_coll//WVS:area" group-by="WVS:size">
                <xsl:sort select="current-grouping-key()"/>
                <WVS:sizeGroup>
                    <xsl:attribute name="size"><xsl:value-of select="current-grouping-key()"/></xsl:attribute>
                    <xsl:for-each select="current-group()">
                        <WVS:areaCode>
                            <xsl:value-of select="WVS:areaCode"/>
                        </WVS:areaCode>
                    </xsl:for-each>
                </WVS:sizeGroup>
            </xsl:for-each-group>
        </WVS:sizeCollection>
    </xsl:variable>
=======
The first variable returns a node-set but the second one does not. I, therefore, am not able to apply the [u]intersect</u> operator to get <WVS:areaCode/>'s that result from their intersection. Do you have any idea why the second variable is not a node-set? Declaring it as node()* using the 'as' attribute does not work either.
Right now, I can generate a sequence of intersecting <WVS:areaCode/>'s by looping through each variable as a sequence but it is very slow when processing half a million records.
<xsl:variable name="areacodes" select="for $i in $areaBySRCCD//WVS:areaCode, $j in $sizecoll//WVS:areaCode return if ($i eq $j) then $i else ''"/>

Any suggestions?

Thanks,
Francine.

Reply With Quote