xsl-list
[Top] [All Lists]

RE: [xsl] Find the root element from an attribute node

2008-07-10 07:00:26
I want to detect 
whether the ancestor of the particular href is <html> as 
opposed to <map>, <task>, <concept> or <reference> so that I 
can treat it differently. How do I do it?

<xsl:template match="@href[ancestor::html]">


Is never going to work. 

Why not? match="html//@href" is more conventional, but your form is just as
good. It assumes, of course, that you somewhere do apply-templates to the
attribute node.

I've read with bewilderment the 
threads about the xslt spec and that attributes are children 
of elements but elements are not parents of children... 

No you've got that the wrong way around.

The relationship between elements and subelements is called "child" in one
direction and "parent" in the other.

The relationship between elements and attributes is called "attribute" in
one direction and "parent" in the other.

You can always go up from an attribute using the parent or ancestor axes.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--