xsl-list
[Top] [All Lists]

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

2008-07-10 08:23:41
<xsl:template match="@href[ancestor::html]">

Is never going to work. 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... So, that being the case, how exactly do I find out
where my current @href came from?

What you've done should be fine, but its slow to walk the ancestor
axis to the root element each time, so just do:

<xsl:variable name="isHTML" select="exists(/html)" as="xs:boolean"/>

and then:

match="@href[$isHTML]"

This code is based on the assumption that xsl:apply-templates is called
for the input tree only, and not for any other loaded or constructed.
--
Vladimir Nesterovsky




--~------------------------------------------------------------------
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>
--~--