|
Re: Re: How can I insert 'raw' (X|XHT|HT)ML into my DOM?: msg#00028java.enhydra.xmlc
On Thursday 16 January 2003 15:17, dcorbin@xxxxxxxxxxxxxx wrote: > > It does if you output to XML (including XHTML, of course). > > So is there a frowned upon solution for XML? No - there's nothing in the DOM API that can be "recycled" for a hack like CDATA sections for HTML. And I really don't see a need for it, either, because it's no problem to parse an XML "snippet" (as opposed to HTML, where it's difficult enough to parse complete documents, let alone snippets) into a DOM with a run-of -the-mill XML parser and import the resulting node tree into the main DOM. > > 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. Sure - but you can't produce XML that's not wellformed (e.g. has unabalanced tags) as you can with the CDATA hack. > > - 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. That's why the CDATA hack is in there, so go ahead and use it. > But, the official frown is noted.... Well, it's more of a caveat that you lose a couple of nice features if you use the CDATA hack, actually. I just couldn't resist the temptation of the first sentence in the original post ("Although it's officially frowned upon, ...") :-) -- 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
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: How can I insert 'raw' (X|XHT|HT)ML into my DOM?, dcorbin |
|---|---|
| Next by Date: | RE: Re: How can I insert 'raw' (X|XHT|HT)ML into my DOM?, Mike Warne |
| Previous by Thread: | Re: Re: How can I insert 'raw' (X|XHT|HT)ML into my DOM?, dcorbin |
| Next by Thread: | Re: How can I insert "raw" (X|XHT|HT)ML into my DOM?, Jacob Kjome |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |