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

Re: Store node into variable

Subject: Re: Store node into variable
From: "Yoann Moranville yoann.moranville@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 21 Apr 2015 13:33:26 -0000
Re:  Store node into variable
Thanks! I opted for XPath and that worked exactly as I needed it.


On 21/04/15 15:22, Michael Kay mike@xxxxxxxxxxxx wrote:
Just use

<xsl:variable name="date" select="$element/date"/>

The way you are doing it, you are creating a temporary document to hold a copy of the date element. The variable is a document node, and document nodes have no name.


I would need the $date to be the same node as $date2 (I want to use a "xsl:choose" in the $date variable).

Either use XPath if() instead:

<xsl:variable name="date" select="if (X) then $element/date else $something.else"/>

Or use xsl:sequence and an @as attribute

<xsl:variable name="date" as="element(date)">
   <xsl:choose>
     <xsl:when test="X">
      <xsl;sequence select="$element/date"/>
    </xsl:when>
    ....
</xsl:variable>


Michael Kay Saxonica mike@xxxxxxxxxxxx +44 (0) 118 946 5893

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.