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

Re: Can a single XPath statement duplicate the funct

Subject: Re: Can a single XPath statement duplicate the functionality of this verbose <xsl:choose> statement?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 23 Oct 2011 20:21:12 -0400
Re:  Can a single XPath statement  duplicate the  funct
Sorry, of course that should be <xsl:copy-of/>.

At 2011-10-23 20:18 -0400, I wrote:
Presuming you have only a single attribute (the name() function will abend if you have more than one), this may work for you ... it expresses a sequence and selects the first member of that sequence:

<xsl:copy select="( ../Location[name(@*)=name(current()/@*)] ,
                    ../Location/@denomination ,
                    '0' )[1]"/>

This relies on the XPath 2 behaviour of sequence ( (), x ) collapsing to ( x ).

Note the use of current() to return the node that was current at the start of evaluating the XPath expression (also available in XPath 1).

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.