[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: can you select name() of attributes?

Subject: RE: can you select name() of attributes?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 27 Jul 2004 11:08:24 +0100
xpath select name
> I want something that selects all the names of the 
> attributes. Is something 
> like the following possible?
> <xsl:variable name="Attr" select="$Doc/@*/name()"/> or
> <xsl:variable name="Attr" select="$Doc/name(@*)"/>
> 

The XPath type system doesn't allow sequences of strings, so you can't
assign a collection of names to a variable. (As DC pointed out, you can
iterate over this collection, though).

XPath 2.0 does allow sequences of strings. However the "/" operator only
works on sequences of nodes (a much-debated question). So you would write:

<xsl:variable name="attr" select="for $n in $Doc/@* return name($n)"/>

This then allows

if ($attr = 'abc')

to test if any of the names is equal to 'abc'.

Michael Kay

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.