This is a SAX filter which resolves all XInclude include elements before passing them on to the client application.
XIncluder is a SAX ContentHandler
that writes its XML document onto
an output stream after resolving all xinclude:include
elements.
XIncluder is a SAX ContentHandler
that writes its XML document onto
an output stream after resolving all xinclude:include
elements.
Based on Eliotte Rusty Harold's SAXXIncluder.
EncodingHeuristics
reads from a stream
(which should be buffered) and attempts to guess
what the encoding of the text in the stream is.
EncodingHeuristics
reads from a stream
(which should be buffered) and attempts to guess
what the encoding of the text in the stream is.
If it fails to determine the type of the encoding,
it returns the default UTF-8.
This is a SAX filter which resolves all XInclude include elements before passing them on to the client application. Currently this class has the following known deviation from the XInclude specification:
Furthermore, I would definitely use a new instance of this class for each document you want to process. I doubt it can be used successfully on multiple documents. Furthermore, I can virtually guarantee that this class is not thread safe. You have been warned.
Since this class is not designed to be subclassed, and since I have not yet considered how that might affect the methods herein or what other protected methods might be needed to support subclasses, I have declared this class final. I may remove this restriction later, though the use-case for subclassing is weak. This class is designed to have its functionality extended via a horizontal chain of filters, not a vertical hierarchy of sub and superclasses.
To use this class:
XIncludeFilter
object with a known base URLXMLReader
object from which the raw document will be read to thesetParent()
method of this object.ContentHandler
object to thesetContentHandler()
method of this object. This is the object which will receive events from the parsed and included document.LexicalHandler
object as the value of this object'shttp://xml.org/sax/properties/lexical-handler
property. Also make sure yourLexicalHandler
asks this object for the status of each comment usinginsideIncludeElement
before doing anything with the comment.parse()
methode.g.
translated from Elliotte Rusty Harold's Java source.