You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Bennett <be...@glengroup.com> on 2003/08/05 23:15:46 UTC

using attributes in xsl:variable tree

Hello,

I'm trying to look for the starting element of nodes in another 
document, store the results of what I find in an xsl:variable and then 
use the information in the $results variable (get the values of various 
attributes in the elements returned, etc.)

I can get a start element into $results but, I can't seem to use 
$results as a node set. I've tried using the nodeset() extension 
function but still can't seem to get the values of the attributes from 
within $results.

Does anyone have any suggestions? (Is there a better way to handle the 
same situation)?

TIA

PS. I've also noticed that even when there are multiple matches I only 
ever get the first match in document order. How come?

------------------------------------------------------------
Here's an example of what I'm trying to do:

$file contains:
	...
	<test1 id="1">
		<test2 id="2">
			<test3 id="3"/>
		</test2>
	</test1>
	...

xsl stylesheet fragment:

...
<xsl:variable name="results">
	<xsl:for-each select="document($file)//*[local-name() = $x]">
		<xsl:copy>
			<xsl:copy-of select="@*"/>
		</xsl:copy>
	</xsl:for-each>
</xsl:variable>	
...

if $x = "test2"

then, in $results I get:
	<test2 id="2"/>

Now, I'm trying to get the value of the id attribute.

Here are the things I've tried (but all fail):
	<xsl:value-of select="$results/@id"/>
	
	<xsl:value-of select="exslt:node-set($results)/@id"/>
	<xsl:value-of select="local-name(exslt:node-set($results))/@id"/>