RE: [xsl] WITH-PARAM with node as argument?

Subject: RE: [xsl] WITH-PARAM with node as argument?
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Fri, 25 Apr 2003 12:54:54 -0400
[Andreas Schlegel]

> I would like to write a with-param statement with a node as 
> argument and 
> handle this node in a template. But I don't know if it is possible or 
> even what is the syntax. 

Yes it is possible and you were almost there - all you had to do was to
try it out.  You can also simplify the "textfield" template by using
attribute value templates.  Assuming that comp/attribute are the
elements you are interested in (as it seems from your example),  it
would look like this (modifying your templates a little) -

<xsl:call-template name="textfield">
   <xsl:with-param 
         name='comp' select='comp'/>
</xsl:call-template>
....

<xsl:template name='textfield'>
   <xsl:param name='comp'/>
 <tr>
   <th align="left"><xsl:value-of
select="{$comp/attribute[@name='country']/@label}"/></th>
     <td align="left" colspan="1">
       <input type='text'
name="{$comp/attribute[@name='country']/@name}"/>

... and so on
</xsl:template>

Now, in this particular case it would not give you any advantage if you
could arrange things so that "comp" is the context node when you call
the template - since call-template keeps the same context in effect and
so you would not need a parameter at all - but there are plenty of other
cases where it is extremely useful to be able to pass a node-set
(possibly containing just one node) as a parameter.

Cheers,

Tom P

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread