relaxng / jing-trang

Schema validation and conversion based on RELAX NG
http://www.thaiopensource.com/relaxng/
Other
228 stars 69 forks source link

Add a SAX API to the Validation Driver #265

Closed adamretter closed 2 years ago

adamretter commented 2 years ago

This adds an API to the Validation Driver for directly working with SAX.

The issue I face without this is that within our XML Native Databases (i.e. eXist-db, Elemental, and FusionDB), XML documents are stored as a stream of SAX-like events.

When we wish to retrieve a document from the XML Native Database, we may do so using either SAX, StaX, or a lazy persistent like DOM approach.

However, all of the APIs for Jing's ValidationDriver require a SAX InputSource. Unfortunately a SAX InputSource requires you to take your XML data from either a Reader, InputStream, or URI (systemId)!

If we were to use an InputSource to take our data from the database, we would first have to first serialize our XML document from the database into a character stream stored on disk (or possibly in-memory), and then provide that to Jing. Jing would then have to deserialize that using an XMLReader to create a series of SAX events.

As our database can produce SAX events when reading a document, it is much more efficient to connect the two directly via SAX than it is to do a serialize and deserialize dance in the middle between the database and Jing.

I hope that makes sense, let me know if you have any questions - my changes are small and attempt to be as unobtrusive as possible! Kind regards :-)

adamretter commented 2 years ago

@murata2makoto Thank you so much for merging this so quickly :-) Kind regards.

sideshowbarker commented 2 years ago

For the record here, V20220510 (with this new API included) has been released to Maven and GitHub