org.xml.sax.XMLReader
public class SAXWriter
extends java.lang.Object
implements org.xml.sax.XMLReader
SAXWriter
writes a DOM4J tree to a SAX ContentHandler.
Modifier and Type | Field | Description |
---|---|---|
protected static java.lang.String |
FEATURE_NAMESPACE_PREFIXES |
|
protected static java.lang.String |
FEATURE_NAMESPACES |
|
protected static java.lang.String[] |
LEXICAL_HANDLER_NAMES |
Constructor | Description |
---|---|
SAXWriter() |
|
SAXWriter(org.xml.sax.ContentHandler contentHandler) |
|
SAXWriter(org.xml.sax.ContentHandler contentHandler,
org.xml.sax.ext.LexicalHandler lexicalHandler) |
|
SAXWriter(org.xml.sax.ContentHandler contentHandler,
org.xml.sax.ext.LexicalHandler lexicalHandler,
org.xml.sax.EntityResolver entityResolver) |
Modifier and Type | Method | Description |
---|---|---|
protected org.xml.sax.helpers.AttributesImpl |
addNamespaceAttribute(org.xml.sax.helpers.AttributesImpl attrs,
Namespace namespace) |
If isDelcareNamespaceAttributes() is enabled then this method will add
the given namespace declaration to the supplied attributes object,
creating one if it does not exist.
|
protected org.xml.sax.Attributes |
createAttributes(Element element,
org.xml.sax.Attributes namespaceAttributes) |
|
protected void |
documentLocator(Document document) |
The
Locator is only really useful when parsing a
textual document as its main purpose is to identify the line and column
number. |
protected void |
dtdHandler(Document document) |
We do not yet support DTD or XML Schemas so this method does nothing
right now.
|
protected void |
endDocument() |
|
protected void |
endElement(Element element) |
|
protected void |
endPrefixMapping(NamespaceStack stack,
int stackSize) |
Fires a SAX endPrefixMapping event for all the namespaceStack which have
gone out of scope
|
protected void |
entityResolver(Document document) |
|
org.xml.sax.ContentHandler |
getContentHandler() |
DOCUMENT ME!
|
org.xml.sax.DTDHandler |
getDTDHandler() |
DOCUMENT ME!
|
org.xml.sax.EntityResolver |
getEntityResolver() |
DOCUMENT ME!
|
org.xml.sax.ErrorHandler |
getErrorHandler() |
DOCUMENT ME!
|
boolean |
getFeature(java.lang.String name) |
Looks up the value of a feature.
|
org.xml.sax.ext.LexicalHandler |
getLexicalHandler() |
DOCUMENT ME!
|
java.lang.Object |
getProperty(java.lang.String name) |
Gets the given SAX property
|
protected void |
checkForNullHandlers() |
Ensures non-null content handlers?
|
boolean |
isDeclareNamespaceAttributes() |
Should namespace declarations be converted to "xmlns" attributes.
|
protected boolean |
isIgnoreableNamespace(Namespace namespace,
NamespaceStack namespaceStack) |
DOCUMENT ME!
|
void |
parse(java.lang.String systemId) |
This method is not supported.
|
void |
parse(org.xml.sax.InputSource input) |
Parses an XML document.
|
void |
setContentHandler(org.xml.sax.ContentHandler contentHandler) |
Sets the
ContentHandler called when SAX events are raised |
void |
setDeclareNamespaceAttributes(boolean declareNamespaceAttrs) |
Sets whether namespace declarations should be exported as "xmlns"
attributes or not.
|
void |
setDTDHandler(org.xml.sax.DTDHandler handler) |
Sets the
DTDHandler . |
void |
setEntityResolver(org.xml.sax.EntityResolver entityResolver) |
Sets the
EntityResolver . |
void |
setErrorHandler(org.xml.sax.ErrorHandler errorHandler) |
Sets the
ErrorHandler . |
void |
setFeature(java.lang.String name,
boolean value) |
This implementation does actually use any features but just stores them
for later retrieval
|
void |
setLexicalHandler(org.xml.sax.ext.LexicalHandler lexicalHandler) |
Sets the
LexicalHandler . |
void |
setProperty(java.lang.String name,
java.lang.Object value) |
Sets the given SAX property
|
void |
setXMLReader(org.xml.sax.XMLReader xmlReader) |
Sets the
XMLReader used to write SAX events to |
protected void |
startDocument() |
|
protected void |
startElement(Element element,
org.xml.sax.helpers.AttributesImpl namespaceAttributes) |
|
protected org.xml.sax.helpers.AttributesImpl |
startPrefixMapping(Element element,
NamespaceStack namespaceStack) |
Fires a SAX startPrefixMapping event for all the namespaceStack which
have just come into scope
|
void |
write(java.lang.String text) |
Generates SAX events for the given text
|
void |
write(CDATA cdata) |
Generates SAX events for the given CDATA
|
void |
write(Comment comment) |
Generates SAX events for the given Comment
|
void |
write(Document document) |
Generates SAX events for the given Document and all its content
|
void |
write(Element element) |
Generates SAX events for the given Element and all its content
|
protected void |
write(Element element,
NamespaceStack namespaceStack) |
|
void |
write(Entity entity) |
Generates SAX events for the given Entity
|
void |
write(Node node) |
A polymorphic method to write any Node to this SAX stream
|
void |
write(ProcessingInstruction pi) |
Generates SAX events for the given ProcessingInstruction
|
void |
writeClose(Element element) |
Writes the closing tag of an
Element |
protected void |
writeContent(Branch branch,
NamespaceStack namespaceStack) |
|
void |
writeOpen(Element element) |
protected static final java.lang.String[] LEXICAL_HANDLER_NAMES
protected static final java.lang.String FEATURE_NAMESPACE_PREFIXES
protected static final java.lang.String FEATURE_NAMESPACES
public SAXWriter()
public SAXWriter(org.xml.sax.ContentHandler contentHandler)
public SAXWriter(org.xml.sax.ContentHandler contentHandler, org.xml.sax.ext.LexicalHandler lexicalHandler)
public SAXWriter(org.xml.sax.ContentHandler contentHandler, org.xml.sax.ext.LexicalHandler lexicalHandler, org.xml.sax.EntityResolver entityResolver)
public void write(Node node) throws org.xml.sax.SAXException
node
- DOCUMENT ME!org.xml.sax.SAXException
- DOCUMENT ME!public void write(Document document) throws org.xml.sax.SAXException
document
- is the Document to parseorg.xml.sax.SAXException
- if there is a SAX error processing the eventspublic void write(Element element) throws org.xml.sax.SAXException
element
- is the Element to parseorg.xml.sax.SAXException
- if there is a SAX error processing the eventspublic void writeOpen(Element element) throws org.xml.sax.SAXException
element
- Element
to output.org.xml.sax.SAXException
- DOCUMENT ME!public void writeClose(Element element) throws org.xml.sax.SAXException
Writes the closing tag of an Element
element
- Element
to output.org.xml.sax.SAXException
- DOCUMENT ME!public void write(java.lang.String text) throws org.xml.sax.SAXException
text
- is the text to send to the SAX ContentHandlerorg.xml.sax.SAXException
- if there is a SAX error processing the eventspublic void write(CDATA cdata) throws org.xml.sax.SAXException
cdata
- is the CDATA to parseorg.xml.sax.SAXException
- if there is a SAX error processing the eventspublic void write(Comment comment) throws org.xml.sax.SAXException
comment
- is the Comment to parseorg.xml.sax.SAXException
- if there is a SAX error processing the eventspublic void write(Entity entity) throws org.xml.sax.SAXException
entity
- is the Entity to parseorg.xml.sax.SAXException
- if there is a SAX error processing the eventspublic void write(ProcessingInstruction pi) throws org.xml.sax.SAXException
pi
- is the ProcessingInstruction to parseorg.xml.sax.SAXException
- if there is a SAX error processing the eventspublic boolean isDeclareNamespaceAttributes()
false
as per the SAX specification.
This property is set via the SAX feature
"http://xml.org/sax/features/namespace-prefixes"public void setDeclareNamespaceAttributes(boolean declareNamespaceAttrs)
declareNamespaceAttrs
- DOCUMENT ME!public org.xml.sax.ContentHandler getContentHandler()
getContentHandler
in interface org.xml.sax.XMLReader
ContentHandler
called when SAX events are
raisedpublic void setContentHandler(org.xml.sax.ContentHandler contentHandler)
ContentHandler
called when SAX events are raisedsetContentHandler
in interface org.xml.sax.XMLReader
contentHandler
- is the ContentHandler
called when SAX events
are raisedpublic org.xml.sax.DTDHandler getDTDHandler()
getDTDHandler
in interface org.xml.sax.XMLReader
DTDHandler
public void setDTDHandler(org.xml.sax.DTDHandler handler)
DTDHandler
.setDTDHandler
in interface org.xml.sax.XMLReader
handler
- DOCUMENT ME!public org.xml.sax.ErrorHandler getErrorHandler()
getErrorHandler
in interface org.xml.sax.XMLReader
ErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
ErrorHandler
.setErrorHandler
in interface org.xml.sax.XMLReader
errorHandler
- DOCUMENT ME!public org.xml.sax.EntityResolver getEntityResolver()
getEntityResolver
in interface org.xml.sax.XMLReader
EntityResolver
used when a Document contains a
DTDpublic void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
EntityResolver
.setEntityResolver
in interface org.xml.sax.XMLReader
entityResolver
- is the EntityResolver
public org.xml.sax.ext.LexicalHandler getLexicalHandler()
LexicalHandler
used when a Document contains a
DTDpublic void setLexicalHandler(org.xml.sax.ext.LexicalHandler lexicalHandler)
LexicalHandler
.lexicalHandler
- is the LexicalHandler
public void setXMLReader(org.xml.sax.XMLReader xmlReader)
XMLReader
used to write SAX events toxmlReader
- is the XMLReader
public boolean getFeature(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
getFeature
in interface org.xml.sax.XMLReader
name
- DOCUMENT ME!org.xml.sax.SAXNotRecognizedException
- DOCUMENT ME!org.xml.sax.SAXNotSupportedException
- DOCUMENT ME!public void setFeature(java.lang.String name, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
setFeature
in interface org.xml.sax.XMLReader
name
- DOCUMENT ME!value
- DOCUMENT ME!org.xml.sax.SAXNotRecognizedException
- DOCUMENT ME!org.xml.sax.SAXNotSupportedException
- DOCUMENT ME!public void setProperty(java.lang.String name, java.lang.Object value)
setProperty
in interface org.xml.sax.XMLReader
name
- DOCUMENT ME!value
- DOCUMENT ME!public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
getProperty
in interface org.xml.sax.XMLReader
name
- DOCUMENT ME!org.xml.sax.SAXNotRecognizedException
- DOCUMENT ME!org.xml.sax.SAXNotSupportedException
- DOCUMENT ME!public void parse(java.lang.String systemId) throws org.xml.sax.SAXNotSupportedException
parse
in interface org.xml.sax.XMLReader
systemId
- DOCUMENT ME!org.xml.sax.SAXNotSupportedException
- DOCUMENT ME!public void parse(org.xml.sax.InputSource input) throws org.xml.sax.SAXException
SAXNotSupportedException
exception is thrown.parse
in interface org.xml.sax.XMLReader
input
- DOCUMENT ME!org.xml.sax.SAXException
- DOCUMENT ME!org.xml.sax.SAXNotSupportedException
- if the input source is not wrapping a dom4j documentprotected void writeContent(Branch branch, NamespaceStack namespaceStack) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void documentLocator(Document document) throws org.xml.sax.SAXException
Locator
is only really useful when parsing a
textual document as its main purpose is to identify the line and column
number. Since we are processing an in memory tree which will probably
have its line number information removed, we'll just use -1 for the line
and column numbers.document
- DOCUMENT ME!org.xml.sax.SAXException
- DOCUMENT ME!protected void entityResolver(Document document) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void dtdHandler(Document document) throws org.xml.sax.SAXException
document
- DOCUMENT ME!org.xml.sax.SAXException
- DOCUMENT ME!protected void startDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void endDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void write(Element element, NamespaceStack namespaceStack) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected org.xml.sax.helpers.AttributesImpl startPrefixMapping(Element element, NamespaceStack namespaceStack) throws org.xml.sax.SAXException
element
- DOCUMENT ME!namespaceStack
- DOCUMENT ME!org.xml.sax.SAXException
- DOCUMENT ME!protected void endPrefixMapping(NamespaceStack stack, int stackSize) throws org.xml.sax.SAXException
stack
- DOCUMENT ME!stackSize
- DOCUMENT ME!org.xml.sax.SAXException
- DOCUMENT ME!protected void startElement(Element element, org.xml.sax.helpers.AttributesImpl namespaceAttributes) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void endElement(Element element) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected org.xml.sax.Attributes createAttributes(Element element, org.xml.sax.Attributes namespaceAttributes) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected org.xml.sax.helpers.AttributesImpl addNamespaceAttribute(org.xml.sax.helpers.AttributesImpl attrs, Namespace namespace)
attrs
- DOCUMENT ME!namespace
- DOCUMENT ME!protected boolean isIgnoreableNamespace(Namespace namespace, NamespaceStack namespaceStack)
namespace
- DOCUMENT ME!namespaceStack
- DOCUMENT ME!protected void checkForNullHandlers()