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

Re: Can a single XPath statement duplicate the fu

Subject: Re: Can a single XPath statement duplicate the functionality of this verbose <xsl:choose> statement?
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Sun, 23 Oct 2011 20:18:22 -0700
Re:  Can a single XPath statement  duplicate the     fu
It does. I have put off downloading the book because of a lack of time right now, but I can see that I might be able to save time in the long run.
Thanks for the answers,
Mark


-----Original Message----- From: G. Ken Holman
Sent: Sunday, October 23, 2011 6:30 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Can a single XPath statement duplicate the functionality of this verbose statement?


At 2011-10-23 18:21 -0700, Mark wrote:
One more small question: I am confused by brackets in XPath;

The brackets specify a predicate used to keep or toss the nodes tested in the step from the next step of the location path.

what is the difference between
Location[name(@*)]

That is atypical. It is addressing the child element <Location> and only keeping it if there is an attribute, because the name() function returns a non-empty string. An empty string tests as false(), a non-empty string tests as true(). One wouldn't write the above because that particular predicate test is nonsensical in this situation (but not syntactically in error).

Location/@*

That addresses the attributes of the child element <Location>.


Location[@*]

That addresses the child element <Location> but only keeps it if the element has any attributes. If the element doesn't have attributes, the XPath expression stops getting evaluated.

Chapter 3 section 2 of my XSLT book (free preview download on my web
site) describes the syntax of XPath expressions in gory detail.

I hope this helps.

. . . . . . . . Ken


-- Contact us for world-wide XML consulting and instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal

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.