xsl-list
[Top] [All Lists]

Re: WITH-PARAM with node as argument?

2003-04-25 10:22:23
Martinez, Brian wrote:

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??"  ;-)
Well I tried it for some hours and could not find a solution that works. I already wrote a code like yours but it won't work. It is apity but I have the same problem with your example. The code builds the textfield but the values of label, name, size and value are empty!

Thanks for your help,
Andreas


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





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



<Prev in Thread] Current Thread [Next in Thread>