[jdom-interest] Attribute defaults

Dennis Sosnoski dms at sosnoski.com
Tue Nov 20 14:12:24 PST 2001


With 20-20 hindsight I think an unfortunate choice was made early on in 
the design of XML parsers. It'd seem to make a lot of sense to use a 
layered approach to processing XML, along the lines of:

Layer 1 - parser, checks well-formed document and tokenizes document
Layer 2 (optional) - validator, handles document validation, default 
values, etc.
Layer 3 (optional) - document model, builds representation of document 
in memory

SAX/SAX2 assumes that what I've called Layer 2 is embedded in the parser 
(and completely hidden). This doesn't seem to provide any major 
benefits, but certainly causes a lot of problems. Having it separated 
out as another layer would be more modular and promote DTD & Schema 
validators that could work with a variety of parsers (and would also be 
easy to use for in-memory document validation, since it's easy to 
generate a parse event stream from the representation). It'd also make 
it more likely that the validators would expose information for external 
use.

  - Dennis

Tom Dimock wrote:

>At 01:48 PM 11/20/2001 -0400, Elliotte Rusty Harold wrote:
>
>>At 8:41 AM -0800 11/20/01, Jason Hunter wrote:
>>
>>>I would very much like Attributes to have that ability.  I think it's a
>>>feature we could have using an XNI-based builder.  It's only because SAX
>>>doesn't provide it that you can't get this information from SAXBuilder.
>>>Interestingly, it would be available using DOMBuilder.
>>>
>>SAX 2.1 is scheduled to provide this. API is still uncertain but see 
>>http://www.saxproject.org/apidoc/org/xml/sax/ext/Attributes2.html
>>
>
>Ok, so using that I could look at each attribute as it was read and test
>isSpecified. Whenever it returned false, I have "discovered" a default
>value and could save it.  I guess I was hoping for a more direct way to
>discover the defaults - this relies on reading an existing XML file in
>which each attribute is defaulted at least once.  It would be useless if I
>had built the tree programatically and then went to output it.  What is
>really needed is to have the schema available through some API.
>
>----------------------------------------------------------------------------
>       Tom Dimock  ----  Cornell University  ----  tad1 at cornell.edu
>"There go my people.  I must follow them, for I am their leader."  M. Gandhi
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
>





More information about the jdom-interest mailing list