From: Andreas Schlegel [mailto:schlegelaw(_at_)gmx(_dot_)de]
Sent: Friday, April 25, 2003 10:12 AM
Subject: [xsl] 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[(_at_)name='country']/@label"/>
<xsl:with-param name="name"
select="comp/attribute[(_at_)name='country']/@name"/>
<xsl:with-param name="size"
select="comp/attribute[(_at_)name='country']/@size"/>
<xsl:with-param name="value"
select="comp/attribute[(_at_)name='country']/@value"/>
</xsl:call-template>
You could reduce this to:
<xsl:call-template name="textfield">
<xsl:with-param name="country" select="comp/attribute[(_at_)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(_dot_)martinez(_at_)cendant(_dot_)com |
| 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