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 Document
convert
(Document document, DOMImplementation impl) Translates a XOMnu.xom.Document
object into an equivalentorg.w3c.dom.Document
object.static Attribute
Translates a DOMorg.w3c.dom.Attr
object into an equivalentnu.xom.Attribute
object.static Comment
Translates a DOMorg.w3c.dom.Comment
object into an equivalentnu.xom.Comment
object.static Document
Translates a DOMorg.w3c.dom.Document
object into an equivalentnu.xom.Document
object.static Nodes
convert
(DocumentFragment fragment) Translates a DOMorg.w3c.dom.DocumentFragment
object into an equivalentnu.xom.Nodes
object.static Nodes
convert
(DocumentFragment fragment, NodeFactory factory) Translates a DOMorg.w3c.dom.DocumentFragment
object into an equivalentnu.xom.Nodes
object, converting each DOM node as specified by a factory.static Document
convert
(Document domDocument, NodeFactory factory) Translates a DOMorg.w3c.dom.Document
object into an equivalentnu.xom.Document
object as controlled by a factory.static DocType
convert
(DocumentType doctype) Translates a DOMorg.w3c.dom.DocumentType
object into an equivalentnu.xom.DocType
object.static Element
Translates a DOMorg.w3c.dom.Element
object into an equivalentnu.xom.Element
object.static ProcessingInstruction
Translates a DOMorg.w3c.dom.ProcessingInstruction
object into an equivalentnu.xom.ProcessingInstruction
object.static Text
Translates a DOMorg.w3c.dom.Text
object into an equivalentnu.xom.Text
.
-
Method Details
-
convert
Translates a DOM
org.w3c.dom.Document
object into an equivalentnu.xom.Document
object. The original DOM document is not changed. Some DOMDocument
objects 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.Document
object into an equivalentnu.xom.Document
object as controlled by a factory. The original DOM document is not changed. Some DOMDocument
objects 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.DocumentFragment
object into an equivalentnu.xom.Nodes
object. The original DOM document fragment is not changed. Some DOMDocumentFragment
objects 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
Nodes
containing the converted fragment members - Throws:
XMLException
- if the DOM object is not a well-balanced XML fragment
-
convert
Translates a DOM
org.w3c.dom.DocumentFragment
object into an equivalentnu.xom.Nodes
object, converting each DOM node as specified by a factory. The original DOM document fragment is not changed. Some DOMDocumentFragment
objects 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
Nodes
containing the converted fragment members - Throws:
XMLException
- if the DOM object is not a well-balanced XML fragment
-
convert
Translates a DOM
org.w3c.dom.Comment
object into an equivalentnu.xom.Comment
object. The original DOM object is not changed. Some DOMComment
objects 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.Text
object into an equivalentnu.xom.Text
. This method will also convertorg.w3c.dom.CDATA
objects. The original DOM object is not changed. Some DOMText
objects 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.Attr
object into an equivalentnu.xom.Attribute
object. The original DOM object is not changed. Some DOMAttr
objects cannot be serialized as well-formed XML, and thus cannot be converted to XOM. Furthermore, DOM usesAttr
objects to represent namespace declarations. XOM does not. Converting anAttr
object that represents anxmlns
orxmlns:prefix
attribute will cause an exception.- Parameters:
attribute
- the DOMAttr
to translate- Returns:
- the equivalent XOM
Attribute
- Throws:
XMLException
- if the DOMAttr
is a namespace declaration or is not a well-formed XML attribute
-
convert
Translates a DOM
org.w3c.dom.ProcessingInstruction
object into an equivalentnu.xom.ProcessingInstruction
object. The original DOM object is not changed. Some DOMProcessingInstruction
objects cannot be serialized as well-formed XML, and thus cannot be converted to XOM.- Parameters:
pi
- the DOMProcessingInstruction
to convert- Returns:
- a XOM
ProcessingInstruction
- Throws:
XMLException
- if the DOMProcessingInstruction
is not a well-formed XML processing instruction
-
convert
Translates a DOM
org.w3c.dom.DocumentType
object into an equivalentnu.xom.DocType
object. The original DOM object is not changed. Some DOMDocumentType
objects cannot be serialized as well-formed XML, and thus cannot be converted to XOM.- Parameters:
doctype
- the DOMDocumentType
to convert- Returns:
- the equivalent XOM
DocType
- Throws:
XMLException
- if the DOMDocumentType
is not a well-formed XML document type declaration
-
convert
Translates a DOM
org.w3c.dom.Element
object into an equivalentnu.xom.Element
object. The original DOM object is not changed. Some DOMElement
objects cannot be serialized as namespace well-formed XML, and thus cannot be converted to XOM.- Parameters:
element
- the DOMElement
to convert- Returns:
- the equivalent XOM
Element
- Throws:
XMLException
- if the DOMElement
is not a well-formed XML element
-
convert
Translates a XOM
nu.xom.Document
object into an equivalentorg.w3c.dom.Document
object. 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
-