Re: [xsl] How to create a temporary xml tree and then re-use it

Subject: Re: [xsl] How to create a temporary xml tree and then re-use it
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Tue, 22 Jan 2002 22:03:59 +0100
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@xxxxxxxxxxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
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


Current Thread