Top Description Fields Constructors Methods
org.jdom.output

public Class SAXOutputter

extends Object
Class Inheritance
Known Direct Subclasses
org.jdom.transform.JDOMSource.DocumentReader
Imports
java.io.*, java.lang.reflect.*, java.util.*, org.jdom.*, org.xml.sax.*, org.xml.sax.ext.*, org.xml.sax.helpers.*

Outputs a JDOM document as a stream of SAX2 events.

Most ContentHandler callbacks are supported. Both ignorableWhitespace() and skippedEntity() have not been implemented. The JDOMLocator class returned by getLocator exposes the current node being operated upon.

At this time, it is not possible to access notations and unparsed entity references in a DTD from JDOM. Therefore, DTDHandler callbacks have not been implemented yet.

The ErrorHandler callbacks 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.

Authors
Brett McLaughlin, Jason Hunter, Fred Trimble, Bradley S. Huffman
Version
$Revision: 1.40 $, $Date: 2007/11/10 05:29:01 $

Field Summary

Modifier and TypeField and Description
private static final String[]
attrTypeToNameMap

Array to map JDOM attribute type (as entry index) to SAX attribute type names.

private ContentHandler
contentHandler

registered ContentHandler

private static final String
private static final String
DECL_HANDLER_ALT_PROPERTY

Shortcut for SAX-ext.

private static final String
DECL_HANDLER_SAX_PROPERTY

Shortcut for SAX-ext.

private boolean
declareNamespaces

Whether to report attribute namespace declarations as xmlns attributes.

private DeclHandler
declHandler

registered DeclHandler

private DTDHandler
dtdHandler

registered DTDHandler

private EntityResolver
entityResolver

registered EntityResolver

private ErrorHandler
errorHandler

registered ErrorHandler

private static final String
LEXICAL_HANDLER_ALT_PROPERTY

Shortcut for SAX-ext.

private static final String
LEXICAL_HANDLER_SAX_PROPERTY

Shortcut for SAX-ext.

private LexicalHandler
lexicalHandler

registered LexicalHandler

private JDOMLocator
locator

A SAX Locator that points at the JDOM node currently being outputted.

private static final String
NAMESPACES_SAX_FEATURE

Shortcut for SAX namespaces core feature

private static final String
NS_PREFIXES_SAX_FEATURE

Shortcut for SAX namespace-prefixes core feature

private boolean
reportDtdEvents

Whether to report DTD events to DeclHandlers and LexicalHandlers.

private static final String
VALIDATION_SAX_FEATURE

Shortcut for SAX validation core feature

Constructor Summary

AccessConstructor and Description
public
SAXOutputter()

This will create a SAXOutputter without any registered handler.

public
SAXOutputter(ContentHandler
contains ContentHandler callback methods
contentHandler
)

This will create a SAXOutputter with the specified ContentHandler.

public
SAXOutputter(ContentHandler
contains ContentHandler callback methods
contentHandler
,
ErrorHandler
contains ErrorHandler callback methods
errorHandler
,
DTDHandler
contains DTDHandler callback methods
dtdHandler
,
EntityResolver
contains EntityResolver callback methods
entityResolver
)

This will create a SAXOutputter with the specified SAX2 handlers.

public
SAXOutputter(ContentHandler
contains ContentHandler callback methods
contentHandler
,
ErrorHandler
contains ErrorHandler callback methods
errorHandler
,
DTDHandler
contains DTDHandler callback methods
dtdHandler
,
EntityResolver
contains EntityResolver callback methods
entityResolver
,
LexicalHandler
contains LexicalHandler callbacks.
lexicalHandler
)

This will create a SAXOutputter with the specified SAX2 handlers.

Method Summary

Modifier and TypeMethod and Description
private AttributesImpl

Returns:

AttributeImpl the updated attribute list.
addNsAttribute
(AttributesImpl
AttributeImpl where to add the attribute.
atts
,
Namespace
Namespace the namespace to declare.
ns
)

Appends a namespace declaration in the form of a xmlns attribute to an attribute list, crerating this latter if needed.

private void
cdata(String
all text in the CDATA section, including whitespace.
cdataText
)

