| java.lang.Object gnu.xml.XMLFilter
XMLFilter | public class XMLFilter implements DocumentHandler,ContentHandler,gnu.text.SourceLocator,XConsumer,PositionConsumer(Code) | | Fixup XML input events.
Handles namespace resolution, and adds "namespace nodes" if needed.
Does various error checking.
This wrapper should be used when creating a NodeTree,
as is done for XQuery node constructor expressions.
Can also be called directly from XMLParser, in which case we use a slightly
lower-level interface where we array char array segments rather than
Strings. This is to avoid duplicate String allocation and interning.
The combination XMLParser+XMLFilter+NodeTree makes for a fast and
compact way to read an XML file into a DOM.
|
Method Summary | |
public void | beginEntity(Object baseUri) | public void | characters(char ch, int start, int length) | protected void | checkValidComment(char[] chars, int offset, int length) | protected boolean | checkWriteAtomic() | void | closeStartTag() | public void | commentFromParser(char[] chars, int start, int length) Process a comment, when called from an XML parser.
The data (starting at start for length chars).
Does not include the delimiters (i.e. | public void | consume(SeqPosition position) | public static String | duplicateAttributeMessage(Symbol attrSymbol, Object elementName) | public void | emitCharacterReference(int value, char[] name, int start, int length) Process a character entity reference.
The string encoding of the character (e.g. | public void | emitDoctypeDecl(char[] buffer, int target, int tlength, int data, int dlength) Process a DOCTYPE declaration. | public void | emitEndAttributes() Process the end of a start tag.
There are no more attributes. | public void | emitEndElement(char[] data, int start, int length) Process an end tag. | public void | emitEntityReference(char[] name, int start, int length) Process an entity reference. | public void | emitStartAttribute(char[] data, int start, int count) Process an attribute, with the given attribute name. | public void | emitStartElement(char[] data, int start, int count) Process a start tag, with the given element name. | public void | endAttribute() | public void | endDocument() | public void | endElement() | public void | endElement(String namespaceURI, String localName, String qName) | public void | endElement(String name) | public void | endEntity() | public void | endPrefixMapping(String prefix) | public void | error(char severity, String message) | public NamespaceBinding | findNamespaceBinding(String prefix, String uri, NamespaceBinding oldBindings) Functionally equivalent to
new NamespaceBinding(prefix, uri, oldBindings ,
but uses "hash consing". | public int | getColumnNumber() | public String | getFileName() | public int | getLineNumber() | public String | getPublicId() | public String | getSystemId() | public void | ignorableWhitespace(char ch, int start, int length) | public boolean | ignoring() | final boolean | inElement() | public boolean | isStableSourceLocation() | public void | linefeedFromParser() | public MappingInfo | lookupNamespaceBinding(String prefix, char[] uriChars, int uriStart, int uriLength, int uriHash, NamespaceBinding oldBindings) Return a MappingInfo containing a match namespaces. | MappingInfo | lookupTag(Symbol qname) | MappingInfo | lookupTag(char[] data, int start, int length) Look up an attribute/element tag (a QName as a lexical string
before namespace resolution), and return a MappingInfo with the
tagHash, prefix, and local fields set.
The trick is to avoid allocating a new String for each element or
attribute node we see, but only allocate a new String when we see a
tag we haven't seen. | public void | processingInstruction(String target, String data) | void | processingInstructionCommon(String target, char[] content, int offset, int length) | public void | processingInstructionFromParser(char[] buffer, int tstart, int tlength, int dstart, int dlength) Process a processing instruction. | public void | setDocumentLocator(Locator locator) | public void | setMessages(SourceMessages messages) | public void | setSourceLocator(LineBufferedReader in) | public void | setSourceLocator(SourceLocator locator) | public void | skippedEntity(String name) | public void | startAttribute(Object attrType) | public void | startDocument() | public void | startElement(Object type) | public void | startElement(String namespaceURI, String localName, String qName, Attributes atts) | public void | startElement(String name, AttributeList atts) | protected void | startElementCommon() | public void | startPrefixMapping(String prefix, String uri) | public void | textFromParser(char[] data, int start, int length) | public void | write(int v) | public void | write(char[] data, int start, int length) Process raw text. | public void | write(String str) | public void | write(CharSequence str, int start, int length) | public void | writeBoolean(boolean v) | public void | writeCDATA(char[] data, int start, int length) Process a CDATA section.
The data (starting at start for length char).
Does not include the delimiters (i.e. | public void | writeComment(char[] chars, int start, int length) Process a comment.
The data (starting at start for length chars).
Does not include the delimiters (i.e. | public void | writeDocumentUri(Object uri) | public void | writeDouble(double v) | public void | writeFloat(float v) | public void | writeInt(int v) | protected void | writeJoiner() | public void | writeLong(long v) | public void | writeObject(Object v) If v is a node, make a copy of it. | public void | writePosition(AbstractSequence seq, int ipos) | public void | writeProcessingInstruction(String target, char[] content, int offset, int length) |
COPY_NAMESPACES_INHERIT | final public static int COPY_NAMESPACES_INHERIT(Code) | | |
COPY_NAMESPACES_PRESERVE | final public static int COPY_NAMESPACES_PRESERVE(Code) | | |
attrCount | int attrCount(Code) | | The number of attributes.
Zero means we've seen an element start tag.
Gets reset to -1 when we no longer in the element header.
|
attrLocalName | String attrLocalName(Code) | | The local name if currently processing an attribute value.
|
copyNamespacesMode | public transient int copyNamespacesMode(Code) | | |
currentNamespacePrefix | String currentNamespacePrefix(Code) | | Non-null if we're processing a namespace declaration attribute.
In that case it is the prefix we're defining,
or
"" in the case of a default namespace.
|
ignoringLevel | protected int ignoringLevel(Code) | | Postive if all output should be ignored.
This happens if we're inside an attribute value inside an element which
is stringized because it is in turm inside an outer attribute. Phew.
If gets increment by nested attributes so we can tell when to stop.
|
inStartTag | boolean inStartTag(Code) | | |
mappingTable | MappingInfo[] mappingTable(Code) | | Map either lexical-QName or expanded-QName to a MappingInfo.
This is conceptually three hash tables merged into a single data structure.
(1) when we first see a tag (a QName as a lexical form before namespace
resolution), we map the tag String to an preliminary info entry that
has a null qname field.
(2) After see the namespace declaration, we use the same table and keys,
but name the uri and qtype.namespaceNodes also have to match.
(3) Used for hash-consing NamespaceBindings.
|
mappingTableMask | int mappingTableMask(Code) | | |
mismatchReported | boolean mismatchReported(Code) | | |
namespacePrefixes | public boolean namespacePrefixes(Code) | | True if namespace declarations should be passed through as attributes.
Like SAX2's http://xml.org/features/namespace-prefixes.
|
nesting | protected int nesting(Code) | | Twice the number of active startElement and startDocument calls.
|
out | public Consumer out(Code) | | The specified target Consumer that accepts the output.
In contrast, base may be either
==out or
==tlist .
|
startIndexes | int[] startIndexes(Code) | | |
stringizingElementNesting | protected int stringizingElementNesting(Code) | | Value of
nesting just before outermost startElement
while
stringizingLevel > 0 .
I.e. if we're nested inside a element nested inside an attribute
then
stringizingElementNesting >= 0 ,
otherwise
stringizingElementNesting == -1 .
|
stringizingLevel | protected int stringizingLevel(Code) | | If
stringizingLevel > 0 then stringize rather than copy nodes.
It counts the number of nested startAttributes that are active.
(In the future it should also count begun comment and
processing-instruction constructors, when those support nesting.)
|
tlist | TreeList tlist(Code) | | This is where we save attributes while processing a begin element.
It may be the final output if
out instanceof NodeTree .
|
workStack | Object[] workStack(Code) | | A helper stack.
This is logically multiple separate stacks, but we combine them into
a single array. While this makes the code a little harder to read,
it reduces memory overhead and (more importantly) should improve locality.
For each nested document or element there is the saved value of
namespaceBindings followed by a either a MappingInfo or Symbol
from the emitBeginElement/startElement. This is followed by a MappingInfo
or Symbol for each attribute we seen for the current element.
|
characters | public void characters(char ch, int start, int length) throws SAXException(Code) | | |
checkValidComment | protected void checkValidComment(char[] chars, int offset, int length)(Code) | | |
checkWriteAtomic | protected boolean checkWriteAtomic()(Code) | | |
closeStartTag | void closeStartTag()(Code) | | |
commentFromParser | public void commentFromParser(char[] chars, int start, int length)(Code) | | Process a comment, when called from an XML parser.
The data (starting at start for length chars).
Does not include the delimiters (i.e. "" are excluded).
|
emitCharacterReference | public void emitCharacterReference(int value, char[] name, int start, int length)(Code) | | Process a character entity reference.
The string encoding of the character (e.g. "xFF" or "255") is given,
as well as the character value.
|
emitDoctypeDecl | public void emitDoctypeDecl(char[] buffer, int target, int tlength, int data, int dlength)(Code) | | Process a DOCTYPE declaration.
|
emitEndAttributes | public void emitEndAttributes()(Code) | | Process the end of a start tag.
There are no more attributes.
|
emitEndElement | public void emitEndElement(char[] data, int start, int length)(Code) | | Process an end tag.
An abbreviated tag (such as
' ' ) has a name==null.
|
emitEntityReference | public void emitEntityReference(char[] name, int start, int length)(Code) | | Process an entity reference.
The entity name is given.
This handles the predefined entities, such as "<" and """.
|
emitStartAttribute | public void emitStartAttribute(char[] data, int start, int count)(Code) | | Process an attribute, with the given attribute name.
The attribute value is given using
write .
The value is terminated by either another emitStartAttribute
or an emitEndAttributes.
|
emitStartElement | public void emitStartElement(char[] data, int start, int count)(Code) | | Process a start tag, with the given element name.
|
endAttribute | public void endAttribute()(Code) | | |
endDocument | public void endDocument()(Code) | | |
endElement | public void endElement()(Code) | | |
endEntity | public void endEntity()(Code) | | |
endPrefixMapping | public void endPrefixMapping(String prefix)(Code) | | |
getColumnNumber | public int getColumnNumber()(Code) | | |
getLineNumber | public int getLineNumber()(Code) | | |
ignorableWhitespace | public void ignorableWhitespace(char ch, int start, int length) throws SAXException(Code) | | |
ignoring | public boolean ignoring()(Code) | | |
inElement | final boolean inElement()(Code) | | |
isStableSourceLocation | public boolean isStableSourceLocation()(Code) | | |
linefeedFromParser | public void linefeedFromParser()(Code) | | |
lookupNamespaceBinding | public MappingInfo lookupNamespaceBinding(String prefix, char[] uriChars, int uriStart, int uriLength, int uriHash, NamespaceBinding oldBindings)(Code) | | Return a MappingInfo containing a match namespaces.
Specifically, return a
MappingInfo info is such that
info.namespaces is equal to
new NamespaceBinding(prefix, uri, oldBindings) , where
uri is
new String(uriChars, uriStart, uriLength).intern()) .
|
lookupTag | MappingInfo lookupTag(char[] data, int start, int length)(Code) | | Look up an attribute/element tag (a QName as a lexical string
before namespace resolution), and return a MappingInfo with the
tagHash, prefix, and local fields set.
The trick is to avoid allocating a new String for each element or
attribute node we see, but only allocate a new String when we see a
tag we haven't seen. So we calculate the hash code using the
characters in the array, rather than using String's hashCode.
|
processingInstructionCommon | void processingInstructionCommon(String target, char[] content, int offset, int length)(Code) | | |
processingInstructionFromParser | public void processingInstructionFromParser(char[] buffer, int tstart, int tlength, int dstart, int dlength)(Code) | | Process a processing instruction.
|
setDocumentLocator | public void setDocumentLocator(Locator locator)(Code) | | |
startAttribute | public void startAttribute(Object attrType)(Code) | | |
startDocument | public void startDocument()(Code) | | |
startElementCommon | protected void startElementCommon()(Code) | | |
textFromParser | public void textFromParser(char[] data, int start, int length)(Code) | | |
write | public void write(int v)(Code) | | |
write | public void write(char[] data, int start, int length)(Code) | | Process raw text.
|
writeBoolean | public void writeBoolean(boolean v)(Code) | | |
writeCDATA | public void writeCDATA(char[] data, int start, int length)(Code) | | Process a CDATA section.
The data (starting at start for length char).
Does not include the delimiters (i.e.
"" are excluded).
|
writeComment | public void writeComment(char[] chars, int start, int length)(Code) | | Process a comment.
The data (starting at start for length chars).
Does not include the delimiters (i.e. "" are excluded).
|
writeDocumentUri | public void writeDocumentUri(Object uri)(Code) | | |
writeDouble | public void writeDouble(double v)(Code) | | |
writeFloat | public void writeFloat(float v)(Code) | | |
writeInt | public void writeInt(int v)(Code) | | |
writeJoiner | protected void writeJoiner()(Code) | | |
writeLong | public void writeLong(long v)(Code) | | |
writeObject | public void writeObject(Object v)(Code) | | If v is a node, make a copy of it.
|
writeProcessingInstruction | public void writeProcessingInstruction(String target, char[] content, int offset, int length)(Code) | | |
|
|