Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xsl & textarea with no data

Reply
Thread Tools

xsl & textarea with no data

 
 
a113n
Guest
Posts: n/a
 
      12-31-2007
I have the following XSL code to handle textareas:
<!-- Match TEXTAREA -->
<xsl:template name="TEXTAREA" match="TEXTAREA">
<TEXTAREA ROWS="{@ROWS}" COLS="{@COLS}" NAME="{@NAME}">
<xsl:if test="@READONLY">
<xsl:attribute name="READONLY"><xsl:text>READONLY</xsl:text></
xsl:attribute>
</xsl:if>
<xsl:value-of select="."/>
</TEXTAREA>
</xsl:template>

The problem is that when there is no data, this comes out to be
something like this: <TEXTAREA .... /> instead of <TEXTAREA ...></
TEXTAREA>.

For some reason the browser treats everything after the textarea when
this occurs as apart of the textarea, which is obviously bad. Does
anyone know how I can get the browser to not do this or some way to
get the XSL to print out the ending </TEXTAREA> when there is no data
for the text area? Thanks in advance for your help.
 
Reply With Quote
 
 
 
 
a113n
Guest
Posts: n/a
 
      12-31-2007
Also, I am using the following doctype:

<HTML xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      12-31-2007
a113n wrote:
> I have the following XSL code to handle textareas:
> <!-- Match TEXTAREA -->
> <xsl:template name="TEXTAREA" match="TEXTAREA">
> <TEXTAREA ROWS="{@ROWS}" COLS="{@COLS}" NAME="{@NAME}">
> <xsl:if test="@READONLY">
> <xsl:attribute name="READONLY"><xsl:text>READONLY</xsl:text></
> xsl:attribute>
> </xsl:if>
> <xsl:value-of select="."/>
> </TEXTAREA>
> </xsl:template>
>
> The problem is that when there is no data, this comes out to be
> something like this: <TEXTAREA .... /> instead of <TEXTAREA ...></
> TEXTAREA>.


With XSLT 1.0 all you can do is use
<xslutput method="html"/>
and make sure you use a textarea element in no namespace.
With XSLT 2.0 you can also use
<xslutput method="xhtml"/>
and a textarea element (lower-case) in the XHTML namespace
http://www.w3.org/1999/xhtml.

If you are trying to output XHTML with XSLT 1.0 then it is not possible
to ensure that an empty textarea element is output as <textarea
....></textarea>. You will need to switch to HTML 4.01 in that case.



--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
a113n
Guest
Posts: n/a
 
      12-31-2007
Thanks for your help Martin. Unfortunately changing the output over
to HTML still gives me the same problem. I'm not sure what you mean
by using the TEXTAREA element in no namespace, could you elaborate on
this? I'm familiar with namespaces in reference to .NET, but not in
terms of XSL transformations.

How difficult is it to upgrade from XSLT 1.0 to 2.0? What bothers me
most about this is that everything was working fine until I
reformatted our server last nite, and now we have this problem. I've
bandaid solved the problem by adding a space to the textarea, but I do
not like this approach, something more delicate is required.
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      12-31-2007
a113n wrote:
> Thanks for your help Martin. Unfortunately changing the output over
> to HTML still gives me the same problem. I'm not sure what you mean
> by using the TEXTAREA element in no namespace, could you elaborate on
> this?


You need to do two things, you need to use
<xslutput method="html"/>
and you need to use result elements in no namespace so you need to get
rid of of the xmlns attribute in
<HTML xmlns="http://www.w3.org/1999/xhtml"" xml:lang="en" lang="en">
where you need to use
<html lang="en">
instead.

As for upgrading to XSLT 2.0, there are three XSLT 2.0 processors
currently, Saxon from <URL:http://saxon.sourceforge.net/> has a Java and
a .NET version, Gestalt is an Eiffel implementation, and Altova provides
it XSLT and XQuery tools as a native windows application.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      01-02-2008
a113n wrote:
> The problem is that when there is no data, this comes out to be
> something like this: <TEXTAREA .... /> instead of <TEXTAREA ...></
> TEXTAREA>.


XML considers those two forms identical. HTML doesn't. Are you sure you
used the xslutput directive to say you want to generate HTML rather
than XML?

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add </textarea> within <textarea> tags? frank.moens@gmail.com Javascript 1 07-04-2007 04:00 PM
Textarea Inside of a textarea wperry1@gmail.com ASP General 6 02-05-2006 08:00 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
XSL: textarea with xsl code??? Thomas S. XML 1 02-05-2004 05:38 PM
Removing carriage returns from <textarea></textarea> input Augustus ASP General 1 09-10-2003 04:55 AM



Advertisments