Subject: RE: [xsl] Passing variable number of parameters to xsl file From: Jarno.Elovirta@xxxxxxxxx Date: Thu, 21 Mar 2002 10:57:20 +0200 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Passing variable number , Peter Davis | Thread | RE: [xsl] Passing variable number , Hunsberger, Peter |
RE: [xsl] More efficient way than f, Michael Kay | Date | RE: [xsl] MERGING 2 XML DOCS WITH d, Michael Kay |
Month |