[jdom-interest] XSLT && JDOM

Elliotte Rusty Harold elharo at metalab.unc.edu
Tue Jun 20 07:19:38 PDT 2000

At 2:42 AM -0400 6/20/00, bob wrote:
>Howdy folkeses-
>I've recently become smitten with XSLT stuff (theoretically,
>at least, after reading chapter 14 of Elliotte's book.
>[online, free, and wacky cool]).
>Anyhow, it seems that XSLT stuff defines 'content' to be
>the character data between open and close tags.  Which could
>include the content of nested children.

Part of the problem is that different XML specs define the same terms 
in different ways and use different names for the same things. 
Unofficial APIs like SAX and JDOM add even more cooks to the XML 
soup. This is only slowly being straightened out. In both SAX2 and 
JDOM, I've been arguing for as much consistency as possible with XML 
terminology. Sometimes I win. Sometimes I don't.

Even within the morass of different specs, some books are more 
consistent and accurate than others. In Chapter 14 in particular I 
doubt that I was all that careful about what I meant when I wrote the 
word "content". However, in this case, I got lucky and you're right. 
Production 43 of the XML 1.0 spec defines content as

content ::=  (element | CharData | Reference | CDSect | PI | Comment)*

Thus, I do think that changing the name of the getContent() method to 
getValue() would be much more consistent with XSLT and XPath.

On a related note, I've been finishing up a medium-sized tutorial on 
JDOM to be given next Monday evening at XMLDevCon, and I find that I 
consistently misused getChildren() when what I really meant to do was 
getMixedContent().  I'm beginning to get used to it now, but I 
suspect this is a hurdle a lot of programmers are going to have to 
cross. I propose renaming all the getChildren() methods 
getChildElements() so there's no confusion. The various XML specs are 
all quite clear that elements aren't the only kind of children. 
Comments, processing instructions, and text nodes are children too. 
Only attributes are not children. We could perhaps rename 
getMixedContent() getContent() as well, which is a little more 
consistent (if not quite as necessary) since getMixedContent() 
currently works for the cases of both mixed and unmixed content.

| 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/     |

More information about the jdom-interest mailing list