[jdom-interest] d-o-e, rendering embedded HTML and XMLOutputter

Elliotte Rusty Harold elharo at metalab.unc.edu
Tue Apr 16 08:05:10 PDT 2002


At 5:10 PM -0400 4/14/02, Gary Lawrence Murphy wrote:
>This problem has taken me across three mailing lists, and I'm not
>getting any closer ... but I do have some evidence it's a problem
>with the way I am using transformation on JDOM objects.
>
>Here's a scenario: Users enter free-hand (often broken) HTML into a
>webform textarea edit box. Their text is wrapped in an XML envelope,
>their HTML enclosed by <![CDATA[ ]]> to escape all the <>& chars and
>so the broken markup will parse.  This envelope XML document is
>stored, transported, retrieved and unpacked so the original
>user-entered HTML can be displayed on a weblog.  This is more or less
>the scenario for "disable-output-escaping".
>

Right there is your problem. The system design is fundamentally 
flawed. You're trying to treat PCDATA as markup and markup as PCDATA. 
This flies completely in the face of everything XML is about. As 
you've noticed there are some hacks that let you do this, but they're 
unreliable, especially as you begin integrating different APIs, 
technologies and tools.

You need to go back to the drawing board and design a system that 
simply does not depend on d-o-e at any step of the process. Ideally 
you should insist on well-formed HTML. If you can't do that, then you 
need an additional intermediate step in which the HTML text data is 
extracted from its containing element as plain text. But don't expect 
it treat a string as marked up text one minute and plain text the 
next. It just won't work. It's got to be one or the other, not both.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list