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

Passing a variable number of parameters?

Subject: Passing a variable number of parameters?
From: Jakob Fix <jakob.fix@xxxxxxxxx>
Date: Mon, 27 Sep 2004 14:41:52 +0200
variable number of parameters
My question is twofold, one part is pure XSL, the other focuses on the
implementation side of things.

I need a way to pass a variable number of key-value pairs to the
stylesheet.  The keys are taken from a known, finite list, and can be
zero or more.  This appears impossible to achieve with xsl:params
because they must be known at compile time.  So, I thought the best
way would be to pass a NodeList or an XML fragment to one known
xsl:param.  Could somebody confirm this as correct, or is there a
better way to achieve this goal?

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.

I sincerely hope somebody on this list has a solution to this problem.


Some background:  I am developping an application which consists of a
client written entirely in {ECMA,J,Java}script.  The client access
electronic publications, and can also search their contents. To
display the hit count per publication, I transform the XML document
with the metadata information about the publications, with the hit
counts passed in as parameter (if possible).  The result will look a
bit like this:

+-------------------------------+
| - [328] Publication Title 1
| - Publication Title 2
| - [2] Publication Title 3
| - Publication Title 4
| [...]                          
+-------------------------------+

I imagine the nodelist to be stored in the parameter to look like this
<hits>
<hit for="id.of.publication1" number="328"/>
<hit for="id.of.publication3" number="2"/>
</hits>

And, finally, the template to use the nodeist parameter:
<xsl:template name="tpl.insert.hit.count">
<!-- current publication id supplied by caller -->
<xsl:param name="publication.id"/>

<!-- create a variable containing either a node, or is empty -->
<xsl:variable name="hit.node"
select="$hit.fragment/hits/hit[@id=$publication.id]"/>

<!-- if non-empty, output hit count stuff -->
<xsl:if test="$hit.node">
<span class='clsHitCount'><xsl:value-of select="$hit.node/@number"/></span>
</xsl:if>
</xsl:template>


Thank you very much in advance,
-- 
Jakob Fix.
[I have Gmail invitations.  Please contact me *offlist* if interested.]

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--

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.