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 currentJDOMFactoryin use.voidsetFactory(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-JDOMFactoryto use
-
getFactory
-
build
-
build
-
build
This will build a JDOM CDATA from an existing DOM CDATASection- Parameters:
cdata-org.w3c.dom.CDATASectionobject- Returns:
CDATA- JDOM CDATA object- Since:
- JDOM2
-
build
-
build
-
build
This will build a JDOM ProcessingInstruction from an existing DOM ProcessingInstruction- Parameters:
pi-org.w3c.dom.ProcessingInstructionobject- Returns:
ProcessingInstruction- JDOM ProcessingInstruction object- Since:
- JDOM2
-
build
This will build a JDOM EntityRef from an existing DOM EntityReference- Parameters:
er-org.w3c.dom.EntityReferenceobject- Returns:
EnityRef- JDOM EntityRef object- Since:
- JDOM2
-
build
This will build a JDOM Element from an existing DOM Element- Parameters:
doctype-org.w3c.dom.Elementobject- Returns:
Element- JDOM Element object- Since:
- JDOM2
-