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

RE: constructing the Node Sets

Subject: RE: constructing the Node Sets
From: "Siva Jasthi" <siva.jasthi@xxxxxxx>
Date: Wed, 29 Jan 2003 09:29:40 -0600
siva jasthi
hi -

I have tried this out in my xsl, but it doesn't seem to be working.

Here is a sample A.xml and B.xsl.  (count of a: 4, count of b: 3, count of
c: 0) is the output of the html.

I expected that the intersection of a and b will produce a count of 2, but
it is coming out as 0.  (Because the obid="A" and obid="B" are common to
both a and b).

Can you pl. tell us where i am doing things wrong?

thanks
- siva jasthi



A.xml
-----

<?xml version="1.0" encoding="ISO-8859-1"?>

<?xml-stylesheet type="text/xsl" href="B.xsl"?>

<Root>
  <Class name="Asm" obid="A"/>
  <Class name="Asm" obid="B"/>
  <Class name="Asm" obid="C"/>
  <Class name="Asm" obid="D"/>
  <Class name="Cmp" obid="A"/>
  <Class name="Cmp" obid="B"/>
  <Class name="Cmp" obid="X"/>
</Root>


B.xsl
-----
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

  <xsl:variable name="a" select="/Root/Class[@name='Asm']/@obid"/>
  <xsl:variable name="b" select="/Root/Class[@name='Cmp']/@obid"/>

  <xsl:variable name="c" select="$a[ count( . | $b ) = count( $b ) ]"/>

count of a: <xsl:value-of select="count($a)" />
count of b: <xsl:value-of select="count($b)" />
count of c: <xsl:value-of select="count($c)" />


</xsl:template>

</xsl:stylesheet>





-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Roger Glover
Sent: Tuesday, January 28, 2003 12:39 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  constructing the Node Sets


Idea copied from Michael Kay's "XSLT Programmer's Reference", 2nd ed., Wrox
Press, 2001, p. 425 ...

<xsl:variable name="C" select="$A[ count( . | $B ) = count( $B ) ]"/>

The select expression selects the node subset C of node set A, composed of
any member node of A which, when added to node set B, produces a node set
the same size as B (in other words, the node was already in node set B).

The usage of A and B in the select expression can be reversed with no side
effects except possibly:
    o   a change in the list ordering of nodes in node set C
    o   a change in the speed of execution of the expression

-- Roger Glover

Siva Jasthi wrote
> I have constructed two variables (A and B) each of which contains a Node
> Set (through select="XPath Expression").
>
> A = [Node1, Node2, Node3, Node4, Node5]
> B = [Node3, Node4, Node5, Node6, Node7, Node8]
>
> I now would like to construct another variable C with the Nodes that exist
> both in A and B.  (So as to produce a third table with the Nodes that are
> common to both A and B).
>
> C= [Node3, Node4, Node5]
>
> Is there any way to construct C from A and B?.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.