[jdom-interest] Common interfaces..

Kenworthy, Edward edward.kenworthy at exchange.co.uk
Fri May 4 06:47:55 PDT 2001


Ah! That makes perfect sense. Thanks.

-----Original Message-----
From: Elliotte Rusty Harold [mailto:elharo at metalab.unc.edu]
Sent: 04 May 2001 14:22
To: jdom-interest at jdom.org
Subject: RE: [jdom-interest] Common interfaces..


At 12:16 PM +0100 5/4/01, Kenworthy, Edward wrote:
>>- Currently, the XML outputting capability is in a separate class,
>>and the JDOM
>>"nodes" don't know anything about it.
>
>+Currently this is true, but it doesn't have to be.
>
>Perhaps I am missing something but surely separation of the view from the
>model dictates that it should be ?
>

We've gone back and forth on this one. I think that XML documents are 
text, not abstract structures in memory. Therefore returning the text 
representation of one of our abstract structures is a fundamental 
operation. In fact the text form is more fundamental than our object 
form. That is, the model is the text. The object is the view.

We originally pulled out all the textifying code into XMLOutputter to 
allow much more control over syntax details like whether empty 
element tags were used or not, and whether extra white space was 
added to indent things, and indeed it is easier this way, but it's 
not the only way. Two possible solutions:

1. getSerializedForm() (or perhaps just get TextForm()) returns the 
canonical representation of the object with no extra white space or 
line breaks or indenting. This method is not necessarily used by 
XMLOutputter.

2. We pass in some sort of FormatOptions object to 
getSerializedForm() to specify how things like empty element tags and 
extra white space should be handled.

>toString() is already implemented isn't it ? I've certainly seen Element
>stringify itself.
>

But that's purely for debugging. It doesn't produce good XML. For 
instance the toString() of an Element does not include all the 
element's children and descendants.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list