When you say you "will modify it so that it generates SAX events"
I guess you mean that you are going to remove the functionality that
currently generates XML as text. I guess you want to do that for
performance reasons(?) or because you have some other downstream
processing that you want to connect to(?).
To get down to code for a moment (always clearer I think), suppose
you have an object "fred" and a class that generates XML (Generator).
I suppose at the moment you do something like:
ContentHandler handler = ...
Generator generator = new Generator();
Writer writer = new StringWriter();
generator.setWriter(writer);
generator.encode(fred);
Reader reader = new StringReader(writer.toString());
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
ErrorHandler errorHandler = ...
xmlReader.setErrorHandler(errorHandler);
xmlReader.parse(reader);
I imagine that you want to change this to the following:
ContentHandler handler = ...
Generator generator = new Generator();
generator.setContentHandler(handler);
ErrorHandler errorHandler = ...
generator.setErrorHandler(errorHandler);
generator.encode(fred);
and somehow get a SAX validator involved. Frankly I wouldn't
try this, it appears to be a huge amount of effort for marginal
benefit (unless I'm missing something in what you are trying
to achieve).
Huw
-----Original Message-----
From: Verachten Bruno [mailto:[EMAIL PROTECTED]
Sent: 03 January 2005 16:52
To: [EMAIL PROTECTED]
Subject: Using Xerces as a validating parser with SAX events
Hi,
I have a class that generates XML into a Writer from a Java object
tree. I will modify it so that it generates SAX events.
I'd like to use the Xerces validation engine to check the generated
XML, but I just can't see how to plug it into my code.
I know I could do an identity transformation to get it running, but I
would prefer not having any dependancy with Xalan.
Did I miss something, or can't it be done?
Thanks.
Bruno Verachten
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]