public class XMLFilter extends java.lang.Object implements org.xml.sax.DocumentHandler, org.xml.sax.ContentHandler, SourceLocator, XConsumer, PositionConsumer
SourceLocator.Simple
Modifier and Type | Field and Description |
---|---|
static int |
COPY_NAMESPACES_INHERIT |
static int |
COPY_NAMESPACES_MASK |
static int |
COPY_NAMESPACES_PRESERVE |
int |
copyNamespacesMode |
protected int |
ignoringLevel
Positive if all output should be ignored.
|
boolean |
namespacePrefixes
True if namespace declarations should be passed through as attributes.
|
protected int |
nesting
Twice the number of active startElement and startDocument calls.
|
Consumer |
out
The specified target Consumer that accepts the output.
|
protected int |
stringizingElementNesting
Value of
nesting just before outermost startElement
while stringizingLevel > 0 . |
protected int |
stringizingLevel
If
stringizingLevel > 0 then stringize rather than copy nodes. |
Modifier and Type | Method and Description |
---|---|
XMLFilter |
append(char c) |
XMLFilter |
append(java.lang.CharSequence csq) |
XMLFilter |
append(java.lang.CharSequence csq,
int start,
int end) |
void |
beginEntity(java.lang.Object baseUri) |
void |
characters(char[] ch,
int start,
int length) |
protected void |
checkValidComment(char[] chars,
int offset,
int length) |
protected boolean |
checkWriteAtomic() |
void |
commentFromParser(char[] chars,
int start,
int length)
Process a comment, when called from an XML parser.
|
static java.lang.String |
duplicateAttributeMessage(Symbol attrSymbol,
java.lang.Object elementName) |
void |
emitCharacterReference(int value,
char[] name,
int start,
int length)
Process a character entity reference.
|
void |
emitDoctypeDecl(char[] buffer,
int target,
int tlength,
int data,
int dlength)
Process a DOCTYPE declaration.
|
void |
emitEndAttributes()
Process the end of a start tag.
|
void |
emitEndElement(char[] data,
int start,
int length)
Process an end tag.
|
void |
emitEntityReference(char[] name,
int start,
int length)
Process an entity reference.
|
void |
emitStartAttribute(char[] data,
int start,
int count)
Process an attribute, with the given attribute name.
|
void |
emitStartElement(char[] data,
int start,
int count)
Process a start tag, with the given element name.
|
void |
endAttribute()
End of an attribute or end of an actual parameter.
|
void |
endDocument() |
void |
endElement() |
void |
endElement(java.lang.String name) |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName) |
void |
endEntity() |
void |
endPrefixMapping(java.lang.String prefix) |
void |
error(char severity,
java.lang.String message) |
NamespaceBinding |
findNamespaceBinding(java.lang.String prefix,
java.lang.String uri,
NamespaceBinding oldBindings)
Functionally equivalent to
new NamespaceBinding(prefix, uri, oldBindings ,
but uses "hash consing". |
int |
getColumnNumber()
Return current column number.
|
int |
getEndColumn()
Column (one-origin) of end of range; unknown/unspecified is -1.
|
int |
getEndLine()
Line number (one-origin) of end of range; unknown/unspecified is -1.
|
java.lang.String |
getFileName()
Normally same as getSystemId.
|
int |
getLineNumber()
Return current line number.
|
java.lang.String |
getPublicId() |
int |
getStartColumn()
Column (one-origin) of start of range; unknown/unspecified is -1.
|
int |
getStartLine()
Line number (one-origin) of start of range; unknown/unspecified is -1.
|
java.lang.String |
getSystemId() |
void |
ignorableWhitespace(char[] ch,
int start,
int length) |
boolean |
ignoring()
True if consumer is ignoring rest of element.
|
boolean |
isStableSourceLocation()
True if position is unlikely to change.
|
void |
linefeedFromParser() |
gnu.xml.MappingInfo |
lookupNamespaceBinding(java.lang.String prefix,
char[] uriChars,
int uriStart,
int uriLength,
int uriHash,
NamespaceBinding oldBindings)
Return a MappingInfo containing a match namespaces.
|
void |
processingInstruction(java.lang.String target,
java.lang.String data) |
void |
processingInstructionFromParser(char[] buffer,
int tstart,
int tlength,
int dstart,
int dlength)
Process a processing instruction.
|
void |
setDocumentLocator(org.xml.sax.Locator locator) |
void |
setMessages(SourceMessages messages) |
void |
setSourceLocator(gnu.kawa.io.InPort in) |
void |
setSourceLocator(SourceLocator locator) |
void |
skippedEntity(java.lang.String name) |
void |
startAttribute(java.lang.Object attrType)
Write a attribute for the current element.
|
void |
startDocument() |
void |
startElement(java.lang.Object type) |
void |
startElement(java.lang.String name,
org.xml.sax.AttributeList atts) |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts) |
protected void |
startElementCommon() |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri) |
void |
textFromParser(char[] data,
int start,
int length) |
void |
write(char[] data,
int start,
int length)
Process raw text.
|
void |
write(java.lang.CharSequence str,
int start,
int length) |
void |
write(int v) |
void |
write(java.lang.String str) |
void |
writeBoolean(boolean v) |
void |
writeCDATA(char[] data,
int start,
int length)
Process a CDATA section.
|
void |
writeComment(char[] chars,
int start,
int length)
Process a comment.
|
void |
writeDocumentUri(java.lang.Object uri) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
protected void |
writeJoiner() |
void |
writeLong(long v) |
void |
writeObject(java.lang.Object v)
If v is a node, make a copy of it.
|
void |
writePosition(AbstractSequence seq,
int ipos)
Consume a single position pair.
|
void |
writePosition(SeqPosition position)
Consume node at current position.
|
void |
writeProcessingInstruction(java.lang.String target,
char[] content,
int offset,
int length) |
public Consumer out
==out
or ==tlist
.public static final int COPY_NAMESPACES_PRESERVE
public static final int COPY_NAMESPACES_INHERIT
public transient int copyNamespacesMode
public static final int COPY_NAMESPACES_MASK
protected int nesting
protected int stringizingLevel
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.)protected int stringizingElementNesting
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
.protected int ignoringLevel
public boolean namespacePrefixes
public XMLFilter(Consumer out)
public void setSourceLocator(gnu.kawa.io.InPort in)
public void setSourceLocator(SourceLocator locator)
public void setMessages(SourceMessages messages)
public NamespaceBinding findNamespaceBinding(java.lang.String prefix, java.lang.String uri, NamespaceBinding oldBindings)
new NamespaceBinding(prefix, uri, oldBindings
,
but uses "hash consing".public gnu.xml.MappingInfo lookupNamespaceBinding(java.lang.String prefix, char[] uriChars, int uriStart, int uriLength, int uriHash, NamespaceBinding oldBindings)
MappingInfo info
is such that
info.namespaces
is equal to
new NamespaceBinding(prefix, uri, oldBindings)
, where uri
is new String(uriChars, uriStart, uriLength).intern())
.public void endAttribute()
Consumer
protected boolean checkWriteAtomic()
public void write(int v)
public void writeBoolean(boolean v)
public void writeFloat(float v)
public void writeDouble(double v)
public void writeInt(int v)
public void writeLong(long v)
public void writeDocumentUri(java.lang.Object uri)
public void writePosition(SeqPosition position)
PositionConsumer
writePosition
in interface PositionConsumer
public void writePosition(AbstractSequence seq, int ipos)
PositionConsumer
writePosition
in interface PositionConsumer
public void writeObject(java.lang.Object v)
public void write(char[] data, int start, int length)
public void write(java.lang.String str)
public void write(java.lang.CharSequence str, int start, int length)
public void linefeedFromParser()
public void textFromParser(char[] data, int start, int length)
protected void writeJoiner()
public void writeCDATA(char[] data, int start, int length)
"<![CDATA["
and "]]>"
are excluded).writeCDATA
in interface XConsumer
protected void startElementCommon()
public void emitStartElement(char[] data, int start, int count)
public void startElement(java.lang.Object type)
public void startAttribute(java.lang.Object attrType)
Consumer
public void emitStartAttribute(char[] data, int start, int count)
write
.
The value is terminated by either another emitStartAttribute
or an emitEndAttributes.public void emitEndAttributes()
public void emitEndElement(char[] data, int start, int length)
'<br/>'
) has a name==null.public void endElement()
public void emitEntityReference(char[] name, int start, int length)
public void emitCharacterReference(int value, char[] name, int start, int length)
protected void checkValidComment(char[] chars, int offset, int length)
public void writeComment(char[] chars, int start, int length)
writeComment
in interface XConsumer
public void commentFromParser(char[] chars, int start, int length)
public void writeProcessingInstruction(java.lang.String target, char[] content, int offset, int length)
writeProcessingInstruction
in interface XConsumer
public void processingInstructionFromParser(char[] buffer, int tstart, int tlength, int dstart, int dlength)
public void startDocument()
startDocument
in interface org.xml.sax.ContentHandler
startDocument
in interface org.xml.sax.DocumentHandler
public void endDocument()
endDocument
in interface org.xml.sax.ContentHandler
endDocument
in interface org.xml.sax.DocumentHandler
public void emitDoctypeDecl(char[] buffer, int target, int tlength, int data, int dlength)
public void beginEntity(java.lang.Object baseUri)
beginEntity
in interface XConsumer
public XMLFilter append(char c)
append
in interface java.lang.Appendable
public XMLFilter append(java.lang.CharSequence csq)
append
in interface java.lang.Appendable
public XMLFilter append(java.lang.CharSequence csq, int start, int end)
append
in interface java.lang.Appendable
public static java.lang.String duplicateAttributeMessage(Symbol attrSymbol, java.lang.Object elementName)
public void error(char severity, java.lang.String message)
public boolean ignoring()
Consumer
public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
setDocumentLocator
in interface org.xml.sax.DocumentHandler
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
startElement
in interface org.xml.sax.ContentHandler
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
endElement
in interface org.xml.sax.ContentHandler
public void startElement(java.lang.String name, org.xml.sax.AttributeList atts)
startElement
in interface org.xml.sax.DocumentHandler
public void endElement(java.lang.String name) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.DocumentHandler
org.xml.sax.SAXException
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
characters
in interface org.xml.sax.DocumentHandler
org.xml.sax.SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface org.xml.sax.ContentHandler
ignorableWhitespace
in interface org.xml.sax.DocumentHandler
org.xml.sax.SAXException
public void processingInstruction(java.lang.String target, java.lang.String data)
processingInstruction
in interface org.xml.sax.ContentHandler
processingInstruction
in interface org.xml.sax.DocumentHandler
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
startPrefixMapping
in interface org.xml.sax.ContentHandler
public void endPrefixMapping(java.lang.String prefix)
endPrefixMapping
in interface org.xml.sax.ContentHandler
public void skippedEntity(java.lang.String name)
skippedEntity
in interface org.xml.sax.ContentHandler
public java.lang.String getPublicId()
getPublicId
in interface javax.xml.transform.SourceLocator
getPublicId
in interface org.xml.sax.Locator
public java.lang.String getSystemId()
getSystemId
in interface javax.xml.transform.SourceLocator
getSystemId
in interface org.xml.sax.Locator
public java.lang.String getFileName()
SourceLocator
public int getLineNumber()
SourceLocator
getStartLine()
.
The "first" line is line 1; unknown is -1.getLineNumber
in interface javax.xml.transform.SourceLocator
getLineNumber
in interface org.xml.sax.Locator
public int getColumnNumber()
SourceLocator
getStartColumn()
.
The "first" column is column 1; unknown is -1.getColumnNumber
in interface javax.xml.transform.SourceLocator
getColumnNumber
in interface org.xml.sax.Locator
public int getStartLine()
SourceLocator
public int getStartColumn()
SourceLocator
public int getEndLine()
SourceLocator
public int getEndColumn()
SourceLocator
public boolean isStableSourceLocation()
SourceLocator