[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to create a temporary xml tree and then re-use
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: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|