Re: [xsl] I mean self::* doesn't select attributes :(

Subject: Re: [xsl] I mean self::* doesn't select attributes :(
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 25 Apr 2001 10:45:21 +0100
Hi Evan,

> What I naturally tried was:
> @*[self::xyz:foo]
> But that doesn't work, because the self axis will *never* select
> attributes except with self::node(), being that *element* is the
> principal node type of the self axis and there is no attribute()
> node test (not that that would be useful).

An attribute() node test would be useful in this context if it
operated in the same way as processing-instruction() i.e. if you could
pass a string as a value to it and that would be used to test the name
of the attribute:


Of course the string could be a variable:


and then you could do things like:


rather than:

  @*[name() = $attr]

The big trouble would be handling namespaces with this syntax - is the
prefix in the name string resolved according to the current namespace
declarations within the stylesheet or is it a match between the
actual qualified name of the attribute in the source and the string
that you have?

Of course if you had that kind of node test for attributes, then you
may as well have one for elements as well.  I believe that this kind
of node test syntax was in an early WD of the XPath Rec.



Jeni Tennison

 XSL-List info and archive:

Current Thread