Class DOMConverter
Converts XOM Document objects to and from DOM
Document objects. This class can also
convert many DOM node objects into the corresponding
XOM node objects. However, the reverse is not possible because
DOM objects cannot live outside their containing
Document.
- Version:
- 1.2d1
- Author:
- Elliotte Rusty Harold
-
Method Summary
Modifier and TypeMethodDescriptionstatic Documentconvert(Document document, DOMImplementation impl) Translates a XOMnu.xom.Documentobject into an equivalentorg.w3c.dom.Documentobject.static AttributeTranslates a DOMorg.w3c.dom.Attrobject into an equivalentnu.xom.Attributeobject.static CommentTranslates a DOMorg.w3c.dom.Commentobject into an equivalentnu.xom.Commentobject.static DocumentTranslates a DOMorg.w3c.dom.Documentobject into an equivalentnu.xom.Documentobject.static Nodesconvert(DocumentFragment fragment) Translates a DOMorg.w3c.dom.DocumentFragmentobject into an equivalentnu.xom.Nodesobject.static Nodesconvert(DocumentFragment fragment, NodeFactory factory) Translates a DOMorg.w3c.dom.DocumentFragmentobject into an equivalentnu.xom.Nodesobject, converting each DOM node as specified by a factory.static Documentconvert(Document domDocument, NodeFactory factory) Translates a DOMorg.w3c.dom.Documentobject into an equivalentnu.xom.Documentobject as controlled by a factory.static DocTypeconvert(DocumentType doctype) Translates a DOMorg.w3c.dom.DocumentTypeobject into an equivalentnu.xom.DocTypeobject.static ElementTranslates a DOMorg.w3c.dom.Elementobject into an equivalentnu.xom.Elementobject.static ProcessingInstructionTranslates a DOMorg.w3c.dom.ProcessingInstructionobject into an equivalentnu.xom.ProcessingInstructionobject.static TextTranslates a DOMorg.w3c.dom.Textobject into an equivalentnu.xom.Text.
-
Method Details
-
convert
Translates a DOM
org.w3c.dom.Documentobject into an equivalentnu.xom.Documentobject. The original DOM document is not changed. Some DOMDocumentobjects cannot be serialized as namespace well-formed XML, and thus cannot be converted to XOM.- Parameters:
domDocument- the DOM document to translate- Returns:
- a XOM document
- Throws:
XMLException- if the DOM document is not a well-formed XML document
-
convert
Translates a DOM
org.w3c.dom.Documentobject into an equivalentnu.xom.Documentobject as controlled by a factory. The original DOM document is not changed. Some DOMDocumentobjects cannot be serialized as namespace well-formed XML, and thus cannot be converted to XOM.- Parameters:
domDocument- the DOM document to translatefactory- the factory that converts each DOM node into zero or more XOM nodes- Returns:
- a XOM document
- Throws:
XMLException- if the DOM document is not a well-formed XML document
-
convert
Translates a DOM
org.w3c.dom.DocumentFragmentobject into an equivalentnu.xom.Nodesobject. The original DOM document fragment is not changed. Some DOMDocumentFragmentobjects cannot be serialized as namespace well-balanced XML, and thus cannot be converted to XOM.- Parameters:
fragment- the DOM document fragment to translate- Returns:
- a
Nodescontaining the converted fragment members - Throws:
XMLException- if the DOM object is not a well-balanced XML fragment
-
convert
Translates a DOM
org.w3c.dom.DocumentFragmentobject into an equivalentnu.xom.Nodesobject, converting each DOM node as specified by a factory. The original DOM document fragment is not changed. Some DOMDocumentFragmentobjects cannot be serialized as namespace well-balanced XML, and thus cannot be converted to XOM.- Parameters:
fragment- the DOM document fragment to translatefactory- the NodeFactory that converts each DOM node into a XOM node- Returns:
- a
Nodescontaining the converted fragment members - Throws:
XMLException- if the DOM object is not a well-balanced XML fragment
-
convert
Translates a DOM
org.w3c.dom.Commentobject into an equivalentnu.xom.Commentobject. The original DOM object is not changed. Some DOMCommentobjects cannot be serialized as well-formed XML, and thus cannot be converted to XOM.- Parameters:
comment- the DOM comment to translate- Returns:
- a XOM comment
- Throws:
XMLException- if the DOM comment is not a well-formed XML comment
-
convert
Translates a DOM
org.w3c.dom.Textobject into an equivalentnu.xom.Text. This method will also convertorg.w3c.dom.CDATAobjects. The original DOM object is not changed. Some DOMTextobjects cannot be serialized as well-formed XML, and thus cannot be converted to XOM.- Parameters:
text- the DOM text to translate- Returns:
- a XOM text
- Throws:
XMLException- if the DOM text is not a well-formed XML text
-
convert
Translates a DOM
org.w3c.dom.Attrobject into an equivalentnu.xom.Attributeobject. The original DOM object is not changed. Some DOMAttrobjects cannot be serialized as well-formed XML, and thus cannot be converted to XOM. Furthermore, DOM usesAttrobjects to represent namespace declarations. XOM does not. Converting anAttrobject that represents anxmlnsorxmlns:prefixattribute will cause an exception.- Parameters:
attribute- the DOMAttrto translate- Returns:
- the equivalent XOM
Attribute - Throws:
XMLException- if the DOMAttris a namespace declaration or is not a well-formed XML attribute
-
convert
Translates a DOM
org.w3c.dom.ProcessingInstructionobject into an equivalentnu.xom.ProcessingInstructionobject. The original DOM object is not changed. Some DOMProcessingInstructionobjects cannot be serialized as well-formed XML, and thus cannot be converted to XOM.- Parameters:
pi- the DOMProcessingInstructionto convert- Returns:
- a XOM
ProcessingInstruction - Throws:
XMLException- if the DOMProcessingInstructionis not a well-formed XML processing instruction
-
convert
Translates a DOM
org.w3c.dom.DocumentTypeobject into an equivalentnu.xom.DocTypeobject. The original DOM object is not changed. Some DOMDocumentTypeobjects cannot be serialized as well-formed XML, and thus cannot be converted to XOM.- Parameters:
doctype- the DOMDocumentTypeto convert- Returns:
- the equivalent XOM
DocType - Throws:
XMLException- if the DOMDocumentTypeis not a well-formed XML document type declaration
-
convert
Translates a DOM
org.w3c.dom.Elementobject into an equivalentnu.xom.Elementobject. The original DOM object is not changed. Some DOMElementobjects cannot be serialized as namespace well-formed XML, and thus cannot be converted to XOM.- Parameters:
element- the DOMElementto convert- Returns:
- the equivalent XOM
Element - Throws:
XMLException- if the DOMElementis not a well-formed XML element
-
convert
Translates a XOM
nu.xom.Documentobject into an equivalentorg.w3c.dom.Documentobject. The original XOM document is not changed. Since DOM2 internal subsets are read-only, the internal DTD subset is not converted. All other aspects of the document should be translated without a problem.- Parameters:
document- the XOM document to translateimpl- the specific DOM implementation into which this document will be converted- Returns:
- a DOM document
-