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

Subject: Re: [xsl] Find the root element from an attribute node
From: "vladimir@xxxxxxxxxxxxxxxxxxxx" <vladimir@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Jul 2008 08:22:21 -0700
> > <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

Current Thread