package sax
- Alphabetic
- Public
- All
Type Members
-
class
XIncludeFilter
extends XMLFilterImpl
This is a SAX filter which resolves all XInclude include elements before passing them on to the client application.
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:
- XPointer is not supported.
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:
- Construct an
XIncludeFilterobject with a known base URL - Pass the
XMLReaderobject from which the raw document will be read to thesetParent()method of this object. - Pass your own
ContentHandlerobject to thesetContentHandler()method of this object. This is the object which will receive events from the parsed and included document. - Optional: if you wish to receive comments, set your own
LexicalHandlerobject as the value of this object'shttp://xml.org/sax/properties/lexical-handlerproperty. Also make sure yourLexicalHandlerasks this object for the status of each comment usinginsideIncludeElementbefore doing anything with the comment. - Pass the URL of the document to read to this object's
parse()method
e.g.
val includer = new XIncludeFilter(base) includer setParent parser includer setContentHandler new SAXXIncluder(System.out) includer parse args(i)
translated from Elliotte Rusty Harold's Java source.
-
class
XIncluder
extends ContentHandler with LexicalHandler
XIncluder is a SAX
ContentHandlerthat writes its XML document onto an output stream after resolving allxinclude:includeelements.XIncluder is a SAX
ContentHandlerthat writes its XML document onto an output stream after resolving allxinclude:includeelements.Based on Eliotte Rusty Harold's SAXXIncluder.
Value Members
-
object
EncodingHeuristics
EncodingHeuristicsreads from a stream (which should be buffered) and attempts to guess what the encoding of the text in the stream is.EncodingHeuristicsreads 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.