xsl-list
[Top] [All Lists]

Re: can you select name() of attributes?

2004-07-27 02:51:41

I think it drops down to the following: can you select name() of attributes 
in 
a select attribute in an xsl element?

yes

as for any node

select="name(/foo/bar/@baz)"

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()"/>
 </xsl:for-each>
</xsl:for-each>
David

________________________________________________________________________
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:
http://www.star.net.uk
________________________________________________________________________