Re: [xsl] XSL to generate XPaths

Subject: Re: [xsl] XSL to generate XPaths
From: Michael Strasser <M.Strasser@xxxxxxxxxxxxx>
Date: Thu, 17 May 2001 23:20:33 +1000
I found a couple of bugs in my XSL that showed up when an element had an
attribute and child elements with the same names.

>       <!-- If this is an attribute node, output '@' before its name. -->
>       <xsl:if test="../@*[name() = name(current())]">

The correct test to see if the current node is an attribute is:

  count(.|../@*) = count(../@*)

>       <!--
>         If the parent has more than one node with the same name as
>         the current one...
>       -->
>       <xsl:if test="count(../*[name() = name(current())]) &gt; 1">

Here I needed to check if the current node is an element:

  count(.|../*)=count(../*) and count(../*[name()=name(current())]) &gt; 1"

If anyone wants the new version of the whole thing, please let me know.

-- 
Michael Strasser
Brisbane, Australia

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread