Re: [xsl] Attributes and Axis
Subject: Re: [xsl] Attributes and Axis|
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 13 Apr 2006 12:19:01 -0400
At 11:58 AM 4/13/2006, you wrote:
I'm trying to navigate thru the attributes of a element, but no
success. Something like
meaning if there is more attributes for this node...
Right. This won't work since attributes don't have siblings. They
have parents, but since they aren't children of their parents, they
aren't siblings of the other attributes.
But ofcourse that wont work...
I finnaly made what i want using
This works because when attributes are selected they are assigned a
context position, so there will be a last one -- but which one it is,
is up to the processor, since attributes are not ordered in the data model.
But what if i need to use axis with attributes? Or there arent't axis
with attributes? If so, how can i refrence other attributes on the
This is one place where XSLT 1.0 gets dicey. You can say ../@* to get
all the attributes on an element, starting from one of them. To get
all the *other* attributes, however, you more or less have to use an
explicit name test, as in "../@*[not(name()=name(current())]", which
is admittedly fairly ugly.
In XPath 2.0 you can say ../@*[not(. is current())] which is a bit
better, if not much.
To say more, we'd have to know more about why you're asking.
In general, these limits reflect the "second-class" status of
attributes in the XML/XSLT paradigm. Assuming your XML is
well-designed, this is mostly a good thing (attributes are easily
hidden or ignored, etc.): when something is "first-class" it should
be an element. I do understand that much XSLT is written to
ameliorate badly-designed XML.
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
Mulberry Technologies: A Consultancy Specializing in SGML and XML