[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL to generate XPaths

Subject: Re: XSL to generate XPaths
From: Michael Strasser <M.Strasser@xxxxxxxxxxxxx>
Date: Thu, 17 May 2001 23:20:33 +1000
conditional xpaths
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.