This is the mail archive of the xsl-list@mulberrytech.com mailing list .
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi,
I might not have described this very well. I think the xsl:choose is kind of what I am looking for. I realize that <xsl:if test="@in_textarea"> will test true if it is set to anything (i.e. true, false). That is part of the reason I am looking for a more general mechanism to accomplish this.
Given the XML:
<column name="model" type="String" description="Auto Model" field_type="textarea">Mustang</column>
<column name="vin" type="String" description="VIN Number" field_type="textbox">Abc</column>
Either pick 1 or 2 based on the value of field_type:
<xsl:variable name="field">
<xsl:value-of select='attribute::field_type'/>
</xsl:variable>
<xsl:choose>
<xsl:when test='$field=textbox'>
<!-- choice 1 --> <td><INPUT TYPE="text" Name="{$table_name}:{$attribute_name}" Value="{$field_name}"/></td>
</xsl:when>
<xsl:when test='$field=textarea'>
<!-- choice 2 --> <td><textarea Name="{$table_name}:{$attribute_name}" ROWS="4" COLS="40"><xsl:value-of select='.'/></textarea></td>
</xsl:when>
</xsl:choose>
I am pretty sure that I am testing these things wrong, but the one example I can find that uses this
<xsl:when test='$level=1'>
doesn't really explain what the different pieces are. What I have above doesn't work.
Kerry.
-----Original Message-----
From: Steve Tinney [SMTP:stinney@sas.upenn.edu]
Sent: Friday, February 11, 2000 11:28 AM
To: xsl-list@mulberrytech.com
Subject: Re: Using the xsl:if correctly
> like to be able to do something a little more generic. Unfortunately,
> either the xsl:if doesn't support it, or I have been doing it wrong.
> How do I fix this?
I'm not really sure what you mean. Do you mean that you want a more
generalized conditional control mechanism? If so, xsl:choose, xsl:when
and xsl:otherwise are probably what you are looking for. See the XSLT
spec section 9.2, with its example.
Steve
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |