Subject: RE: WITH-PARAM with node as argument?
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Fri, 25 Apr 2003 10:34:29 -0600
|
> From: Andreas Schlegel [mailto:schlegelaw@xxxxxx]
> Sent: Friday, April 25, 2003 10:12 AM
> Subject: WITH-PARAM with node as argument?
>
>
> Hi,
>
> 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.
Not to pick on you, but I can't count how many times people qualify possible
solutions with "I don't know if it is possible . . ." to which my answer is
"Why don't you just TRY IT??" ;-)
Anyway:
> <xsl:call-template name="textfield">
> <xsl:with-param name="label"
> select="comp/attribute[@name='country']/@label"/>
> <xsl:with-param name="name"
> select="comp/attribute[@name='country']/@name"/>
> <xsl:with-param name="size"
> select="comp/attribute[@name='country']/@size"/>
> <xsl:with-param name="value"
> select="comp/attribute[@name='country']/@value"/>
> </xsl:call-template>
You could reduce this to:
<xsl:call-template name="textfield">
<xsl:with-param name="country" select="comp/attribute[@name='country']"/>
</xsl:call-template>
This will pass in a single param, country, as a node-set. Then your
template could be rewritten as:
<xsl:template name="textfield">
<xsl:param name="country"/>
<tr>
<th align="left"><xsl:value-of select="$country/@label"/></th>
<td align="left" colspan="1">
<input type="text" name="{$country/@name}" size="{$country/@size}"
value="{$country/@value}"/>
</td>
</tr>
</xsl:template>
Note the use of attribute value templates in the <input> tag to replace your
cumbersome xsl:element/xsl:attribute code.
hth,
b.
| brian martinez brian.martinez@xxxxxxxxxxx |
| lead gui programmer 303.708.7248 |
| cheap tickets, part of trip network fax 303.790.9350 |
| 6436 s. racine cir. englewood, co 80111 |
| cendant travel distribution services http://www.cheaptickets.com/ |
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|