osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: Re: How can I insert "raw" (X|XHT|HT)ML into my DOM? - msg#00026

List: java.enhydra.xmlc

Date: Prev Next Index Thread: Prev Next Index

If you used Barracuda, you could return the markup in a BText component and do..

BText = new BText("<div>some content</div>");
btext.setAllowMarkupInText(true);

Then just return the BComponent.

No messing with <![CDATA[ ....... ]]>


Jake

At 08:39 PM 1/15/2003 -0500, you wrote:
I have an application where I have access to some Markup Language in string form. I would like to (effectively) insert that into my DOM as a single unprocessable chunk so that when I render my DOM, it get's rendered as HTML rather then as a TextNode.  The only solution I can see is to parse that HTML and insert it as DOM objects, and I really rather not have to do that.

Thanks for any tips.

David

_______________________________________________
XMLC mailing list
XMLC@xxxxxxxxxxx
http://www.enhydra.org/mailman/listinfo.cgi/xmlc
Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

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). 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 - 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 -- 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

Next Message by Date: click to view message preview

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

Previous Message by Thread: click to view message preview

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

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

Next Message by Thread: click to view message preview

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

Something I have done before is to have another auxilary Document that has the document fragment, or fragments that I want to insert into my main DOM. When creating the main Document, I insert fragments from the other DOM. This allows you the possibility of having many variations in the dynamic data. The auxilary Document may have many "<div>" elements or other block elements. You can pick and choose which one(s) you need to insert into the master document. This may or may not apply to your situation. If the markup comes from an external source, then this may not work for you. Mike. -----Original Message----- From: Richard Kunze [mailto:kunze@xxxxxxxxx] Sent: Thursday, January 16, 2003 5:12 AM To: xmlc@xxxxxxxxxxx Subject: Re: Xmlc: Re: How can I insert 'raw' (X|XHT|HT)ML into my DOM? 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 _______________________________________________ XMLC mailing list XMLC@xxxxxxxxxxx http://www.enhydra.org/mailman/listinfo.cgi/xmlc
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by