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.
characters
public void characters(ch[] ,
int start,
int length)
throws SAXException
checkValidComment
protected void checkValidComment(char[] chars,
int offset,
int length)
checkWriteAtomic
protected boolean checkWriteAtomic()
commentFromParser
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. "<!--" and "-->" are excluded).
duplicateAttributeMessage
public static String duplicateAttributeMessage(Symbol attrSymbol,
Object elementName)
emitCharacterReference
public void emitCharacterReference(int value,
char[] name,
int start,
int length)
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)
Process a DOCTYPE declaration.
emitEndAttributes
public void emitEndAttributes()
Process the end of a start tag.
There are no more attributes.
emitEndElement
public void emitEndElement(char[] data,
int start,
int length)
Process an end tag.
An abbreviated tag (such as '
'
) has a name==null.
emitEntityReference
public void emitEntityReference(char[] name,
int start,
int length)
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)
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)
Process a start tag, with the given element name.
endAttribute
public void endAttribute()
End of an attribute or end of an actual parameter.
The former use matches a startAttribute; the latter may not,
and can be used to separate parameters in a parameter list.
This double duty suggsts the method should at least be re-named.
- endAttribute in interface Consumer
endElement
public void endElement(String name)
throws SAXException
endElement
public void endElement(String namespaceURI,
String localName,
String qName)
endPrefixMapping
public void endPrefixMapping(String prefix)
error
public void error(char severity,
String message)
findNamespaceBinding
public NamespaceBinding findNamespaceBinding(String prefix,
String uri,
NamespaceBinding oldBindings)
Functionally equivalent to
new NamespaceBinding(prefix, uri, oldBindings
,
but uses "hash consing".
ignorableWhitespace
public void ignorableWhitespace(ch[] ,
int start,
int length)
throws SAXException
ignoring
public boolean ignoring()
True if consumer is ignoring rest of element.
The producer can use this information to skip ahead.
- ignoring in interface Consumer
linefeedFromParser
public void linefeedFromParser()
lookupNamespaceBinding
public gnu.xml.MappingInfo lookupNamespaceBinding(String prefix,
char[] uriChars,
int uriStart,
int uriLength,
int uriHash,
NamespaceBinding oldBindings)
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())
.
processingInstruction
public void processingInstruction(String target,
String data)
processingInstructionFromParser
public void processingInstructionFromParser(char[] buffer,
int tstart,
int tlength,
int dstart,
int dlength)
Process a processing instruction.
setDocumentLocator
public void setDocumentLocator(Locator locator)
setSourceLocator
public void setSourceLocator(SourceLocator locator)
skippedEntity
public void skippedEntity(String name)
startAttribute
public void startAttribute(Object attrType)
Write a attribute for the current element.
This is only allowed immediately after a startElement.
- startAttribute in interface Consumer
startElement
public void startElement(String name,
AttributeList atts)
startElement
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
startElementCommon
protected void startElementCommon()
startPrefixMapping
public void startPrefixMapping(String prefix,
String uri)
textFromParser
public void textFromParser(char[] data,
int start,
int length)
write
public void write(CharSequence str,
int start,
int length)
- write in interface Consumer
write
public void write(char[] data,
int start,
int length)
Process raw text.
- write in interface Consumer
writeCDATA
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. "
and "]]>"
are excluded).
- writeCDATA in interface XConsumer
writeComment
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. "<!--" and "-->" are excluded).
- writeComment in interface XConsumer
writeDocumentUri
public void writeDocumentUri(Object uri)
writeJoiner
protected void writeJoiner()
writeObject
public void writeObject(Object v)
If v is a node, make a copy of it.
- writeObject in interface Consumer