xsl-list
[Top] [All Lists]

[xsl] passing a sequence as a parameter

2008-02-26 04:20:04
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(_dot_)walpole(_at_)devon(_dot_)gov(_dot_)uk
Web http://www.devonline.gov.uk



Rob Walpole
Devon Portal Developer
Tel. 01392 382768
E-mail robert(_dot_)walpole(_at_)devon(_dot_)gov(_dot_)uk


--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--