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

Re: Can a single XPath statement duplicate the func

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:56:11 -0400
Re:  Can a single XPath statement  duplicate the   func
At 2011-10-23 17:39 -0700, Mark wrote:
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'.

So I see. I failed to address the attributes after copying your original expression.


I think the expression below will work for you.

. . . . . . . Ken

~/t/ftemp $ cat mark.xml
<Stamps>
 <Stamp>
       <Formats souvenir-sheet="2895"/>
     <Location denomination="1"/>
</Stamp>

<Stamp>
      <Formats souvenir-sheet="2896"/>
     <Location denomination="5"/>
     <Location souvenir-sheet="1"/>
   </Stamp>
</Stamps>~/t/ftemp $ cat mark.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0">
  <xsl:output indent="yes"/>
  <xsl:template match="/">
    <xsl:for-each select="//Formats">
      <result>
      <xsl:copy-of select="( ../Location/@*[name(.)=name(current()/@*)] ,
                             ../Location/@denomination,
                             '0' )[1]"/>
      </result>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>~/t/ftemp $ xslt2 mark.xml mark.xsl
<?xml version="1.0" encoding="UTF-8"?>
<result denomination="1"/>
<result souvenir-sheet="1"/>~/t/ftemp $




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