This will be called for each chunk of CDATA section encountered.

private void
characters(String
all text in an element, including whitespace.
elementText
)

This will be called for each chunk of character data encountered.

private void
comment(String
all text in a comment, including whitespace.
commentText
)

This will be called for each chunk of comment data encontered.

private XMLReader

Returns:

XMLReader a SAX2 parser.
createDTDParser
()

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 void
documentLocator(Document
JDOM Document.
document
)

This method tells you the line of the XML file being parsed.

private void
dtdEvents(Document
JDOM Document the DocType is to process.
document
)

This parses a DTD declaration to fire the related events towards the registered handlers.

private void
element(Element
Element used in callbacks.
element
,
NamespaceStack
List stack of Namespaces in scope.
namespaces
)

This will recursively invoke all of the callbacks for a particular element.

private void
elementContent(List<E>
element content as a List of nodes.
content
,
NamespaceStack
List stack of Namespaces in scope.
namespaces
)

This will invoke the callbacks for the content of an element.

private void
elementContent(Content
a Content node.
node
,
NamespaceStack
List stack of Namespaces in scope.
namespaces
)

This will invoke the callbacks for the content of an element.

private void
endDocument()

Always the last method of all callbacks in all handlers to be invoked.

private void
endElement(Element
Element used in callbacks.
element
)

This will invoke the endElement callback in the ContentHandler.

private void
endPrefixMapping(NamespaceStack
List stack of Namespaces in scope.
namespaces
,
int
number of previously declared namespaces
previouslyDeclaredNamespaces
)

This will invoke the endPrefixMapping callback in the ContentHandler when a namespace is goes out of scope in the Document.

private void
entityRef(EntityRef
EntityRef.
entity
)

This will invoke the ContentHandler.skippedEntity callback when an entity reference is encountered.

private static String

Returns:

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

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

public ContentHandler

Returns:

the current ContentHandler or null if none was registered.
getContentHandler
()

Returns the registered ContentHandler.

public DeclHandler

Returns:

the current DeclHandler or null if none was registered.
getDeclHandler
()

Return the registered DeclHandler.

public DTDHandler

Returns:

the current DTDHandler or null if none was registered.
getDTDHandler
()

Return the registered DTDHandler.

public EntityResolver

Returns:

the current EntityResolver or null if none was registered.
getEntityResolver
()

Return the registered EntityResolver.

public ErrorHandler

Returns:

the current ErrorHandler or null if none was registered.
getErrorHandler
()

Return the registered ErrorHandler.

public boolean

Returns:

boolean the current state of the feature (true or false).
getFeature
(String
String the feature name, which is a fully-qualified URI.
name
)

This will look up the value of a SAX feature.

public LexicalHandler

Returns:

the current LexicalHandler or null if none was registered.
getLexicalHandler
()

Return the registered LexicalHandler.

public JDOMLocator

Returns:

a JDOMLocator object referencing the node currently being processed or null if no output operation is being performed.
getLocator
()

Returns a JDOMLocator object referencing the node currently being processed by this outputter.

public Object

Returns:

Object the current value of the property.
getProperty
(String
String the property name, which is a fully-qualified URI.
name
)

This will look up the value of a SAX property.

public boolean

Returns:

whether DTD events will be reported
getReportDTDEvents
()

Returns whether DTD events will be reported.

public boolean

Returns:

whether attribute namespace declarations shall be reported as "xmlns" attributes.
getReportNamespaceDeclarations
()

Returns whether attribute namespace declarations shall be reported as "xmlns" attributes.

private void
handleError(JDOMException
JDOMException containing the error information; will be wrapped in a SAXParseException when reported to the SAX error handler.
exception
)

Notifies the registered SAX error handler (if any) of an input processing error.

public void
output(Document
JDOM Document to output.
document
)

This will output the JDOM Document, firing off the SAX events that have been registered.

public void
output(List<E>
List of JDOM nodes to output.
nodes
)

This will output a list of JDOM nodes as a document, firing off the SAX events that have been registered.

public void
output(Element
the Element node to output.
node
)

This will output a single JDOM element as a document, firing off the SAX events that have been registered.

public void
outputFragment(List<E>
List of JDOM nodes to output.
nodes
)

This will output a list of JDOM nodes as a fragment of an XML document, firing off the SAX events that have been registered.

public void
outputFragment(Content
the Content node to output.
node
)

This will output a single JDOM nodes as a fragment of an XML document, firing off the SAX events that have been registered.

private void
processingInstruction(ProcessingInstruction
ProcessingInstruction containing target and data.
pi
)

This will invoke the ContentHandler.processingInstruction callback when a processing instruction is encountered.

public void
setContentHandler(ContentHandler
contains ContentHandler callback methods.
contentHandler
)

This will set the ContentHandler.

public void
setDeclHandler(DeclHandler
contains declaration callback methods.
declHandler
)

This will set the DeclHandler.

public void
setDTDHandler(DTDHandler
contains DTDHandler callback methods.
dtdHandler
)

This will set the DTDHandler.

public void
setEntityResolver(EntityResolver
contains EntityResolver callback methods.
entityResolver
)

This will set the EntityResolver.

public void
setErrorHandler(ErrorHandler
contains ErrorHandler callback methods.
errorHandler
)

This will set the ErrorHandler.

public void
setFeature(String
String the feature name, which is a fully-qualified URI.
name
,
boolean
boolean the requested state of the feature (true or false).
value
)

This will set the state of a SAX feature.

public void
setLexicalHandler(LexicalHandler
contains lexical callback methods.
lexicalHandler
)

This will set the LexicalHandler.

public void
setProperty(String
String the property name, which is a fully-qualified URI.
name
,
Object
Object the requested value for the property.
value
)

This will set the value of a SAX property.

public void
setReportDTDEvents(boolean
whether to notify DTD events.
reportDtdEvents
)

This will define whether to report DTD events to SAX DeclHandlers and LexicalHandlers if these handlers are registered and the document to output includes a DocType declaration.

public void
setReportNamespaceDeclarations(boolean
whether attribute namespace declarations shall be reported as "xmlns" attributes.
declareNamespaces
)

This will define whether attribute namespace declarations shall be reported as "xmlns" attributes.

private void
startDocument()

This method is always the second method of all callbacks in all handlers to be invoked (setDocumentLocator is always first).

private void
startElement(Element
Element used in callbacks.
element
,
Attributes
List of namespaces to declare with the element or null.
nsAtts
)

This will invoke the startElement callback in the ContentHandler.

private Attributes

Returns:

Attributes declaring the namespaces local to element or null.
startPrefixMapping
(Element
Element used in callbacks.
element
,
NamespaceStack
List stack of Namespaces in scope.
namespaces
)

This will invoke the ContentHandler.startPrefixMapping callback when a new namespace is encountered in the Document.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attrTypeToNameMapback to summary
private static final String[] attrTypeToNameMap

Array to map JDOM attribute type (as entry index) to SAX attribute type names.

contentHandlerback to summary
private ContentHandler contentHandler

registered ContentHandler

CVS_IDback to summary
private static final String CVS_ID
DECL_HANDLER_ALT_PROPERTYback to summary
private static final String DECL_HANDLER_ALT_PROPERTY

Shortcut for SAX-ext. declaration handler alternate property

DECL_HANDLER_SAX_PROPERTYback to summary
private static final String DECL_HANDLER_SAX_PROPERTY

Shortcut for SAX-ext. declaration handler property

declareNamespacesback to summary
private boolean declareNamespaces

Whether to report attribute namespace declarations as xmlns attributes. Defaults to false as per SAX specifications.

See Also
SAX namespace specifications
declHandlerback to summary
private DeclHandler declHandler

registered DeclHandler

dtdHandlerback to summary
private DTDHandler dtdHandler

registered DTDHandler

entityResolverback to summary
private EntityResolver entityResolver

registered EntityResolver

errorHandlerback to summary
private ErrorHandler errorHandler

registered ErrorHandler

LEXICAL_HANDLER_ALT_PROPERTYback to summary
private static final String LEXICAL_HANDLER_ALT_PROPERTY

Shortcut for SAX-ext. lexical handler alternate property. Although this property URI is not the one defined by the SAX "standard", some parsers use it instead of the official one.

