[XML-SIG] composite documents

Alexandre Fayolle Alexandre.Fayolle at logilab.fr
Sun Nov 9 13:00:26 EST 2003

On Thu, Nov 06, 2003 at 05:35:55PM +0100, Frederic Gobry wrote:
> Hi,
> I wondered what the best solution would be to solve the following
> problem:
> I've two families of XML documents my application generates. The first
> one (let's call it the Schema, even if it's a plain XML document) can
> be saved standalone, or as part of the second (the Data).
> I've a xml.sax.handler.ContentHandler derived class to parse the
> Schema, and I would like to somehow reuse it in the content handler of
> the Data parser. Is it possible, easy, not a good idea ?

Here's a nice XML parsing trick: you're allowed to change the
ContentHandler of a Sax reader during parsing (e.g. during a
startElement callback). So you can have the DataContentHandler register
the SchemaContentHandler during parsing and the SchemaContentHandler
register the DataContentHandler back when the Schema has been parsed. 

Alexandre Fayolle
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Développement logiciel avancé - Intelligence Artificielle - Formations

More information about the XML-SIG mailing list