[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Using the xsl:if correctly

Subject: RE: Using the xsl:if correctly
From: "Kerry Nice (DEN)" <Kerry.Nice@xxxxxxxxxxx>
Date: Fri, 11 Feb 2000 15:32:38 -0500
kerry nice
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.

    -----Original Message-----
    From:   Steve Tinney [SMTP:stinney@xxxxxxxxxxxxx]
    Sent:   Friday, February 11, 2000 11:28 AM
    To:     xsl-list@xxxxxxxxxxxxxxxx
    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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.