[erlang-questions] beginner: Generating HTML with ">" from Erlang
Bengt Kleberg
bengt.kleberg@REDACTED
Fri Feb 14 06:42:20 CET 2014
Perhaps it was coincidence, but using xmerl to write HTML has never
failed me before. If xmerl can be made to handle Javascript I will
continue to use it. It is a good fit to how I think.
bengt
On Fri, 2014-02-14 at 14:01 +1300, Richard A. O'Keefe wrote:
> 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.
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list