Class AbstractSAXOutputProcessor
- All Implemented Interfaces:
SAXOutputProcessor
Most ContentHandler callbacks are supported. Neither
ignorableWhitespace()
nor skippedEntity()
have been
implemented.
At this time, it is not possible to access notations and unparsed entity
references in a DTD from JDOM. Therefore, full DTDHandler
call-backs have not been implemented yet.
The ErrorHandler
call-backs have not been implemented, since
these are supposed to be invoked when the document is parsed and at this
point the document exists in memory and is known to have no errors.
- Author:
- Brett McLaughlin, Jason Hunter, Fred Trimble, Bradley S. Huffman, Rolf Lear
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected XMLReader
Creates a SAX XMLReader.protected void
printCDATA
(SAXTarget out, FormatStack fstack, CDATA cdata) This will handle printing of aCDATA
.protected void
printComment
(SAXTarget out, FormatStack fstack, Comment comment) This will handle printing of aComment
.protected void
printContent
(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Walker walker) This will handle printing of a List ofContent
.protected void
printDocType
(SAXTarget out, FormatStack fstack, DocType docType) This will handle printing of aDocType
.protected void
printDocument
(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Document document) This will handle printing of aDocument
.protected void
printElement
(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Element element) This will handle printing of anElement
.protected void
printEntityRef
(SAXTarget out, FormatStack fstack, EntityRef entity) This will handle printing of anEntityRef
.protected void
printProcessingInstruction
(SAXTarget out, FormatStack fstack, ProcessingInstruction pi) This will handle printing of aProcessingInstruction
.protected void
printText
(SAXTarget out, FormatStack fstack, Text text) This will handle printing of aText
.void
This will handle printing out a list of nodes.void
Print out a
node.CDATA
void
Print out a
.Comment
void
Print out the
.DocType
void
This will print the
to the given SAXTarget.Document
void
void
Print out a
.EntityRef
void
process
(SAXTarget out, Format format, ProcessingInstruction pi) Print out a
.ProcessingInstruction
void
Print out a
node.Text
void
processAsDocument
(SAXTarget out, Format format, List<? extends Content> nodes) This will handle printing out a list of nodes that is encapsulated in start/end Document SAX events.void
processAsDocument
(SAXTarget out, Format format, Element node) Methods inherited from class org.jdom2.output.support.AbstractOutputProcessor
buildWalker
-
Constructor Details
-
AbstractSAXOutputProcessor
public AbstractSAXOutputProcessor()
-
-
Method Details
-
process
Description copied from interface:SAXOutputProcessor
This will print the
to the given SAXTarget.Document
Warning: using your own SAXTarget may cause the outputter's preferred character encoding to be ignored. If you use encodings other than UTF-8, we recommend using the method that takes an OutputStream instead.
- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output styledoc
-Document
to format.- Throws:
JDOMException
- if there is an issue encountered during output.
-
process
Description copied from interface:SAXOutputProcessor
Print out the
.DocType
- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output styledoctype
-DocType
to output.- Throws:
JDOMException
- if there is an issue encountered during output.
-
process
Description copied from interface:SAXOutputProcessor
- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output styleelement
-Element
to output.- Throws:
JDOMException
- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, List<? extends Content> list) throws JDOMException Description copied from interface:SAXOutputProcessor
This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output stylelist
-List
of nodes.- Throws:
JDOMException
- if there is an issue encountered during output.
-
process
Description copied from interface:SAXOutputProcessor
Print out a
node.CDATA
- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output stylecdata
-CDATA
to output.- Throws:
JDOMException
- if there is an issue encountered during output.
-
process
Description copied from interface:SAXOutputProcessor
Print out a
node. Performs the necessary entity escaping and whitespace stripping.Text
- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output styletext
-Text
to output.- Throws:
JDOMException
- if there is an issue encountered during output.
-
process
Description copied from interface:SAXOutputProcessor
Print out a
.Comment
- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output stylecomment
-Comment
to output.- Throws:
JDOMException
- if there is an issue encountered during output.
-
process
Description copied from interface:SAXOutputProcessor
Print out a
.ProcessingInstruction
- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output stylepi
-ProcessingInstruction
to output.- Throws:
JDOMException
- if there is an issue encountered during output.
-
process
Description copied from interface:SAXOutputProcessor
Print out a
.EntityRef
- Specified by:
process
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output styleentity
-EntityRef
to output.- Throws:
JDOMException
- if there is an issue encountered during output.
-
processAsDocument
public void processAsDocument(SAXTarget out, Format format, List<? extends Content> nodes) throws JDOMException Description copied from interface:SAXOutputProcessor
This will handle printing out a list of nodes that is encapsulated in start/end Document SAX events. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".- Specified by:
processAsDocument
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output stylenodes
-List
of nodes.- Throws:
JDOMException
- if there is an issue encountered during output.
-
processAsDocument
Description copied from interface:SAXOutputProcessor
Print out an
encapsulated in start/end Document SAX events, including itsElement
s, and all contained (child) elements, etc.Attribute
- Specified by:
processAsDocument
in interfaceSAXOutputProcessor
- Parameters:
out
-SAXTarget
to use.format
-Format
instance specifying output stylenode
-Element
to output.- Throws:
JDOMException
- if there is an issue encountered during output.
-
printDocument
protected void printDocument(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Document document) throws SAXException This will handle printing of aDocument
.- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStacknstack
- the NamespaceStackdocument
-Document
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
printDocType
This will handle printing of aDocType
.- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStackdocType
-DocType
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
printProcessingInstruction
protected void printProcessingInstruction(SAXTarget out, FormatStack fstack, ProcessingInstruction pi) throws SAXException This will handle printing of aProcessingInstruction
.- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStackpi
-ProcessingInstruction
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
printComment
This will handle printing of aComment
.- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStackcomment
-Comment
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
printEntityRef
protected void printEntityRef(SAXTarget out, FormatStack fstack, EntityRef entity) throws SAXException This will handle printing of anEntityRef
.- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStackentity
-EntotyRef
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
printCDATA
This will handle printing of aCDATA
.- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStackcdata
-CDATA
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
printText
This will handle printing of aText
.- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStacktext
-Text
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
printElement
protected void printElement(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Element element) throws SAXException This will handle printing of anElement
.This method arranges for outputting the Element infrastructure including Namespace Declarations and Attributes.
- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStacknstack
- the NamespaceStackelement
-Element
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
printContent
protected void printContent(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Walker walker) throws SAXException This will handle printing of a List ofContent
.It relies on the appropriate Walker to get the formatting right.
- Parameters:
out
-SAXTarget
to use.fstack
- the FormatStacknstack
- the NamespaceStackwalker
-Waker
ofContent
to write.- Throws:
SAXException
- if the destination SAXTarget fails
-
createParser
Creates a SAX XMLReader.
- Returns:
XMLReader
a SAX2 parser.- Throws:
Exception
- if no parser can be created.
-