OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Schema-type-aware SAX processing

[ Lists Home | Date Index | Thread Index ]

> I have data that may be arbitrarily large and may conform to arbitrary
> XSDL schemata.  Because of the size, I want to process the 
> document as an
> event stream (hence SAX), and I want to make different processing
> decisions based on the declared types from the schema and based on the
> ultimate base types, if there's any type inheritance.
> 
> What's the right tool?  Perl is the language of choice, but 
> I'm flexible.
> 
> I've looked at libxml2 (and XML::LibXML), Xerces-C++ (and
> Xerces-p/XML::Xerces), and XSV.  They are all focused on 
> validation; the
> document is checked as to whether it fulfills the schema, but 
> there does
> not seem to be a straightforward way to say, "Hi.  I'm an 
> element.  What
> type am I?"
> 
> What am I missing?  Will SAXON-SA provide this ability?
> 

There's an API in JAXP 1.3 (available as part of JDK 1.5) that provides this
information; it's implemented both by Xerces and by Saxon-SA. It's somewhat
clumsy, however. It's done through the interface ValidatorHandler which
extends ContentHandler, and which allows you after a call on startElement to
get a TypeInfo object giving information about the type of the element or
any of its attributes. There's an example of its use in the
SchemaValidatorHandlerExample.java program included in the Saxon-SA
distribution.

Saxon's own SAX-like interface, the Receiver interface, provides type
information natively as part of each startElement or attribute event. This
also provides you with access to the schema components in considerably
greater detail than the TypeInfo interface: though it's all Saxon-specific.

Michael Kay
http://www.saxonica.com/  






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS