[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] First element with given attribute values


Subject: RE: [xsl] First element with given attribute values
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Sun, 11 Apr 2004 19:36:07 +0200

> -----Original Message-----
> From: Nicolas Mailhot [mailto:Nicolas.Mailhot@xxxxxxxxxxx]
>
> Thanks everyone for the info!
>
> I already had something with keys, but it was much less elegant since
> the test was not node in the match part but via an xsl:if the template.
>
> I this particular case the trimming is done on a variable (via
> exsl:node-set()) so keys do not work (the keyed tree must exist at the
> start of the processing, right ?).
>

Strictly speaking: the key definition is not linked to a certain tree before
it is called upon by key(). When key()  is used, the context node determines
which document the key() function operates on. If you change that by use of,
for example:
<xsl:for-each select="document('x')/*">

When key() is used inside the for-each, it will return nodes from
document('x').

In theory, this opens up the possibility of redirecting the content of your
node-set variable to a separate (temporary) XML file, and use key() in
combination with document() as described above to have it return the nodes
from you temporary tree.
The use of a temp-file to store the node-set variable in itself can be
considered to be suboptimal, I guess, but just to show that the possiblity
does exist...


Cheers,

Andreas


Current Thread
Keywords
xml