[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Passing a variable number of parameters to a named
If you're using XSLT 1.1 processor (SAXON is the only one I know that won't barf), you can do something like: <xsl:call-template name="process_nodeset"> <xsl:with-param name="rtf"><a>1</a><b>2</b></xsl:with-param> <xsl:call-template> <xsl:template name="process_nodeset"> <xsl:value-of select="$rtf"/> </xsl:template> I think you could get at the values by using <xsl:value-of select="$rtf/a"/> <xsl:value-of select="$rtf/b"/> but I haven't tried that. If you're using XSLT 1.0, it's the same idea, but you can't say select="$rtf" because 1.0 doesn't implicitly convert Result Tree Fragments into nodesets, so you have to call an extension function that does the conversion (most processors have one, it might be called different names, but nodeset() or node-set() are common): <xsl:value-of select="myprocessor:node-set($rtf)"/> If you want to keep this parser-independent and don't want to use the extension function, you'll have to be a little tricky and access your stylesheet as an external XML document using document() function. There's some information on how to use document() in various places, check the list archive, the FAQ, the spec, or www.jenitennison.com - Eugene : -----Original Message----- : From: Chris Gow [mailto:cgow@xxxxxxxxxxxxxxxxxx] : Sent: Thursday, January 18, 2001 5:15 PM : To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx : Subject: RE: Passing a variable number of parameters to a : named-temp late : : : OK. Can I create the nodeset within my actual XSL : Stylesheet? The data : that I want to operate on will be created within the : stylesheet itself and : not be coming from an XML file. : : Chris : : At 05:00 PM 1/18/01 -0800, you wrote: : >: What I would like to do is duplicate what programming : >: languages have: pass : >: a number of parameters (or some similar mechanism) to a : >: template without : >: knowing how many parameters were actually passed. For : >: example, JavaScript : >: has the arguments array and Java allows you to pass an array of : >: objects. Can I implement something similar in XSL? I did a : > : >You can pass a nodeset, which can be treated as the XML : equivalent of an : >array. : > : >- Eugene : > : > XSL-List info and archive: : http://www.mulberrytech.com/xsl/xsl-list : : : XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list : 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
|