LEXICAL_HANDLER_SAX_PROPERTYback to summary
private static final String LEXICAL_HANDLER_SAX_PROPERTY

Shortcut for SAX-ext. lexical handler property

lexicalHandlerback to summary
private LexicalHandler lexicalHandler

registered LexicalHandler

locatorback to summary
private JDOMLocator locator

A SAX Locator that points at the JDOM node currently being outputted.

NAMESPACES_SAX_FEATUREback to summary
private static final String NAMESPACES_SAX_FEATURE

Shortcut for SAX namespaces core feature

NS_PREFIXES_SAX_FEATUREback to summary
private static final String NS_PREFIXES_SAX_FEATURE

Shortcut for SAX namespace-prefixes core feature

reportDtdEventsback to summary
private boolean reportDtdEvents

Whether to report DTD events to DeclHandlers and LexicalHandlers. Defaults to true.

VALIDATION_SAX_FEATUREback to summary
private static final String VALIDATION_SAX_FEATURE

Shortcut for SAX validation core feature

Constructor Detail

SAXOutputterback to summary
public SAXOutputter()

This will create a SAXOutputter without any registered handler. The application is then responsible for registering them using the setXxxHandler() methods.

SAXOutputterback to summary
public SAXOutputter(ContentHandler contentHandler)

This will create a SAXOutputter with the specified ContentHandler.

Parameters
contentHandler:ContentHandler

contains ContentHandler callback methods

SAXOutputterback to summary
public SAXOutputter(ContentHandler contentHandler, ErrorHandler errorHandler, DTDHandler dtdHandler, EntityResolver entityResolver)

This will create a SAXOutputter with the specified SAX2 handlers. At this time, only ContentHandler and EntityResolver are supported.

Parameters
contentHandler:ContentHandler

contains ContentHandler callback methods

errorHandler:ErrorHandler

contains ErrorHandler callback methods

dtdHandler:DTDHandler

contains DTDHandler callback methods

entityResolver:EntityResolver

contains EntityResolver callback methods

SAXOutputterback to summary
public SAXOutputter(ContentHandler contentHandler, ErrorHandler errorHandler, DTDHandler dtdHandler, EntityResolver entityResolver, LexicalHandler lexicalHandler)

This will create a SAXOutputter with the specified SAX2 handlers. At this time, only ContentHandler and EntityResolver are supported.

Parameters
contentHandler:ContentHandler

contains ContentHandler callback methods

errorHandler:ErrorHandler

contains ErrorHandler callback methods

dtdHandler:DTDHandler

contains DTDHandler callback methods

entityResolver:EntityResolver

contains EntityResolver callback methods

lexicalHandler:LexicalHandler

contains LexicalHandler callbacks.

Method Detail

addNsAttributeback to summary
private AttributesImpl addNsAttribute(AttributesImpl atts, Namespace ns)

Appends a namespace declaration in the form of a xmlns attribute to an attribute list, crerating this latter if needed.

Parameters
atts:AttributesImpl

AttributeImpl where to add the attribute.

ns:Namespace

Namespace the namespace to declare.

Returns:AttributesImpl

AttributeImpl the updated attribute list.

cdataback to summary
private void cdata(String cdataText) throws JDOMException

This will be called for each chunk of CDATA section encountered.

Parameters
cdataText:String

all text in the CDATA section, including whitespace.

charactersback to summary
private void characters(String elementText) throws JDOMException

This will be called for each chunk of character data encountered.

Parameters
elementText:String

all text in an element, including whitespace.

commentback to summary
private void comment(String commentText) throws JDOMException

This will be called for each chunk of comment data encontered.

Parameters
commentText:String

all text in a comment, including whitespace.

createDTDParserback to summary
private XMLReader createDTDParser() throws JDOMException

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.
documentLocatorback to summary
private void documentLocator(Document document)

This method tells you the line of the XML file being parsed. For an in-memory document, it's meaningless. The location is only valid for the current parsing lifecycle, but the document has already been parsed. Therefore, it returns -1 for both line and column numbers.

Parameters
document:Document

JDOM Document.

dtdEventsback to summary
private void dtdEvents(Document document) throws JDOMException

This parses a DTD declaration to fire the related events towards the registered handlers.

Parameters
document:Document

JDOM Document the DocType is to process.

elementback to summary
private void element(Element element, NamespaceStack namespaces) throws JDOMException

This will recursively invoke all of the callbacks for a particular element.

Parameters
element:Element

Element used in callbacks.

namespaces:NamespaceStack

List stack of Namespaces in scope.

elementContentback to summary
private void elementContent(List<E> content, NamespaceStack namespaces) throws JDOMException

This will invoke the callbacks for the content of an element.

Parameters
content:List<E>

element content as a List of nodes.

namespaces:NamespaceStack

List stack of Namespaces in scope.

elementContentback to summary
private void elementContent(Content node, NamespaceStack namespaces) throws JDOMException

This will invoke the callbacks for the content of an element.

Parameters
node:Content

a Content node.

namespaces:NamespaceStack

List stack of Namespaces in scope.

endDocumentback to summary
private void endDocument() throws JDOMException

Always the last method of all callbacks in all handlers to be invoked.

endElementback to summary
private void endElement(Element element) throws JDOMException

This will invoke the endElement callback in the ContentHandler.

Parameters
element:Element

Element used in callbacks.

endPrefixMappingback to summary
private void endPrefixMapping(NamespaceStack namespaces, int previouslyDeclaredNamespaces) throws JDOMException

This will invoke the endPrefixMapping callback in the ContentHandler when a namespace is goes out of scope in the Document.

Parameters
namespaces:NamespaceStack

List stack of Namespaces in scope.

previouslyDeclaredNamespaces:int

number of previously declared namespaces

entityRefback to summary
private void entityRef(EntityRef entity) throws JDOMException

This will invoke the ContentHandler.skippedEntity callback when an entity reference is encountered.

Parameters
entity:EntityRef

EntityRef.

getAttributeTypeNameback to summary
private static String getAttributeTypeName(int type)

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

Parameters
type:int

int the type of the JDOM attribute.

Returns:String

String the SAX 2.0 attribute type string.

See Also
org.jdom.Attribute#getAttributeType, org.xml.sax.Attributes#getType
getContentHandlerback to summary
public ContentHandler getContentHandler()

Returns the registered ContentHandler.

Returns:ContentHandler

the current ContentHandler or null if none was registered.

getDeclHandlerback to summary
public DeclHandler getDeclHandler()

Return the registered DeclHandler.

Returns:DeclHandler

the current DeclHandler or null if none was registered.

getDTDHandlerback to summary
public DTDHandler getDTDHandler()

Return the registered DTDHandler.

Returns:DTDHandler

the current DTDHandler or null if none was registered.

getEntityResolverback to summary
public EntityResolver getEntityResolver()

Return the registered EntityResolver.

Returns:EntityResolver

the current EntityResolver or null if none was registered.

getErrorHandlerback to summary
public ErrorHandler getErrorHandler()

Return the registered ErrorHandler.

Returns:ErrorHandler

the current ErrorHandler or null if none was registered.

getFeatureback to summary
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException

This will look up the value of a SAX feature.

Parameters
name:String

String the feature name, which is a fully-qualified URI.

Returns:boolean

boolean the current state of the feature (true or false).

Exceptions
SAXNotRecognizedException:
when SAXOutputter does not recognize the feature name.
SAXNotSupportedException:
when SAXOutputter recognizes the feature name but determine its value at this time.
getLexicalHandlerback to summary
public LexicalHandler getLexicalHandler()

Return the registered LexicalHandler.

Returns:LexicalHandler

the current LexicalHandler or null if none was registered.

getLocatorback to summary
public JDOMLocator getLocator()

Returns a JDOMLocator object referencing the node currently being processed by this outputter. The returned object is a snapshot of the location information and can thus safely be memorized for later use.

This method allows direct access to the location information maintained by SAXOutputter without requiring to implement XMLFilter. (In SAX, locators are only available though the ContentHandler interface).

Note that location information is only available while SAXOutputter is outputting nodes. Hence this method should only be used by objects taking part in the output processing such as ErrorHandlers.

Returns:JDOMLocator

a JDOMLocator object referencing the node currently being processed or null if no output operation is being performed.

getPropertyback to summary
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException

This will look up the value of a SAX property.

Parameters
name:String

String the property name, which is a fully-qualified URI.

Returns:Object

Object the current value of the property.

Exceptions
SAXNotRecognizedException:
when SAXOutputter does not recognize the property name.
SAXNotSupportedException:
when SAXOutputter recognizes the property name but cannot determine its value at this time.
getReportDTDEventsback to summary
public boolean getReportDTDEvents()

Returns whether DTD events will be reported.

Returns:boolean

whether DTD events will be reported

getReportNamespaceDeclarationsback to summary
public boolean getReportNamespaceDeclarations()

Returns whether attribute namespace declarations shall be reported as "xmlns" attributes.

Returns:boolean

whether attribute namespace declarations shall be reported as "xmlns" attributes.

handleErrorback to summary
private void handleError(JDOMException exception) throws JDOMException

Notifies the registered SAX error handler (if any) of an input processing error. The error handler can choose to absorb the error and let the processing continue.

Parameters
exception:JDOMException

JDOMException containing the error information; will be wrapped in a SAXParseException when reported to the SAX error handler.

Exceptions
JDOMException:
if no error handler has been registered or if the error handler fired a SAXException.
outputback to summary
public void output(Document document) throws JDOMException

This will output the JDOM Document, firing off the SAX events that have been registered.

Parameters
document:Document

JDOM Document to output.

Exceptions
JDOMException:
if any error occurred.
outputback to summary
public void output(List<E> nodes) throws JDOMException

This will output a list of JDOM nodes as a document, firing off the SAX events that have been registered.

Warning

This method may output ill-formed XML documents if the list contains top-level objects that are not legal at the document level (e.g. Text or CDATA nodes, multiple Element nodes, etc.). Thus, it should only be used to output document portions towards ContentHandlers capable of accepting such ill-formed documents (such as XSLT processors).

Parameters
nodes:List<E>

List of JDOM nodes to output.

Exceptions
JDOMException:
if any error occurred.
See Also
output(org.jdom.Document)
outputback to summary
public void output(Element node) throws JDOMException

This will output a single JDOM element as a document, firing off the SAX events that have been registered.

Parameters
node:Element

the Element node to output.

Exceptions
JDOMException:
if any error occurred.
outputFragmentback to summary
public void outputFragment(List<E> nodes) throws JDOMException

This will output a list of JDOM nodes as a fragment of an XML document, firing off the SAX events that have been registered.

Warning

This method does not call the ContentHandler#setDocumentLocator, ContentHandler#startDocument and ContentHandler#endDocument callbacks on the ContentHandler. The user shall invoke these methods directly prior/after outputting the document fragments.

Parameters
nodes:List<E>

List of JDOM nodes to output.

Exceptions
JDOMException:
if any error occurred.
See Also
outputFragment(org.jdom.Content)
outputFragmentback to summary
public void outputFragment(Content node) throws JDOMException

This will output a single JDOM nodes as a fragment of an XML document, firing off the SAX events that have been registered.

Warning

This method does not call the ContentHandler#setDocumentLocator, ContentHandler#startDocument and ContentHandler#endDocument callbacks on the ContentHandler. The user shall invoke these methods directly prior/after outputting the document fragments.

Parameters
node:Content

the Content node to output.

Exceptions
JDOMException:
if any error occurred.
See Also
outputFragment(java.util.List)
processingInstructionback to summary
private void processingInstruction(ProcessingInstruction pi) throws JDOMException

This will invoke the ContentHandler.processingInstruction callback when a processing instruction is encountered.

Parameters
pi:ProcessingInstruction

ProcessingInstruction containing target and data.

setContentHandlerback to summary
public void setContentHandler(ContentHandler contentHandler)

This will set the ContentHandler.

Parameters
contentHandler:ContentHandler

contains ContentHandler callback methods.

setDeclHandlerback to summary
public void setDeclHandler(DeclHandler declHandler)

This will set the DeclHandler.

Parameters
declHandler:DeclHandler

contains declaration callback methods.

setDTDHandlerback to summary
public void setDTDHandler(DTDHandler dtdHandler)

This will set the DTDHandler.

Parameters
dtdHandler:DTDHandler

contains DTDHandler callback methods.

setEntityResolverback to summary
public void setEntityResolver(EntityResolver entityResolver)

This will set the EntityResolver.

Parameters
entityResolver:EntityResolver

contains EntityResolver callback methods.

setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler errorHandler)

This will set the ErrorHandler.

Parameters
errorHandler:ErrorHandler

contains ErrorHandler callback methods.

setFeatureback to summary
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException

This will set the state of a SAX feature.

All XMLReaders are required to support setting to true and to false.

SAXOutputter currently supports the following SAX core features:

http://xml.org/sax/features/namespaces
description: true indicates namespace URIs and unprefixed local names for element and attribute names will be available
access: read/write, but always true!
http://xml.org/sax/features/namespace-prefixes
description: true indicates XML 1.0 names (with prefixes) and attributes (including xmlns* attributes) will be available
access: read/write
http://xml.org/sax/features/validation
description: controls whether SAXOutputter is reporting DTD-related events; if true, the DocType internal subset will be parsed to fire DTD events
access: read/write, defaults to true

Parameters
name:String

String the feature name, which is a fully-qualified URI.

value:boolean

boolean the requested state of the feature (true or false).

Exceptions
SAXNotRecognizedException:
when SAXOutputter does not recognize the feature name.
SAXNotSupportedException:
when SAXOutputter recognizes the feature name but cannot set the requested value.
setLexicalHandlerback to summary
public void setLexicalHandler(LexicalHandler lexicalHandler)

This will set the LexicalHandler.

Parameters
lexicalHandler:LexicalHandler

contains lexical callback methods.

setPropertyback to summary
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException

This will set the value of a SAX property. This method is also the standard mechanism for setting extended handlers.

SAXOutputter currently supports the following SAX properties:

http://xml.org/sax/properties/lexical-handler
data type: org.xml.sax.ext.LexicalHandler
description: An optional extension handler for lexical events like comments.
access: read/write
http://xml.org/sax/properties/declaration-handler
data type: org.xml.sax.ext.DeclHandler
description: An optional extension handler for DTD-related events other than notations and unparsed entities.
access: read/write

Parameters
name:String

String the property name, which is a fully-qualified URI.

value:Object

Object the requested value for the property.

Exceptions
SAXNotRecognizedException:
when SAXOutputter does not recognize the property name.
SAXNotSupportedException:
when SAXOutputter recognizes the property name but cannot set the requested value.
setReportDTDEventsback to summary
public void setReportDTDEvents(boolean reportDtdEvents)

This will define whether to report DTD events to SAX DeclHandlers and LexicalHandlers if these handlers are registered and the document to output includes a DocType declaration.

Parameters
reportDtdEvents:boolean

whether to notify DTD events.

setReportNamespaceDeclarationsback to summary
public void setReportNamespaceDeclarations(boolean declareNamespaces)

This will define whether attribute namespace declarations shall be reported as "xmlns" attributes. This flag defaults to false and behaves as the "namespace-prefixes" SAX core feature.

Parameters
declareNamespaces:boolean

whether attribute namespace declarations shall be reported as "xmlns" attributes.

startDocumentback to summary
private void startDocument() throws JDOMException

This method is always the second method of all callbacks in all handlers to be invoked (setDocumentLocator is always first).

startElementback to summary
private void startElement(Element element, Attributes nsAtts) throws JDOMException

This will invoke the startElement callback in the ContentHandler.

Parameters
element:Element

Element used in callbacks.

nsAtts:Attributes

List of namespaces to declare with the element or null.

startPrefixMappingback to summary
private Attributes startPrefixMapping(Element element, NamespaceStack namespaces) throws JDOMException

This will invoke the ContentHandler.startPrefixMapping callback when a new namespace is encountered in the Document.

Parameters
element:Element

Element used in callbacks.

namespaces:NamespaceStack

List stack of Namespaces in scope.

Returns:Attributes

Attributes declaring the namespaces local to element or null.