XIncludeFilter

class XIncludeFilter extends XMLFilterImpl

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:

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:

  1. 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 XIncludeFilter object with a known base URL
  • Pass the XMLReader object from which the raw document will be read to the setParent() method of this object.
  • Pass your own ContentHandler object to the setContentHandler() 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 LexicalHandler object as the value of this object's http://xml.org/sax/properties/lexical-handler property. Also make sure your LexicalHandler asks this object for the status of each comment using insideIncludeElement before 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.

Authors

Burak Emir

class XMLFilterImpl
trait ErrorHandler
trait ContentHandler
trait DTDHandler
trait EntityResolver
trait XMLFilter
trait XMLReader
class Object
trait Matchable
class Any

Value members

Concrete methods

override def characters(ch: Array[Char], start: Int, length: Int): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def endDocument(): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def endElement(uri: String, localName: String, qName: String): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def endPrefixMapping(prefix: String): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def ignorableWhitespace(ch: Array[Char], start: Int, length: Int): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
def insideIncludeElement(): Boolean

This utility method returns true if and only if this reader is currently inside a non-empty include element. (This is '''not''' the same as being inside the node set which replaces the include element.) This is primarily needed for comments inside include elements. It must be checked by the actual LexicalHandler to see whether a comment is passed or not.

This utility method returns true if and only if this reader is currently inside a non-empty include element. (This is '''not''' the same as being inside the node set which replaces the include element.) This is primarily needed for comments inside include elements. It must be checked by the actual LexicalHandler to see whether a comment is passed or not.

Returns

boolean

override def processingInstruction(target: String, data: String): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def setDocumentLocator(locator: Locator): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def skippedEntity(name: String): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def startDocument(): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def startElement(uri: String, localName: String, qName: String, atts1: Attributes): Unit
Definition Classes
XMLFilterImpl -> ContentHandler
override def startPrefixMapping(prefix: String, uri: String): Unit
Definition Classes
XMLFilterImpl -> ContentHandler

Inherited methods

@throws(org.xml.sax.SAXException)
def error(`x$0`: SAXParseException): Unit
Inherited from
XMLFilterImpl
@throws(org.xml.sax.SAXException)
def fatalError(`x$0`: SAXParseException): Unit
Inherited from
XMLFilterImpl
def getContentHandler(): ContentHandler
Inherited from
XMLFilterImpl
def getDTDHandler(): DTDHandler
Inherited from
XMLFilterImpl
def getEntityResolver(): EntityResolver
Inherited from
XMLFilterImpl
def getErrorHandler(): ErrorHandler
Inherited from
XMLFilterImpl
@throws(org.xml.sax.SAXNotSupportedException) @throws(org.xml.sax.SAXNotRecognizedException)
def getFeature(`x$0`: String): Boolean
Inherited from
XMLFilterImpl
def getParent(): XMLReader
Inherited from
XMLFilterImpl
@throws(org.xml.sax.SAXNotSupportedException) @throws(org.xml.sax.SAXNotRecognizedException)
def getProperty(`x$0`: String): `<FromJavaObject>`
Inherited from
XMLFilterImpl
@throws(org.xml.sax.SAXException)
def notationDecl(`x$0`: String, `x$1`: String, `x$2`: String): Unit
Inherited from
XMLFilterImpl
@throws(java.io.IOException) @throws(org.xml.sax.SAXException)
def parse(`x$0`: String): Unit
Inherited from
XMLFilterImpl
@throws(java.io.IOException) @throws(org.xml.sax.SAXException)
def parse(`x$0`: InputSource): Unit
Inherited from
XMLFilterImpl
@throws(java.io.IOException) @throws(org.xml.sax.SAXException)
def resolveEntity(`x$0`: String, `x$1`: String): InputSource
Inherited from
XMLFilterImpl
def setContentHandler(`x$0`: ContentHandler): Unit
Inherited from
XMLFilterImpl
def setDTDHandler(`x$0`: DTDHandler): Unit
Inherited from
XMLFilterImpl
def setEntityResolver(`x$0`: EntityResolver): Unit
Inherited from
XMLFilterImpl
def setErrorHandler(`x$0`: ErrorHandler): Unit
Inherited from
XMLFilterImpl
@throws(org.xml.sax.SAXNotSupportedException) @throws(org.xml.sax.SAXNotRecognizedException)
def setFeature(`x$0`: String, `x$1`: Boolean): Unit
Inherited from
XMLFilterImpl
def setParent(`x$0`: XMLReader): Unit
Inherited from
XMLFilterImpl
@throws(org.xml.sax.SAXNotSupportedException) @throws(org.xml.sax.SAXNotRecognizedException)
def setProperty(`x$0`: String, `x$1`: `<FromJavaObject>`): Unit
Inherited from
XMLFilterImpl
@throws(org.xml.sax.SAXException)
def unparsedEntityDecl(`x$0`: String, `x$1`: String, `x$2`: String, `x$3`: String): Unit
Inherited from
XMLFilterImpl
@throws(org.xml.sax.SAXException)
def warning(`x$0`: SAXParseException): Unit
Inherited from
XMLFilterImpl

Concrete fields

final val XINCLUDE_NAMESPACE: "http://www.w3.org/2001/XInclude"