Re: [xsl] Pipe Question

Subject: Re: [xsl] Pipe Question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 8 Jun 2005 09:55:13 +0100
It's still very hard to relate your descriptions to your example code.
 
>    So,
>    If match is "A" and "B" like this:
>    <match>A</match>
>    <match>B</match>

In the above match is the name of an element node
> 
>    Then the following will match X who's component attributes is either
>    an "A" or "B" value:
> 
>    <xsl:template select="X[@component=$match]"/>

But here it is a parameter name, presumably holding a string.
using a variable in a match pattern is a syntax error in XSLT1,
in XSLT2 it will match elements X with the specified value (if $match is
a string, if $match is a sequence then it will match X elements with
@component equal to any item in the sequence)


> 
>    And if the parameter match is not supplied, then the following will
>    match all X who either have or do not have a component attribute that
>    matches match:

para,eters always have a value, whether one is supplied or not, teh
stylesheet gives a default value.

>    <xsl:template select="X[@component=$match] | X[not(@component='$match')]"/>
> 
That is a syntax error xsl:template does not have a select attribute,
I'll assume you meant match. then it matches all the elements matched by
the first example and in addition matches all the elements for which the
component attribute is not the string "$match". (This is a string, not a
variable reference).

I doubt you meant the string "$match, perhaps you meant

    <xsl:template match="X[@component=$match] | X[not(@component=$match)]"/>

but that is just a long way of writing



> <xsl:param name="match" select="/"/>

>  I need this select to either evaluate to the "root" of the RTF
>    passed into match or nothing.


There are no RTF (result tree fragments) in XSLT2.
If you want to make teh default teh empty sequence rather than the
document node of the input doc, just specify () instead of /


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread