[erlang-questions] beginner: Generating HTML with ">" from Erlang

Bengt Kleberg bengt.kleberg@REDACTED
Mon Feb 17 09:14:34 CET 2014


Greetings,

Thank you for this suggestion with ‘#xml-inheritance#’/0.
I changed ‘#text#’/1 to 'script'/4, ignore all arguments and return the script as it was (with ">"). Works for me.


bengt
________________________________________
From: erlang-questions-bounces@REDACTED [erlang-questions-bounces@REDACTED] on behalf of Ulf Wiger [ulf@REDACTED]
Sent: Thursday, 13 February 2014 4:08 PM
To: Szoboszlay Dániel
Cc: erlang questions
Subject: Re: [erlang-questions] beginner: Generating HTML with ">" from Erlang

You don’t need to copy xmerl_xml.

Simply write the following module.

====================================
-module(szoboszlay_xml).
-export([‘#text#’/1, ‘#xml-inheritance#’]).

‘#xml-inheritance#’() -> [xmerl_xml].

'#text#'(Text) -> ["<![PCDATA[", xmerl_lib:export_text(Text), "]]>”].
====================================

And you’re done. ;-)

BR,
Ulf

On 13 Feb 2014, at 15:48, Szoboszlay Dániel <dszoboszlay@REDACTED> wrote:

> I think it's not possible to add CDATA or PCDATA directives in out-of-the-box xmerl. But you can write your own callback module by simply copying xmerl_xml and changing '#text#'/1 slightly:
>
> '#text#'(Text) -> ["<![PCDATA[", xmerl_lib:export_text(Text), "]]>"].
>
> Cheers,
> Daniel
>
> On Thu, 13 Feb 2014 15:25:43 +0100, Bengt Kleberg <bengt.kleberg@REDACTED> wrote:
>
>> This also sounds like a good idea. You would not happen to know how I
>> could get "![PCDATA[" into xmerl tuples?
>>
>>
>> bengt
>>
>> On Thu, 2014-02-13 at 15:20 +0100, Szoboszlay Dániel wrote:
>>> What about wrapping the Javascript code in a <![PCDATA[ ... ]]> section?
>>> The browser shall parse > as < in PCDATA before interpreting it as
>>> Javascript code.
>>>
>>> Daniel
>>>
>>> On Thu, 13 Feb 2014 15:13:56 +0100, Bengt Kleberg
>>> <bengt.kleberg@REDACTED> wrote:
>>>
>>> > Javascript needs ">".
>>> >
>>> >
>>> > On Thu, 2014-02-13 at 13:59 +0100, Anthony Ramine wrote:
>>> >> Mmmmh, right. Was thinking about <.
>>> >>
>>> >> That being said, code consuming HTML or XML shouldn’t see a difference,
>>> >> and not escaping could also introduce other bugs, as ]]> is not
>>> >> supposed to appear in content (in XML). This leads us to the original
>>> >> question, which was « why do you need to do this? ».
>>> >>
>>> >
>>> > _______________________________________________
>>> > erlang-questions mailing list
>>> > erlang-questions@REDACTED
>>> > http://erlang.org/mailman/listinfo/erlang-questions
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list