[Home] [By Thread] [By Date] [Recent Entries]

Subject: RE: Using the xsl:if correctly
From: "Kerry Nice (DEN)" <Kerry.Nice@xxxxxxxxxxx>
Date: Fri, 11 Feb 2000 16:42:40 -0500
Title: RE: Using the xsl:if correctly

Perfect,
This is exactly what I was looking for:
      <xsl:if test="@field_type = 'textbox'">

You can't believe how long (and how unsuccessfully) I spent searching the net for an example that does this.  I guess I should have guessed this, but oh well.

Thanks,
Kerry.

    -----Original Message-----
    From:   Wendell Piez [SMTP:wapiez@xxxxxxxxxxxxxxxx]
    Sent:   Friday, February 11, 2000 7:56 AM
    To:     xsl-list@xxxxxxxxxxxxxxxx
    Subject:        Re: Using the xsl:if correctly

    My guess is Kerry is looking for something like:

    <td>
      <xsl:if test="@field_type = 'textbox'">
        <INPUT TYPE="text" Name="{$table_name}:{$column_name}"
               Value="{$field_name}"/>
      </xsl:if>
      <xsl:if test="@field_type = 'textarea'">
        <textarea Name="{$table_name}:{$column_name}"
                  ROWS="4" COLS="40">
          <xsl:value-of select='.'/>
        </textarea>
      </xsl:if>
    </td>

    Note that this solution creates a <td> in all cases, but creates no content
    for it if the field_type attribute is missing or has a different value from
    those handled explicitly. If you need an 'else' effect, use xsl:choose with
    xsl:when and xsl:otherwise.

    --Wendell Piez


    >desired XML:
    ><column name="model" type="String" description="Auto Model"
    field_type="textbox">Mustang</column>
    ><column name="vintag" type="String" description="VIN Number"
    field_type="textarea">abc</column>
    >
    >current XSL:
    ><!-- test to see whether the value goes in a textarea or text field -->
    ><xsl:if test="@in_textbox">
    >  <td><INPUT TYPE="text" Name="{$table_name}:{$column_name}"
    Value="{$field_name}"/></td>
    ></xsl:if>
    ><xsl:if test="@in_textarea">
    >  <td><textarea Name="{$table_name}:{$column_name}" ROWS="4"
    COLS="40"><xsl:value-of select='.'/></textarea></td>
    ></xsl:if>
    >
    >desired XSL:
    >???


    ======================================================================
    Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
    Mulberry Technologies, Inc.                http://www.mulberrytech.com
    17 West Jefferson Street                    Direct Phone: 301/315-9635
    Suite 207                                          Phone: 301/315-9631
    Rockville, MD  20850                                 Fax: 301/315-8285
    ----------------------------------------------------------------------
      Mulberry Technologies: A Consultancy Specializing in SGML and XML
    ======================================================================


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

Current Thread
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member