xsl-list
[Top] [All Lists]

Re: [xsl] Can a single XPath statement duplicate the functionality of this verbose <xsl:choose> statement?

2011-10-23 19:21:26
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(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>