p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XSLT
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 29th, 2006, 01:18 PM
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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old March 29th, 2006, 02:02 PM
mhkay's Avatar
Wrox Author
Points: 12,642, Level: 48
Points: 12,642, Level: 48 Points: 12,642, Level: 48 Points: 12,642, Level: 48
Activity: 97%
Activity: 97% Activity: 97% Activity: 97%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,900
Thanks: 0
Thanked 80 Times in 78 Posts
Default

Both variables are "node-sets" (node sequences in XSLT 2.0 parlance). But each of them holds a single node, and they hold different nodes, so the intersection will be empty. Perhaps you are making the mistake of thinking that intersect compares nodes for equality rather than identity.

I think that what you are doing is probably a join rather than an intersection: the usual way of speeding this up in XSLT is to use keys.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
having problem with Between operator anantdev SQL Language 1 May 26th, 2008 09:14 AM
=== operator in c# surendraparashar C# 2005 8 November 8th, 2007 05:14 AM
Invalid operator for data type. Operator equals di Pusstiu SQL Server 2000 2 August 10th, 2007 05:51 AM
how to use like operator thillaiarasu SQL Server 2000 3 April 25th, 2007 09:53 AM
variable as operator... wrofox Classic ASP Databases 2 March 2nd, 2005 03:46 AM



All times are GMT -4. The time now is 08:23 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc