Package org.jdom2.input
Class DOMBuilder
java.lang.Object
org.jdom2.input.DOMBuilder
Builds a JDOM Document from a pre-existing DOM
org.w3c.dom.Document
.
If you are building a document that has Namespace declarations, you should ensure that the Namespaces are correctly recorded in the DOM document before building the JDOM document from the DOM. By default, the native Java DOMBuilderFactory is configured to ignore Namespaces, and thus they are 'lost' in the DOM tree. JDOM expects Namespace-aware documents, so you should ensure that you change the default settings on the DOMBuilderFactory before parsing the DOM document. For example:
DocumentBuilderFactory domfactory = DocumentBuilderFactory.newInstance(); domfactory.setNamespaceAware(true); DocumentBuilder dombuilder = domfac.newDocumentBuilder(); org.w3c.dom.Document doc = dombuilder.parse(....);
- Author:
- Brett McLaughlin, Jason Hunter, Philip Nelson, Kevin Regan, Yusuf Goolamabbas, Dan Schaffer, Bradley S. Huffman
-
Constructor Summary
ConstructorsConstructorDescriptionThis creates a new DOMBuilder instance using the DefaultJDOMFactory to build the JDOM content. -
Method Summary
Modifier and TypeMethodDescriptionbuild
(CDATASection cdata) This will build a JDOM CDATA from an existing DOM CDATASectionThis will build a JDOM Comment from an existing DOM CommentThis will build a JDOM tree from an existing DOM tree.build
(DocumentType doctype) This will build a JDOM Element from an existing DOM ElementThis will build a JDOM Element from an existing DOM Elementbuild
(EntityReference er) This will build a JDOM EntityRef from an existing DOM EntityReferenceThis will build a JDOM ProcessingInstruction from an existing DOM ProcessingInstructionThis will build a JDOM Text from an existing DOM TextReturns the currentJDOMFactory
in use.void
setFactory
(JDOMFactory factory) This sets a custom JDOMFactory for the builder.
-
Constructor Details
-
DOMBuilder
public DOMBuilder()This creates a new DOMBuilder instance using the DefaultJDOMFactory to build the JDOM content.
-
-
Method Details
-
setFactory
This sets a custom JDOMFactory for the builder. Use this to build the tree with your own subclasses of the JDOM classes.- Parameters:
factory
-JDOMFactory
to use
-
getFactory
Returns the currentJDOMFactory
in use.- Returns:
- the factory in use
-
build
This will build a JDOM tree from an existing DOM tree.- Parameters:
domDocument
-org.w3c.dom.Document
object- Returns:
Document
- JDOM document object.
-
build
This will build a JDOM Element from an existing DOM Element- Parameters:
domElement
-org.w3c.dom.Element
object- Returns:
Element
- JDOM Element object
-
build
This will build a JDOM CDATA from an existing DOM CDATASection- Parameters:
cdata
-org.w3c.dom.CDATASection
object- Returns:
CDATA
- JDOM CDATA object- Since:
- JDOM2
-
build
This will build a JDOM Text from an existing DOM Text- Parameters:
text
-org.w3c.dom.Text
object- Returns:
Text
- JDOM Text object- Since:
- JDOM2
-
build
This will build a JDOM Comment from an existing DOM Comment- Parameters:
comment
-org.w3c.dom.Comment
object- Returns:
Comment
- JDOM Comment object- Since:
- JDOM2
-
build
This will build a JDOM ProcessingInstruction from an existing DOM ProcessingInstruction- Parameters:
pi
-org.w3c.dom.ProcessingInstruction
object- Returns:
ProcessingInstruction
- JDOM ProcessingInstruction object- Since:
- JDOM2
-
build
This will build a JDOM EntityRef from an existing DOM EntityReference- Parameters:
er
-org.w3c.dom.EntityReference
object- Returns:
EnityRef
- JDOM EntityRef object- Since:
- JDOM2
-
build
This will build a JDOM Element from an existing DOM Element- Parameters:
doctype
-org.w3c.dom.Element
object- Returns:
Element
- JDOM Element object- Since:
- JDOM2
-