Package org.jdom2.output
Class DOMOutputter
java.lang.Object
org.jdom2.output.DOMOutputter
Outputs a JDOM
org.jdom2.Document
as a DOM
org.w3c.dom.Document
. Also provides methods to
output other types of JDOM Content in the equivalent DOM nodes.
There are two versions of most functions, one that creates an independent DOM node using the DOMAdapter to create a new org.w3c.dom.Document. The other version creates the new DOM Nodes using the supplied org.w3c.dom.Document instance.
- Author:
- Brett McLaughlin, Jason Hunter, Matthew Merlo, Dan Schaffer, Yusuf Goolamabbas, Bradley S. Huffman, Rolf lear
-
Constructor Summary
ConstructorsConstructorDescriptionThis creates a new DOMOutputter which will attempt to first locate a DOM implementation to use via JAXP, and if JAXP does not exist or there's a problem, will fall back to the default parser.DOMOutputter
(String adapterClass) Deprecated.DOMOutputter
(DOMAdapter adapter) This creates a new DOMOutputter using the specified DOMAdapter implementation as a way to choose the underlying parser.DOMOutputter
(DOMAdapter adapter, Format format, DOMOutputProcessor processor) The complete constructor for specifying a custom DOMAdaptor, Format, and DOMOutputProcessor.DOMOutputter
(DOMOutputProcessor processor) This creates a new DOMOutputter which uses the default (JAXP) DOM implementation but with a custom processor. -
Method Summary
Modifier and TypeMethodDescriptionGet the DOMAdapter currently set for this DOMOutputter.Get the current DOMOutputProcessorboolean
Deprecated.All DOMOutputters are always NamesapceAware.Get the Format instance currently used by this DOMOutputter.This converts the JDOMAttribute
parameter to a DOM Attr Node, returning the DOM version.This converts the JDOMAttribute
parameter to a DOM Attr Node, returning the DOM version.This converts the JDOMCDATA
parameter to a DOM CDATASection Node, returning the DOM version.This converts the JDOMProcessingInstruction
parameter to a DOM ProcessingInstruction, returning the DOM version.This converts the JDOMDocType
parameter to a DOM DocumentType, returning the DOM version.This converts the JDOMDocument
parameter to a DOM Document, returning the DOM version.This converts the JDOMElement
parameter to a DOM Element, returning the DOM version.This converts the JDOMEntityRef
parameter to a DOM EntityReference Node, returning the DOM version.This converts the JDOMProcessingInstruction
parameter to a DOM ProcessingInstruction, returning the DOM version.This converts the JDOMText
parameter to a DOM Text Node, returning the DOM version.This converts the list of JDOMContent
in to a list of DOM Nodes, returning the DOM version.This converts the JDOMAttribute
parameter to a DOM Attr Node, returning the DOM version.This converts the JDOMCDATA
parameter to a DOM CDATASection Node, returning the DOM version.This converts the JDOMProcessingInstruction
parameter to a DOM ProcessingInstruction, returning the DOM version.This converts the JDOMElement
parameter to a DOM Element, returning the DOM version.This converts the JDOMEntityRef
parameter to a DOM EntityReference Node, returning the DOM version.output
(Document basedoc, ProcessingInstruction pi) This converts the JDOMProcessingInstruction
parameter to a DOM ProcessingInstruction, returning the DOM version.This converts the JDOMText
parameter to a DOM Text Node, returning the DOM version.void
setDOMAdapter
(DOMAdapter adapter) Set the DOMAdapter currently set for this DOMOutputter.void
setDOMOutputProcessor
(DOMOutputProcessor processor) Set a new DOMOutputProcessor for this DOMOutputter.void
setForceNamespaceAware
(boolean flag) Deprecated.All DOMOutputters are now always NamespaceAware.void
Set a new Format instance for this DOMOutputter
-
Constructor Details
-
DOMOutputter
public DOMOutputter()This creates a new DOMOutputter which will attempt to first locate a DOM implementation to use via JAXP, and if JAXP does not exist or there's a problem, will fall back to the default parser. -
DOMOutputter
This creates a new DOMOutputter which uses the default (JAXP) DOM implementation but with a custom processor.- Parameters:
processor
- the custom processor to use.- Since:
- JDOM2
-
DOMOutputter
The complete constructor for specifying a custom DOMAdaptor, Format, and DOMOutputProcessor.- Parameters:
adapter
- The adapter to use to create the base Document instance (null implies the default).format
- The output Format to use (null implies the default).processor
- The custom mechanism for doing the output (null implies the default).- Since:
- JDOM2
-
DOMOutputter
Deprecated.useDOMOutputter(DOMAdapter)
instead.This creates a new DOMOutputter using the specified DOMAdapter implementation as a way to choose the underlying parser.- Parameters:
adapterClass
-String
name of class to use for DOM output- Throws:
IllegalArgumentException
- if the adapter could not be instantiated. (it should be JDOMException, but that would require a change to this deprecated method's signature...
-
DOMOutputter
This creates a new DOMOutputter using the specified DOMAdapter implementation as a way to choose the underlying parser.If the specified adapter is not thread-safe then the user should ensure that the adapter instance is never shared between multiple DOMOutputters. The default DOMAdapter
JAXPDOMAdapter
is thread-safe.- Parameters:
adapter
- the DOMAdapter instance to use for creating the base org.w3c.dom.Document Specify the null value to get the default adapter.- Since:
- JDOM2
-
-
Method Details
-
getDOMAdapter
Get the DOMAdapter currently set for this DOMOutputter.- Returns:
- the current DOMAdapter.
- Since:
- JDOM2
-
setDOMAdapter
Set the DOMAdapter currently set for this DOMOutputter.- Parameters:
adapter
- the new DOMAdapter to use (null implies the default).- Since:
- JDOM2
-
getFormat
Get the Format instance currently used by this DOMOutputter.- Returns:
- the current Format instance
- Since:
- JDOM2
-
setFormat
Set a new Format instance for this DOMOutputter- Parameters:
format
- the new Format instance to use (null implies the default)- Since:
- JDOM2
-
getDOMOutputProcessor
Get the current DOMOutputProcessor- Returns:
- the current DOMOutputProcessor
- Since:
- JDOM2
-
setDOMOutputProcessor
Set a new DOMOutputProcessor for this DOMOutputter.- Parameters:
processor
- the new processor to set (null implies the default)- Since:
- JDOM2
-
setForceNamespaceAware
Deprecated.All DOMOutputters are now always NamespaceAware.Controls how NO_NAMESPACE nodes are handled. If true the outputter always creates a namespace aware DOM.- Parameters:
flag
- true to force NamespaceAware
-
getForceNamespaceAware
Deprecated.All DOMOutputters are always NamesapceAware. Always true.Returns whether DOMs will be constructed with namespaces even when the source document has elements all in the empty namespace.- Returns:
- the forceNamespaceAware flag value
-
output
This converts the JDOMDocument
parameter to a DOM Document, returning the DOM version. The DOM implementation is the one supplied by the current DOMAdapter.- Parameters:
document
-Document
to output.- Returns:
- an
org.w3c.dom.Document
version - Throws:
JDOMException
- if output failed.
-
output
This converts the JDOMDocType
parameter to a DOM DocumentType, returning the DOM version. The DOM implementation is the one supplied by the current DOMAdapter.Unlike the other DOM Nodes, you cannot use a DOM Document to simply create a DOM DocumentType Node, it has to be created at the same time as the DOM Document instance. As a result, there is no version of this method that takes a DOM Document instance.
- Parameters:
doctype
-DocType
to output.- Returns:
- an
org.w3c.dom.DocumentType
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMElement
parameter to a DOM Element, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
element
-Element
to output.- Returns:
- an
org.w3c.dom.Element
version - Throws:
JDOMException
- if output failed.
-
output
This converts the JDOMText
parameter to a DOM Text Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
text
-Text
to output.- Returns:
- an
org.w3c.dom.Text
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMCDATA
parameter to a DOM CDATASection Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
cdata
-CDATA
to output.- Returns:
- an
org.w3c.dom.CDATASection
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMProcessingInstruction
parameter to a DOM ProcessingInstruction, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
pi
-ProcessingInstruction
to output.- Returns:
- an
org.w3c.dom.Element
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMProcessingInstruction
parameter to a DOM ProcessingInstruction, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
comment
-Comment
to output.- Returns:
- an
org.w3c.dom.Comment
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMEntityRef
parameter to a DOM EntityReference Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
entity
-EntityRef
to output.- Returns:
- an
org.w3c.dom.EntityReference
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMAttribute
parameter to a DOM Attr Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
attribute
-Attribute
to output.- Returns:
- an
org.w3c.dom.Attr
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMAttribute
parameter to a DOM Attr Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
list
-Attribute
to output.- Returns:
- an
org.w3c.dom.Attr
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMElement
parameter to a DOM Element, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc
- The DOM Document to use for creating DOM Nodes.element
-Element
to output.- Returns:
- an
org.w3c.dom.Element
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMText
parameter to a DOM Text Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc
- The DOM Document to use for creating DOM Nodes.text
-Text
to output.- Returns:
- an
org.w3c.dom.Text
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMCDATA
parameter to a DOM CDATASection Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc
- The DOM Document to use for creating DOM Nodes.cdata
-CDATA
to output.- Returns:
- an
org.w3c.dom.CDATASection
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
public ProcessingInstruction output(Document basedoc, ProcessingInstruction pi) throws JDOMException This converts the JDOMProcessingInstruction
parameter to a DOM ProcessingInstruction, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc
- The DOM Document to use for creating DOM Nodes.pi
-ProcessingInstruction
to output.- Returns:
- an
org.w3c.dom.Element
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMProcessingInstruction
parameter to a DOM ProcessingInstruction, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc
- The DOM Document to use for creating DOM Nodes.comment
-Comment
to output.- Returns:
- an
org.w3c.dom.Comment
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMEntityRef
parameter to a DOM EntityReference Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc
- The DOM Document to use for creating DOM Nodes.entity
-EntityRef
to output.- Returns:
- an
org.w3c.dom.EntityReference
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the JDOMAttribute
parameter to a DOM Attr Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc
- The DOM Document to use for creating DOM Nodes.attribute
-Attribute
to output.- Returns:
- an
org.w3c.dom.Attr
version - Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
output
This converts the list of JDOMContent
in to a list of DOM Nodes, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc
- The DOM Document to use for creating DOM Nodes.list
- of JDOM Content to output.- Returns:
- a List of
org.w3c.dom.Node
- Throws:
JDOMException
- if output failed.- Since:
- JDOM2
-
DOMOutputter(DOMAdapter)
instead.