Scala Library
|
|
class
XIncludeFilter
extends
org.xml.sax.helpers.XMLFilterImpl with
AnyRefThis 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 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 the setParent()
method of this object. ContentHandler
object to the
setContentHandler()
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'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.
parse()
methode.g.
XIncludeFilter includer = new XIncludeFilter(base);
includer.setParent(parser);
includer.setContentHandler(new SAXXIncluder(System.out));
includer.parse(args[i]);
translated from Elliotte Rusty Harold's Java sourceValue Summary | |
final val
|
XINCLUDE_NAMESPACE : java.lang.String = "http://www.w3.org/2001/XInclude" |
Method Summary | |
override def
|
characters (ch : Array[Char], start : Int, length : Int) : Unit |
override def
|
endDocument : Unit |
override def
|
endElement (uri : java.lang.String, localName : java.lang.String, qName : java.lang.String) : Unit |
override def
|
endPrefixMapping (prefix : java.lang.String) : Unit |
override def
|
ignorableWhitespace (ch : Array[Char], start : Int, length : Int) : Unit |
def
|
insideIncludeElement : Boolean |
override def
|
processingInstruction (target : java.lang.String, data : java.lang.String) : Unit |
override def
|
setDocumentLocator (locator : org.xml.sax.Locator) : Unit |
override def
|
skippedEntity (name : java.lang.String) : Unit |
override def
|
startDocument : Unit |
override def
|
startElement (uri : java.lang.String, localName : java.lang.String, qName : java.lang.String, atts1 : org.xml.sax.Attributes) : Unit |
override def
|
startPrefixMapping (prefix : java.lang.String, uri : java.lang.String) : Unit |
Methods inherited from AnyRef | |
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Value Details |
Method Details |
override
def
setDocumentLocator(locator : org.xml.sax.Locator) : Unit
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.
override
def
startElement(uri : java.lang.String, localName : java.lang.String, qName : java.lang.String, atts1 : org.xml.sax.Attributes) : Unit
override
def
endElement(uri : java.lang.String, localName : java.lang.String, qName : java.lang.String) : Unit
override
def
startDocument : Unit
override
def
endDocument : Unit
override
def
startPrefixMapping(prefix : java.lang.String, uri : java.lang.String) : Unit
override
def
endPrefixMapping(prefix : java.lang.String) : Unit
override
def
processingInstruction(target : java.lang.String, data : java.lang.String) : Unit
override
def
skippedEntity(name : java.lang.String) : Unit
Scala Library
|
|