[erlang-questions] beginner: xmerl:export_simple/2 wihtout changing > into >

Carsten Bormann <>
Fri Feb 14 00:32:37 CET 2014


> In particular,
> 	<p>"Some text with >"</p>
> and	<![CDATA["Some text with >"]]>
> would appear to be perfectly legal.

Yes.

> However,
> - the general difficulty of ensuring that ]]> does not occur
>  and the absence of a predefined name for ']' makes it
>  a good idea to always replace > by >

Well, at least it is the simple thing to do if you can’t match on ]]> and escape only those as ]]>

> - any XML tool chain that makes a program *have* to be aware
>  of a distinction between
> 	<p>"Some text with >"</p>
>  and	<p>"Some text with >"</p>
>  is one that I would have to be paid millions of dollars to use.

HTML is not an XML tool chain.
(The original poster was trying to use xmerl to generate HTML.)
HTML was not based on XML, but on the earlier SGML, and has some pretty weird reality for script elements, which cannot be directly expressed in XML (so you have to do weird things to generate something that is both HTML and XML/XHTML).

> So in short, how could anyone possibly "need" to keep '>'
> as '>' rather than '>' or '>’?

Never for actual XML.

> Not many people are aware of the illegality of ]]> in plain
> text.  None of the XML parsers I use is aware of it.  But it
> has always been illegal according to the XML specifications.

If you know about CDATA sections, you should have made that conclusion…
I would be very wary of an XML tool that doesn’t implement them.
$ echo '<foo> ]]> </foo>' | xmllint -
-:1: parser error : Sequence ']]>' not allowed in content
<foo> ]]> </foo>
      ^

Grüße, Carsten




More information about the erlang-questions mailing list