This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: How to create a temporary xml tree and then re-use it
- From: "Joerg Heinicke" <joerg dot heinicke at gmx dot de>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 22 Jan 2002 22:03:59 +0100
- Subject: Re: [xsl] How to create a temporary xml tree and then re-use it
- References: <3c4dcce4.23a6.0@telusplanet.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
You can do it like the following:
<xsl:variable name="$qty">
<load-qty>12</load-qty>
<load-qty>2</load-qty>
<load-qty>53</load-qty>
</xsl:variable>
The problem is that you don't have a nodeset now, only a Result Tree
Fragment. And on the RTF you can't work like on a nodeset. You need a
nodeset()-function, but it is processor-specific. An example for Xalan:
<xsl:stylesheet version="1.0"
xmlns:xsl="http:/www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan">
<xsl:variable name="$qty">
<xsl:for-each select="/root-element/load-qty">
<xsl:element name="qty">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<xsl:value-of select="sum(xalan:nodeset($qty)/qty)"/>
</xsl:template>
</xsl:stylesheet>
The XML:
<root-element>
<load-qty>12</load-qty>
<load-qty>2</load-qty>
<load-qty>53</load-qty>
</root-element>
Regards,
Joerg
----- Original Message -----
From: "Khalid" <k_ali@telusplanet.net>
To: <XSL-List@lists.mulberrytech.com>
Sent: Tuesday, January 22, 2002 9:34 PM
Subject: [xsl] How to create a temporary xml tree nd then re use it
> Hello,
> Can I create a temporary xml tree in memory and then re-use it.
> Like
> <load-qty>12</load-qty>
> <load-qty>2</load-qty>
> <load-qty>53</load-qty>
> Say I read the document and create a new element in memory called
<qty>12</qty>
> for each element from xml file
>
> and then run sum(qty)? on this newly created tree
>
> Thanks in advance
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list