[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: passing a sequence as a parameter
Subject: Re: passing a sequence as a parameter
From: Geert Bormans <geert@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Feb 2008 12:31:11 +0100
|
why don't you pass a string instead of a sequence?
"true,false,true"
use tokenise() to make it a sequence in the XSLT
and index-of to help you with selecting the <name> you want to output
At 12:19 26/02/2008, you wrote:
Hi,
I am looking for a way of working with a sequence passed to a stylesheet
as a parameter. For example, I have an xml file as follows...
<root>
<user>
<name>Robert</name>
<name>Adam</name>
<name>Graham</name>
</user>
</root>
...which I want to pass to my XSLT along with a parameter containing a
sequence of values, lets say ('true', 'false', 'true'). I then want to
iterate through the name elements, only outputing something when the
corresponding value in the sequence is 'true'. In this case I would want
to return
<root>
<user>
<name>Robert</name>
<name>Graham</name>
</user>
</root>
What I have so far is this...
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:param name="my_params"/>
<xsl:template match="/root">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<xsl:template match="user">
<user>
<xsl:for-each select="name">
<xsl:if test="$my_params[...] = 'true'">
<name>
<xsl:value-of select="."/>
</name>
</xsl:if>
</xsl:for-each>
</user>
</xsl:template>
</xsl:stylesheet>
...which needless to say doesn't work, but hopefully will make clearer
what I am trying to do.
Thanks in advance.
Rob Walpole
Devon Portal Developer
Email robert.walpole@xxxxxxxxxxxx
Web http://www.devonline.gov.uk
Rob Walpole
Devon Portal Developer
Tel. 01392 382768
E-mail robert.walpole@xxxxxxxxxxxx
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|