[erlang-questions] beginner: Generating HTML with ">" from Erlang
Richard A. O'Keefe
ok@REDACTED
Fri Feb 14 02:01:00 CET 2014
On 14/02/2014, at 1:50 AM, Magnus Henoch wrote:
> Anthony Ramine <n.oxyde@REDACTED> writes:
>
>> Why do you want to do that?
>>
>> An HTML document with a single « > » in the middle of nowhere is not valid nor well-formed HTML.
>
> It is in fact valid HTML.
Note that while
<script ...>if (a[i[k]] > y)...</script>
is legal XML,
<script ...>if (a[i[k]]>y)...</script>
is not.
Now there's a rather unpleasant difference between HTML
and XHTML here.
The content model for <script> in XHTML is (#PCDATA).
This means that the content of a script element is just
like ordinary text and may contain escaped characters.
So in XHTML,
<script ...>if (a[i[k]]>y)...</script>
must work.
But in HTML, the content model is CDATA, which means that
character and entity references are not allowed, or
rather than things that *look* like character and entity
references are just plain characters passed straight through.
So in HTML,
<script ...>if (a[i[k]]>y)...</script>
passes '&' 'g' 't' ';' through to the Javascript processor.
But remember, ']]>' is *still* illegal, and so is '</'.
So you *want* to escape > and < but you *can't*.
The basic issue here is that xmerl supports *XML*.
Using xmerl to generate HTML (as opposed to XHTML)
is not unlike trying to write C code using a
program designed to make writing Javascript easy.
This is compounded by the fact that a number of
current browsers do not understand XHTML 1.1 and
treat the <script> element like the one in HTML 4.01.
Ouch.
More information about the erlang-questions
mailing list