[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Passing variable number of parameters to xsl file

Subject: RE: Passing variable number of parameters to xsl file
From: Jarno.Elovirta@xxxxxxxxx
Date: Thu, 21 Mar 2002 10:57:20 +0200
pass variable to param
Hi,

> Hi, I need to be able to support a variable number of 
> parameters.  I am
> currently using Xalan v2.2.
> 
> For example, the user would invoke Xalan with parameters:
>   
> 	-PARAM paramName1 paramValue1 -PARAM paramName2 paramValue2  ...
> -PARAM paramNameN paramValueN
> 	(specific example: -PARAM autobrand1 ford -PARAM 
> autobrand2 lexus
> -PARAM tire1 goodyear -PARAM tire2 michellan)
> 
> where N could be for example 1...500.

Err... are you going to have n number of top-level xsl:param elements? You might want to consider passing in a single param that contains the data in XML and then use Xalan extension to convert that into a node-set, or having a single param that contains the param as e.g comma separated list; or write the parameter data into a separate document and access that with document() function.

> 1) Is there a way to get the param count other than having it 
> passed in
> as something like: -PARAM numParams 500?

Well, count(document('')/xsl:stylesheet/xsl:param), but you might as well hard code it.

> 2) What I need to do is test a node's value against all of the
> parameter values passed in.  Note that for each invocation N could be:
> 0, 1, 2, ..500.
> 
> I want to do something like:
> 
> 	if (nodeValue match any of the paramValues of passed in)
> 	then
>   		doSomething();
> 	endif
> 
> for each parameter "family" (ex. autobrand and tire mentioned above)
> 
> without being forced to have a set of fixed static hardcoded test
> statements in the xsl like:
> 
> 	if (nodeValue match $paramName1)
> 		doSomething()
> 	else if  (nodeValue match $paramName2)
> 		doSomething()
> 		...
> 	else if (nodeValue match $paramNameN)
> 		doSomething()
> 	endif
> 
> where doSomething() is the exact same function for all
> nodeValue/paramValue matches.

If you're really going to have n number of xsl:params, then you have to hard code that, but if you pass a single param containing the data as XML or in some easy-to-parse text format, then it't pretty easy to write a recursive template.

Santtu

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.