[jdom-interest] General questions

Joe Gangemi jgangemi at architag.com
Fri Aug 4 13:39:01 PDT 2000


Now that I understand that the functions are named based on the structure 
of the tree and not the structure of the document, I have some questions.

When a document is read into JDOM that does not contain newlines, are the 
elements with no text siblings in the tree considered to have only element 
content?

<root><elem1><elem2>This is text</elem2></elem1></root>

Elem1 contains elem2 only.

If you introduce newlines as follows:

<root>
<elem1>
<elem2>this text</elem2>
</elem1>
</root>

Does elem1 now have mixed content because there is a text node that 
contains a newline after the start-tag for elem1 (and after the end-tag for 
elem2?)?

If I issue a getMixedContent(elem1) request, what do I get back in the list 
from each example? Can I issue a getMixedContent() request on an element 
that does not have mixed content? Will it still return all the elements in 
the list?

I assume that if I add comments and PIs in elements with element content 
both with and without newlines that things get even more interesting.

Let's say that I am writing an application for a variety of XML instances 
and I want to process the elements consistently regardless of the ignorable 
newlines (and any other extraneous whitespace). I do, however, want to be 
aware of the newlines for error reporting or indexing purposes (whatever).

The underlying question is how do I do this? Do I always treat all elements 
as mixed content on the chance that newlines might intervene and sort it 
out in my own code? Or do I need to check for mixed content first then 
issue either a getMixedContent() or getElement() request accordingly?

The questions posed above assume that extraneous whitespace, such as 
newlines, are stored in a text node. Is this correct? Is there any 
distinction made between a text node that only contains whitespace and one 
that does not?


================================================
Joseph V. Gangemi                               Senior Consultant
Architag International                          (856) 784-9522
Leveraging your information assets.             (856) 784-4350 (fax)
jgangemi at architag.com                   http://architag.com
8884129662 at alphapage.airtouch.com               (888) 412-9662 (pager)




More information about the jdom-interest mailing list