xsl-list
[Top] [All Lists]

Re: [xsl] Store node into variable

2015-04-21 08:33:32
Thanks! I opted for XPath and that worked exactly as I needed it.


On 21/04/15 15:22, Michael Kay mike(_at_)saxonica(_dot_)com 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(_at_)saxonica(_dot_)com
+44 (0) 118 946 5893



--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

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