RE: select="*/@UNITS/.."

Subject: RE: select="*/@UNITS/.."
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Thu, 18 Mar 1999 10:53:33 -0000
Title: RE: select="*/@UNITS/.."

> I'm trying to find all child elements that have UNITS attributes by
> using * to find all child elements, @UNITS to winnow those down to the
> ones with UNITS attributes, and .. to select the parent node,
> like this:
>
> <xsl:template match="ATOM">
>   <xsl:apply-templates select="*/@UNITS/.."/>
> </xsl:template>
>
> However, this doesn't seem to actually work. Does anyone see a problem
> with what I'm doing?

Well one point is that the spec doesn't say whether an element is considered to be the parent of its attributes; it does however say that the children of an element are its child elements and character content (i.e. not its attributes), and we can guess that "parent" is intended to be the inverse relationship of "child".

But there's a much easier and cleaner way of doing it anyway:

> <xsl:template match="ATOM">
>   <xsl:apply-templates select="*[@UNITS]"/>
> </xsl:template>

Mike Kay

Current Thread