xsl-list
[Top] [All Lists]

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

2011-10-23 20:03:34
At 2011-10-23 17:58 -0700, Mark wrote:
Hi Ken,
I removed the [1] at the end to get all of the returns, and for the second example a '50' is returned, the @denomination[5] and the default [0]. It is clear that the @souvenir-sheet value is ignored in both cases. I am using XSLT 2, so it always collapses. Is there something incorrect with

../Location[name(@*)=name(current()/@*)]

It seems correct to me.

You are addressing the element and I copied that without thinking. I think you only want the attribute:

  ../Location/@*[name(.)=name(current()/@*)]

. . . . . . . . . . Ken

Mark

-----Original Message----- From: Mark
Sent: Sunday, October 23, 2011 5:39 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Can a single XPath statement duplicate the functionality of this verbose statement?

Hi Ken,
Yes, only one attribute to either element.

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

but I may have explained my needs incorrectly. Your statement works on the
first example below [uses @denomination] but returns nothing for the second
example; there it should return the value of the <Locations
@souvenir-sheet>, i.e., '1'.
Thanks,
Mark

<Stamp>
       <Formats souvenir-sheet="2895"/>
     <Location denomination="1"/>
</Stamp>

<Stamp>
      <Formats souvenir-sheet="2896"/>
     <Location denomination="5"/>
     <Location souvenir-sheet="1"/>
   </Stamp>


--
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>