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]

RE: Using the xsl:if correctly


Title: RE: Using the xsl:if correctly

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]