[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Pipe Question


Subject: Re: [xsl] Pipe Question
From: Karl Stubsjoen <kstubs@xxxxxxxxx>
Date: Fri, 10 Jun 2005 08:04:04 -0700

I recently tried the following select for a param within a template
rule and it worked fine:

<xsl:param name="my_param" select="adfasdfijasdflkjsfs"/>

I thought that the param would be an empty set since the select was
"garbli-gook" and expected the select to fail against the supplied
list for the parameter, but indeed it was the entire supplied list for
the parameter.  This does increase my understanding of the param.  If
no value/list supplied for the param use the select.  The select does
not initialize/filter the param in any way.  Correct?

> No, you don't get a copy, you get the original.
Thanks for clarifying that.  However, nobody still has answered the question:

How do you write the select for a parameter to default to empty, not
the original source?  (I guess you could: select="garbli-gook")
So, a parameter within a template.  This parameter must evaluate to an
empty node-set when not supplied since later node test will be
peformed against the param.

On 6/9/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > If defined like this:
> > <xsl:param name="my_param" select="/"/>
> >
> > Or this:
> > <xsl:param name="my_param" select="."/>
> >
> > And the param "my_param" is not supplied you will end up with a copy
> > of the document source "/" or current context "." (respectively).  Do
> > I have this correct?
>
> No, you don't get a copy, you get the original.
> >
> > $match is a parameter for one of my templates.  The intent of the
> > template:  SELECT ALL -or- SELECT ALL where @component = $match.
> >
> > In this example:
> > <xsl:template match="X[@component=$match] |
> > X[not(@component=$match)]"/>
> >
> > Select ALL X elements who's @component is one of the $match elements
> > -OR- when $match does not exist, SELECT ALL.
>
> If a variable doesn't exist, you get an error. For any condition,
>
> match="X[condition] | X[not(condition)]"
>
> is equivalent to
>
> match="X"
>
> except in the special case where evaluating the condition causes an error.
>
> Michael Kay
> http://www.saxonica.com/


Current Thread