Subject: Re: [xsl] 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 |
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/@*
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.
-- 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Can a single XPath statem, G. Ken Holman | Thread | Re: [xsl] Can a single XPath statem, Mark |
Re: [xsl] Can a single XPath statem, Dimitre Novatchev | Date | [xsl] Using a TableHeader Vs Using , Vasu Chakkera |
Month |