logo       

Re: Re: How can I insert 'raw' (X|XHT|HT)ML into my DOM?: msg#00027

java.enhydra.xmlc

Subject: Re: Re: How can I insert 'raw' (X|XHT|HT)ML into my DOM?

> On Thursday 16 January 2003 13:47, David Corbin wrote:
>> Joe Caron wrote:
>> >Hello David:
>> >
>> >While the following "cheat" is officially frowned upon, I'm convinced
>> >it's necessary in a very few hard cases (where you are dynamically
>> >inserting
>> > data that already contains markup, and the pain of creating
>> > appropriate dom objects is 20 times greater than the guilt you may
>> > feel about taking the easier way out).
>> >
>> >page.setTextContents(""); // remove any placeholder text
>> >
>> >CDATASection cds = page.createCDATASection ([some data containing
>> >markup
>> > you want used as markup]);
>> >
>> >page.getElementContents().appendChild(cds);
>> >
>> >....
>> >out.print(page.toDocument(request, response)).....
>>
>> Why doesn't that insert a CData in the form of [CData[...]] or what
>> ever the syntax is?
>
> It does if you output to XML (including XHTML, of course).
>

So is there a frowned upon solution for XML?

> In HTML, there are no CDATA sections, but sometimes the need to put
> unescaped markup into a DOM. What's more, the semantics of a CDATA
> section ("leave anything in here as is" :-) more-or-less matches the
> intended effect of putting chunks of verbatim markup into the
> document. So, it was kind of reasonable to reuse the CData support in
> the HTML DOM to support unescaped markup.
>
> BTW, here's the obligatory official frown :-) I'd strongly advise you
> to only use the CDATA hack if there's really no other reasonable way
> (say, you've got predefined markup in a legacy database or something
> like this) because putting raw markup into an XMLC DOM has a number of
> disadvantages: - If you're not careful, you can easily produce
> documents that are not valid HTML

I can easily produce invalid XML (not-DTD compliant) too.

> - DOM access methods like Document.getElementById(),
> Document.getLinks() etc. don't see the elements inside a CDATA node
> - Automatic URL rewriting doesn't work for links/forms/whatever inside
> of a CDATA node

I have a solution that is working by generating DOM objects. But it is
VERY complex, and am at a point where I think it will be getting even more
complex as I go forward.
But, the official frown is noted....

> --
> Richard Kunze
>
> [ t]ivano Software, Bahnhofstr. 18, 63263 Neu-Isenburg
> Tel.: +49 6102 80 99 07 - 0, Fax.: +49 6102 80 99 07 - 1
> http://www.tivano.de, kunze@xxxxxxxxx
>
>
> _______________________________________________
> XMLC mailing list
> XMLC@xxxxxxxxxxx
> http://www.enhydra.org/mailman/listinfo.cgi/xmlc


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise