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

Re: Passing a variable number of parameters?

Subject: Re: Passing a variable number of parameters?
From: Jakob Fix <jakob.fix@xxxxxxxxx>
Date: Mon, 27 Sep 2004 17:46:19 +0200
javascript variable number of parameters
David, Andrew,

thanks so far for your input.  On the one hand I am relieved that
there's no obvious solution which I missed, on the other hand I an
worried about the same thing, i.e. there's no straightforward way to
do what I need to do.

Does that mean what I want to do is weird and unusual (not that I
would mind ;-)?

On Mon, 27 Sep 2004 16:26:17 +0100, Andrew Welch
<ajwelch@xxxxxxxxxxxxxxx> wrote:
> 
> > This leads me to the second part of my question, because
> > somebody could say "Why don't you try it out?".  I need to
> > implement this in Javascript, and so far I haven't found a
> > way to create a NodeList that would be accepted by the XSL
> > processor (be it Gecko or MSIE) as valid parameter; I receive
> > "incompatibe type" errors.
> 
> If you are struggling to create a node list to pass in as a parameter,
> two other solutions are:
> 
> 1.  Create an xml file out of your node-list and then reference that
> using the document() function.  For example:
> 
> params.xml
> 
> <params>
>   <param name="bar" value="baz"/>
>   <param name="hello" value="world"/>
> </params/>
> 
> Then use:
> 
> <xsl:variable name="params" select="document('params.xml')"/>

Well, in a multi-user environment this won't work, unless I create a
unique file for each request which is out of the question, and
impossible as the client in this application cannot create files on
the server.

> 2.  Create your params as a well-formed string and then combine with the
> xml document (in also in string form) and then transform that.  For
> example:
> 
> var params = "<params> ..blah </params>";
> var xmlDoc =  "<root>" + params + original_xml_doc + "</root>";
> 
> (note the containing root element to keep everything well-formed)

This is interesting, I would have to modify the in-memory
representation of the source XML file.  I haven't thought of this,
probably because of was too focussed on the nodelist-as-a-parameter
problem.  Looking at your idea, it's certainly not a clean solution
because I have to modify the source file which is Not a Good Thing,
but it would at least be a temporary hack.

> You can then access your parameters using:
> 
> <xsl:variable name="params" select="/root/params"/>
> 
> cheers
> andrew 

By the way, how is this problem dealt with in other languages?  Is
this a Javascript idiosyncracy?  I suppose Java has a NodeList type
which processors will gladly accept?

thanks.
-- 
cheers,
Jakob.

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.