Fw: Textareas containing markup for not rendering

by "Alexander J. Vincent" <jscript(at)pacbell.net>

 Date:  Tue, 10 Jul 2001 07:06:46 -0700
 To:  hwg-techniques(at)hwg.org
  todo: View Thread, Original
Believe it or not, this isn't a question about "how do I get a textarea to
display markup".  I already know it's not meant to do that.

I've embedded a valid XHTML 1.0 Transitional document with a textarea inside
a copy of itself, in it copy's textarea.  I also deliberately broke the
inner </textarea> tag to have a space in it, so as not to actually close the
outer, real textarea.  However, when I fed it to the W3C HTML Validator, it
said my document was no longer valid XHTML 1.0 Transitional, not by a long
shot.

So I did a little research on HTML 4, which XHTML 1.0 is a reformulation of
in XML.  The textarea element is only allowed to contain #PCDATA.  As I
understand it, this means any markup inside the textarea must be unrendered
and unparsed -- and must appear in the rendered textarea as source code.

I e-mailed the W3C Validator list about this issue, but the moderator for
that list denied me the posting, referring me to "If your page doesn't
validate, and you don't know why".  The FAQ sheets had nothing even close to
this problem, so here I am.

I believe, with the broken </textarea> tag, my document is still valid XHTML
1.0 Transitional.  The W3C HTML Validator disagrees, and the point of
contention, according to the HTML 4 DTD, is the definition of #PCDATA.  Have
I misunderstood the definition for #PCDATA, in that it can contain no markup
tags at all?  My belief is #PCDATA-only sections can contain tags, but must
not treat them as markup tags.

As a related and final question, I'd appreciate your opinion on whether the
document in question, submitted below, is indeed valid XHTML 1.0
Transitional.

P.S. -- in posting the below, the stupid e-mail program insists on changing
the standard script closing comment tag \/\/--> (minus backslashes) to
file://-->.  This is not my fault.

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title></title>
<script language="JavaScript" type="text/javascript">
<!--
function deliver() {
    loaded = true
    var data = document.forms.payload.data
    var TAReg = new RegExp("</ textarea>","gi")
    data.value.replace(TAReg, "</textarea>")
    parent.receiveData(self)
    }

function receiveData() {
    eval(document.forms.payload.data.value)
    }
//-->
</script>
</head>
<body onload="receiveData()">
<form name="payload" action="javascript:void(null)">
<input type="hidden" name="datatype" value="javascript" />
<input type="hidden" name="datalabel" value="" />
<!-- each page must define the data textarea contents -->

<!-- begin data storage section -->

<textarea name="data" rows="15" cols="30">
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title></title>
<script language="JavaScript" type="text/javascript">
<!--
function deliver() {
    loaded = true
    var data = document.forms.payload.data
    var TAReg = new RegExp("</ textarea>","gi")
    data.value.replace(TAReg, "</textarea>")
    parent.receiveData(self)
    }

function receiveData() {
    eval(document.forms.payload.data.value)
    }
//-->
</script>
</head>
<body onload="receiveData()">
<form name="payload" action="javascript:void(null)">
<input type="hidden" name="datatype" value="javascript" />
<input type="hidden" name="datalabel" value="" />
<!-- each page must define the data textarea contents -->

<!-- begin data storage section -->

<textarea name="data" rows="15" cols="30"><?php
echo "Hello World";
?></text area>

<!-- end data storage section -->

</form>
</body>
</html>

</textarea>

<!-- end data storage section -->

</form>
</body>
</html>

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA