xsl-list
[Top] [All Lists]

RE: wierd textarea behaviour with xsl

2002-11-12 09:15:04
Declan,

At 10:18 AM 11/12/2002, you wrote:
So to try and force a value into the box I used an xsl choose.

<textarea rows="5" cols="40" name="comment" class="textbox">
        <xsl:choose>
                <xsl:when test="(./currentStatus/comment)">
                        <xsl:choose>
                                <xsl:when test="./currentStatus/comment !=
''">
                                        <xsl:value-of
select="./currentStatus/comment"/>
                                </xsl:when>
                                <xsl:otherwise>
                                        No comments.
                                </xsl:otherwise>
                        </xsl:choose>
                </xsl:when>
        </xsl:choose>
</textarea>

This has fixed it. Man, what a verbose way of having to populate a comment
box.

Tom SW suggested a way to mitigate how verbose it is.

Another way -- perhaps not as neat conceptually, but not requiring you to have a fallback node, is simply not to use the xsl:choose. Since, as you've noted, you get no output if there is no ./currentStatus/comment, your logic is equivalent to:

<textarea rows="5" cols="40" name="comment" class="textbox">
  <xsl:value-of select="currentStatus/comment"/>
  <xsl:if test="not(currentStatus/comment)">No comments.</xsl:if>
</textarea>

Not so bad, eh?

Notice I've trimmed your './currentStatus/comment' to 'currentStatus/comment' since they mean the same thing.

Others have addressed your getting the unwanted XML empty-element syntax. That's the real solution.

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
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