Subject: [xsl] Passing a variable number of parameters? From: Jakob Fix <jakob.fix@xxxxxxxxx> Date: Mon, 27 Sep 2004 14:41:52 +0200 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] [ANN] Saxon 8.1, Michael Kay | Thread | Re: [xsl] Passing a variable number, David Carlisle |
[xsl] [ANN] Saxon 8.1, Michael Kay | Date | Re: [xsl] Passing a variable number, David Carlisle |
Month |