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[(_at_)name='Asm']/@obid"/>
<xsl:variable name="b" select="/Root/Class[(_at_)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(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]On Behalf Of
Roger Glover
Sent: Tuesday, January 28, 2003 12:39 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] 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