Re: migrating from custom tags
Jacob Kjome <[email protected]> Wed, 01 Oct 2003 21:46:37 -0500
| Newsgroups | gmane.comp.java.enhydra.xmlc |
|---|---|
| Message-ID | <[email protected]> |
At 03:27 PM 10/1/2003 -0700, you wrote:
>Would there be any problem turning that custom tag into a utility class
>that just returns the whole nested table HTML as one fat String and
>slapping that into the DOM with a setFooText(fatStringHere) call? Or do
>we need to create new nodes in the DOM and create every HTML element
>present in the nested table structure?
> Since we already have this code working I'd like to leave it as is if
> at all possible.
Well, there is a quick hack you can use that might work for you. However,
you get no guarantee of a well formed document since the markup will pass
through un-parsed. Anyway, here's the hack if you want to try it....
Node msgPlaceHolder = page.getElementMessage();
Node report = page.createCDATASection(sb.toString());
msgPlaceHolder.getParentNode().replaceChild(report, msgPlaceHolder);
You'll have to make sure that you remove any <html>, <head>, or <body> tags
from the string of HTML.
The alternative is to load your database-stored HTML document as a DOM. In
order to do this, you'll have to parse it with an HTML parser such as
JTidy, NeckoHTML, or Jivan (which uses NeckoHTML). You could use XMLC's
dynamic loading for this purpose, although I believe it expects the data to
be loaded from a file located in a configured resource path. I wonder if
an enhancement wouldn't be to be able to also allow loading from an
InputStream? Anyway, I guess I'd try out the CDATA hack to see if that
works first since it is so simple.
Jake