xsl-list
[Top] [All Lists]

RE: [xsl] Predicate Evaluation

2007-11-26 08:15:11
Looking at your input... have you considered using a key? Like so:

<xsl:key name="ns2:Element2" match="ns2:Element2" use="."/>

...

<!-- the result of the key() will be a node-set containing the
ns2:Element2 elements -->
<xsl:for-each select="key('ns2:Element2',
$param1/ns1:Element1/ns1:Element2)">
  <ns3:Element2>
    <xsl:value-of select="."/>
  </ns3:Element2>
</xsl:for-each>

When you feed in a node-set to the second parameter of key(), it returns
a node-set that is equivalent to the result of calling key() on each
node in that node-set. Which would be the same as what you're doing here
- creating a ns3 copy of every node with an equal value between
ns1:Element2 and ns2:Element2.

~ Scott


-----Original Message-----
From: Fernando Ribeiro 
[mailto:webmaster(_at_)fernandoribeiro(_dot_)eti(_dot_)br] 
Sent: Monday, November 26, 2007 9:06 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Predicate Evaluation

Humm, my mistake. I was trying to select a ns2:Element2 element which
value is equal to the value of a ns1:Element2 element, instead. What
would be the right expression to do so? Thanks.

...

These are the inputs:

<ns1:Element1 xmlns:ns1="urn:ns1">
   <ns1:Element2>Test</ns1:Element2>
 </ns1:Element1>

<ns2:Element1 xmlns:ns2="urn:ns2">
   <ns2:Element2 attribute1="value1">Test</ns2:Element2>
  <ns2:Element3>value1</ns3:Element3>
 </ns2:Element1>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>