-----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
Ross Ken
Sent: Wednesday, 5 February 2003 3:10 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] creating a node-set at run-time
Untested but how about
<xsl:param name="var">
<xsl:for-each select="list/item[(_at_)ref]">
<xsl:copy-of
select="document(@ref)/root[(_at_)attrib='attrib-val']"/>
</xsl:for-each>
</xsl:param>
Ken Ross
Ph: +61 7 32359370
Mob: +61 (0)419 772299
Email: Ken(_dot_)Ross(_at_)iie(_dot_)qld(_dot_)gov(_dot_)au
I see a couple of limitations with this
1. It assumes the root element of every input document uses the name "root"
2. It does a deep copy (the whole tree) of each input document rather than
simply the contents of the ref attribute of the root element.
If these are issues for you, try
<xsl:variable name="var">
<xsl:for-each select="list/item[(_at_)ref]">
<xsl:value-of
select="document(@ref)/*[(_at_)attrib='attrib-val']/@ref"/>
</xsl:for-each>
</xsl:variable>
The string value of var will then be the concatenation of the values of
all the ref attributes.
Note that under XSLT 1.0, the processing options for variables as defined above
(i.e. as a result tree fragment) are fairly limited. It can
be turned into a node-set using a processor specific extension function, but
because
text nodes are aggregated, var will be a pretty simple tree consisting of a
root node
and a single text node.
If you want individual elements for each match for subsequent processing, try
adding
an element definition around each occurrence
e.g.
<xsl:variable name="var">
<xsl:for-each select="list/item[(_at_)ref]">
<match>
<xsl:value-of
select="document(@ref)/*[(_at_)attrib='attrib-val']/@ref"/>
</match>
</xsl:for-each>
</xsl:variable>
Then you can do something like (assuming you are in microsoft land)
<xsl:for-each select="msxsl:node-set($var)/match">
...
</xsl:for-each>
You'll also need to define the msxsl namespace on an element prior to the
above, typically the root element of the stylesheet, as
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
Regards
Michael
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list