Re: [xsl] can you select name() of attributes?

Subject: Re: [xsl] can you select name() of attributes?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 27 Jul 2004 10:51:41 +0100
> I think it drops down to the following: can you select name() of attributes in 
> a select attribute in an xsl element?


as for any node


will return the name of the selected node ("baz") in thi scase.

> <xsl:variable name="Attr" select="$Doc/@*"/> which selects all attributes in 
> the Doc variable (which are text values as far as I know...?)

No. That selects attribute nodes not text values.

> I want to be able to use the name of the attributes in the same way as a 
> reqular nodeset, 

well tough, it's a string not a node set:-)

> where I can say node-A=nodeset-B which in a nodeset is true 
>if just one node in nodeset-B is equal to node-A.

As MK says most days you can do this in XPath 2 but not in Xpath 1
howver you can do it in xslt 1.

If you have two sets of attributes, eg

<xsl:variable name="Attr1" select="$Doc1/@*"/>
<xsl:variable name="Attr2" select="$Doc2/@*"/>

Then you want something like:

<xsl:for-each select="$Attr1">
 <xsl:for-each select="$Attr2[name()=name(current())]">
this is in Attr and Attr2: <xsl:value-of select="name()"/>

This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread