Top Description Constructors Methods
org.jdom2.output.support

public Class AbstractSAXOutputProcessor

extends AbstractOutputProcessor
implements SAXOutputProcessor
Class Inheritance
All Implemented Interfaces
org.jdom2.output.support.SAXOutputProcessor
Known Direct Subclasses
org.jdom2.output.SAXOutputter.DefaultSAXOutputProcessor
Static Imports
org.jdom2.JDOMConstants.*

Outputs a JDOM document as a stream of SAX2 events.

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.

The SAX2 API does not support whitespace formatting outside the root element. As a consequence any Formatting options that would normally affect the structures outside the root element will be ignored.
Authors
Brett McLaughlin, Jason Hunter, Fred Trimble, Bradley S. Huffman, Rolf Lear

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private XMLReader

Returns:

XMLReader a SAX2 parser.
createDTDParser
(SAXTarget out)

This will create a SAX XMLReader capable of parsing a DTD and configure it so that the DTD parsing events are routed to the handlers registered onto this SAXOutputter.

protected XMLReader

Returns:

XMLReader a SAX2 parser.
createParser
()

Creates a SAX XMLReader.

private static String

Returns:

String the SAX 2.0 attribute type string.
getAttributeTypeName
(AttributeType
int the type of the JDOM attribute.
type
)

Returns the SAX 2.0 attribute type string from the type of a JDOM Attribute.

private static void
protected void
printCDATA(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final CDATA
CDATA to write.
cdata
)

This will handle printing of a CDATA.

protected void
printComment(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final Comment
Comment to write.
comment
)

This will handle printing of a Comment.

protected void
printContent(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final NamespaceStack
the NamespaceStack
nstack
,
final Walker
Waker of Content to write.
walker
)

This will handle printing of a List of Content.

protected void
printDocType(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final DocType
DocType to write.
docType
)

This will handle printing of a DocType.

protected void
printDocument(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final NamespaceStack
the NamespaceStack
nstack
,
final Document
Document to write.
document
)

This will handle printing of a Document.

protected void
printElement(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final NamespaceStack
the NamespaceStack
nstack
,
final Element
Element to write.
element
)

This will handle printing of an Element.

protected void
printEntityRef(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final EntityRef
EntotyRef to write.
entity
)

This will handle printing of an EntityRef.

protected void
printProcessingInstruction(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final ProcessingInstruction
ProcessingInstruction to write.
pi
)

This will handle printing of a ProcessingInstruction.

protected void
printText(final SAXTarget
SAXTarget to use.
out
,
final FormatStack
the FormatStack
fstack
,
final Text
Text to write.
text
)

This will handle printing of a Text.

public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
Document
Document to format.
doc
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

This will print the Document to the given SAXTarget.
public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
DocType
DocType to output.
doctype
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Print out the DocType.
public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
Element
Element to output.
element
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Print out an Element, including its Attributes, and all contained (child) elements, etc.
public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
List<? extends Content>
List of nodes.
list
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

This will handle printing out a list of nodes.
public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
CDATA
CDATA to output.
cdata
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Print out a CDATA node.
public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
Text
Text to output.
text
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Print out a Text node.
public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
Comment
Comment to output.
comment
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Print out a Comment.
public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
ProcessingInstruction
ProcessingInstruction to output.
pi
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Print out a ProcessingInstruction.
public void
process(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
EntityRef
EntityRef to output.
entity
)

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Print out a EntityRef.
public void
processAsDocument(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
List<? extends Content>
List of nodes.
nodes
)

Implements org.jdom2.output.support.SAXOutputProcessor.processAsDocument.

This will handle printing out a list of nodes that is encapsulated in start/end Document SAX events.
public void
processAsDocument(SAXTarget
SAXTarget to use.
out
,
Format
Format instance specifying output style
format
,
Element
Element to output.
node
)

Implements org.jdom2.output.support.SAXOutputProcessor.processAsDocument.

Print out an Element encapsulated in start/end Document SAX events, including its Attributes, and all contained (child) elements, etc.
Inherited from org.jdom2.output.support.AbstractOutputProcessor:
buildWalker

Constructor Detail

AbstractSAXOutputProcessorback to summary
public AbstractSAXOutputProcessor()

Method Detail

createDTDParserback to summary
private XMLReader createDTDParser(SAXTarget out) throws SAXException

This will create a SAX XMLReader capable of parsing a DTD and configure it so that the DTD parsing events are routed to the handlers registered onto this SAXOutputter.

Returns:XMLReader

XMLReader a SAX2 parser.

Exceptions
JDOMException:
if no parser can be created.
createParserback to summary
protected XMLReader createParser() throws Exception

Creates a SAX XMLReader.

Returns:XMLReader

XMLReader a SAX2 parser.

Exceptions
Exception:
if no parser can be created.
getAttributeTypeNameback to summary
private static String getAttributeTypeName(AttributeType type)

Returns the SAX 2.0 attribute type string from the type of a JDOM Attribute.

Parameters
type:AttributeType

int the type of the JDOM attribute.

Returns:String

String the SAX 2.0 attribute type string.

See Also
org.jdom2.Attribute#getAttributeType, org.xml.sax.Attributes#getType
locateback to summary
private static void locate(SAXTarget out)
printCDATAback to summary
protected void printCDATA(final SAXTarget out, final FormatStack fstack, final CDATA cdata) throws SAXException

This will handle printing of a CDATA.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

cdata:CDATA

CDATA to write.

Exceptions
SAXException:
if the destination SAXTarget fails
printCommentback to summary
protected void printComment(final SAXTarget out, final FormatStack fstack, final Comment comment) throws SAXException

This will handle printing of a Comment.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

comment:Comment

Comment to write.

Exceptions
SAXException:
if the destination SAXTarget fails
printContentback to summary
protected void printContent(final SAXTarget out, final FormatStack fstack, final NamespaceStack nstack, final Walker walker) throws SAXException

This will handle printing of a List of Content.

It relies on the appropriate Walker to get the formatting right.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

nstack:NamespaceStack

the NamespaceStack

walker:Walker

Waker of Content to write.

Exceptions
SAXException:
if the destination SAXTarget fails
printDocTypeback to summary
protected void printDocType(final SAXTarget out, final FormatStack fstack, final DocType docType) throws SAXException

This will handle printing of a DocType.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

docType:DocType

DocType to write.

Exceptions
SAXException:
if the destination SAXTarget fails
printDocumentback to summary
protected void printDocument(final SAXTarget out, final FormatStack fstack, final NamespaceStack nstack, final Document document) throws SAXException

This will handle printing of a Document.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

nstack:NamespaceStack

the NamespaceStack

document:Document

Document to write.

Exceptions
SAXException:
if the destination SAXTarget fails
printElementback to summary
protected void printElement(final SAXTarget out, final FormatStack fstack, final NamespaceStack nstack, final Element element) throws SAXException

This will handle printing of an Element.

This method arranges for outputting the Element infrastructure including Namespace Declarations and Attributes.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

nstack:NamespaceStack

the NamespaceStack

element:Element

Element to write.

Exceptions
SAXException:
if the destination SAXTarget fails
printEntityRefback to summary
protected void printEntityRef(final SAXTarget out, final FormatStack fstack, final EntityRef entity) throws SAXException

This will handle printing of an EntityRef.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

entity:EntityRef

EntotyRef to write.

Exceptions
SAXException:
if the destination SAXTarget fails
printProcessingInstructionback to summary
protected void printProcessingInstruction(final SAXTarget out, final FormatStack fstack, final ProcessingInstruction pi) throws SAXException

This will handle printing of a ProcessingInstruction.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

pi:ProcessingInstruction

ProcessingInstruction to write.

Exceptions
SAXException:
if the destination SAXTarget fails
printTextback to summary
protected void printText(final SAXTarget out, final FormatStack fstack, final Text text) throws SAXException

This will handle printing of a Text.

Parameters
out:SAXTarget

SAXTarget to use.

fstack:FormatStack

the FormatStack

text:Text

Text to write.

Exceptions
SAXException:
if the destination SAXTarget fails
processback to summary
public void process(SAXTarget out, Format format, Document doc) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

This will print the Document to the given SAXTarget.

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.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

doc:Document

Document to format.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processback to summary
public void process(SAXTarget out, Format format, DocType doctype) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

Print out the DocType.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

doctype:DocType

DocType to output.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processback to summary
public void process(SAXTarget out, Format format, Element element) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

Print out an Element, including its Attributes, and all contained (child) elements, etc.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

element:Element

Element to output.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processback to summary
public void process(SAXTarget out, Format format, List<? extends Content> list) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

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>".

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

list:List<? extends Content>

List of nodes.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processback to summary
public void process(SAXTarget out, Format format, CDATA cdata) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

Print out a CDATA node.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

cdata:CDATA

CDATA to output.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processback to summary
public void process(SAXTarget out, Format format, Text text) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

Print out a Text node. Performs the necessary entity escaping and whitespace stripping.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

text:Text

Text to output.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processback to summary
public void process(SAXTarget out, Format format, Comment comment) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

Print out a Comment.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

comment:Comment

Comment to output.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processback to summary
public void process(SAXTarget out, Format format, ProcessingInstruction pi) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

Print out a ProcessingInstruction.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

pi:ProcessingInstruction

ProcessingInstruction to output.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processback to summary
public void process(SAXTarget out, Format format, EntityRef entity) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.process.

Doc from org.jdom2.output.support.SAXOutputProcessor.process.

Print out a EntityRef.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

entity:EntityRef

EntityRef to output.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processAsDocumentback to summary
public void processAsDocument(SAXTarget out, Format format, List<? extends Content> nodes) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.processAsDocument.

Doc from org.jdom2.output.support.SAXOutputProcessor.processAsDocument.

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>".

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

nodes:List<? extends Content>

List of nodes.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.
processAsDocumentback to summary
public void processAsDocument(SAXTarget out, Format format, Element node) throws JDOMException

Implements org.jdom2.output.support.SAXOutputProcessor.processAsDocument.

Doc from org.jdom2.output.support.SAXOutputProcessor.processAsDocument.

Print out an Element encapsulated in start/end Document SAX events, including its Attributes, and all contained (child) elements, etc.

Parameters
out:SAXTarget

SAXTarget to use.

format:Format

Format instance specifying output style

node:Element

Element to output.

Annotations
@Override
Exceptions
JDOMException:
if there is an issue encountered during output.