Re: [xsl] constructing the Node Sets

Subject: Re: [xsl] constructing the Node Sets
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 27 Jan 2003 21:20:34 -0800 (PST)
"Joerg Heinicke" <joerg.heinicke@xxxxxx> wrote in message
news:3E35E0F1.1030305@xxxxxxxxx
> XML:
> 
> <root>
>      <a>
>          <node>1</node>
>          <node>2</node>
>          <node>3</node>
>          <node>4</node>
>          <node>5</node>
>      </a>
>      <b>
>          <node>3</node>
>          <node>4</node>
>          <node>5</node>
>          <node>6</node>
>          <node>7</node>
>          <node>8</node>
>      </b>
> </root>
> 
> XSL:
> 
> <xsl:template match="/root">
>    <root>
>      <xsl:variable name="a" select="a/node"/>
>      <xsl:variable name="b" select="b/node"/>
>      <c>
>        <xsl:copy-of select="$a[. = $b]"/>
>      </c>
>    </root>
> </xsl:template>



The question was for an XPath expression that returns the intersection
of two node-sets. The above obviously will not work like that. E.G. for
nodes that do not have text children, or generally for non-element
nodes, for multiple nodes having the same string string value, for
nodes having more than one text child, etc.

Node-set intersection of a node-set $a and node-set $b is given by the
following XPath expression (Kaysian method):

$a[count(. | $b ) = 1]




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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


Current Thread