[jdom-interest] XMLOutputter/SAXBuilder

Elliotte Rusty Harold elharo at metalab.unc.edu
Sat Sep 15 06:29:14 PDT 2001

At 6:54 PM -0500 9/14/01, philip.nelson at omniresources.com wrote:
>> It's actually not JDOM at all. SAX reports default attributes 
>> on an element,
>> and does not give any indication that these attributes /are/ 
>> default. In
>> other words, it's a "bug/feature" of SAX 2.0 itself. I don't 
>> know of anyway
>> to turn that processing off, and since SAX doesn't yet provide any
>> additional typing or related information about default vs. declared
>> attributes, I'm not sure how we could take care of it if we wanted to.
>This is close to what Elliotte wanted for his XInclude processor. 

I missed part of this thread, but I do see something that needs addressing here. This proposal is orthogonal to what I was asking for. XInclude and other XPath based systems don't need to know whether an attribute was specified or defaulted. I think is part of the infoset but it's not used nearly as much as attribute types. Attribute types are things like CDATA, ID, IDREFS, NOTATION, etc. An attribute of any type can either be specified or default. (Well actually you couldn't practically default an ID type attribute, but that's a minor point.) 

If we want to provide an isSpecified() method on Attribute then this would be separate from the getType() method. 

> I think
>it would be possible when setExpandEntities is false and the DTDHandler is
>active.  Elliottes idea was some sort of AttributeType class 

You'd actually need a DeclHandler and then some to report whether an attribute is or is not defaulted. I don't think SAX2 exposes this in any consistent way. This is scheduled top be added in SAX 2.1. However, attribute types are available for all reported attributes in standard SAX.  

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/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.ibiblio.org/xml/     |

More information about the jdom-interest mailing list