Re: [xsl] passing a sequence as a parameter

Subject: Re: [xsl] passing a sequence as a parameter
From: "Colin Adams" <colinpauladams@xxxxxxxxxxxxxx>
Date: Tue, 26 Feb 2008 11:36:13 +0000
Whether or not you can pass a sequence depends upon the processor. You
can do this with Gestalt, as it allows you to pass any XPath
expression. But you can't specify the type on the xsl:param with the
as attribute, which is unfortunate.

On 26/02/2008, Robert Walpole <robert.walpole@xxxxxxxxxxxx> 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

Current Thread