I must describe differences between those models. I know there is difference in types and purpose anything else?
3 Answers
Michael Kay has already given a pretty good summary of the data-level differences; I'll try to give you some of the design-level differences in my answer.
At the most fundamental level, XDM models a "sequence of items", whereas DOM models a "hierarchy of nodes." This distinction affects every other aspect of their design, from what data can be represented, to how it is accessed and manipulated. For example, it is quite simple to work with nodes from disparate parts of a document simultaneously in XQuery (or even multiple documents), whereas the DOM makes this much more difficult.
Secondly, the type systems used by these two models have very different goals and approaches. Each object in an XDM instance has a single "type annotation", whereas each object in a DOM either implements one or more interfaces or is an instance of a "basic type" (one of DOMString
, DOMTimeStamp
, DOMUserData
, or DOMObject
). XDM has a broad and extensible type system, including types for everything from xs:unsignedByte
s to xs:language
identifiers to DOM-like attribute
s, and requires any language that uses it to fully understand this type system. The DOM type system on the other hand is limited in scope to what is absolutely necessary to specify its API (mostly various extensions of Node
), and attempts to be as language-neutral as possible.
Thirdly, the DOM is a read/write data model that is defined by the API with which it is used and manipulated. The XDM is a read-only model that is defined largely in more abstract terms about "permissible values of expressions," with a minimal API to describe node data accessors. Because of these differing approaches, XDM is well suited for use in functional programming languages while DOM is designed for use in imperative languages. Also, XDM isn't really usable for much on its own; additional language layers (eg the XPath/XQuery Functions and Operators spec) are needed to actually access and manipulate the data. In contrast, the DOM API is all that's needed to work with DOM data.

- 357
- 1
- 6
Main differences: DOM retains some things that XDM doesn't retain, such as DOCTYPE, CDATA sections, entities and entity references; DOM allows trees to be constructed programatically that don't satisfy all the constraints of well-formed XML (e.g. nodes with invalid names); DOM treats namespaces as attributes not as a separate kind of node, and allows namespace inconsistencies; DOM allows adjacent text nodes.

- 156,231
- 11
- 92
- 164
I would like to highlight the read-only vs read-write difference between XDM and DOM. While DOM was designed to "manipulate" documents (just as modern JavaScripts creates and modifies the elements shown in a browser), XDM is designed to "transform" data in the sense of creating new documents from existing ones (which are not modified).
XDM is therefore much better suited for many kinds of data transformation whether based on XPath, XSLT, XQuery, or something similar, which translate an original into a new form or extract data from a given set of documents. The latter work is very common in many kinds of "backend" data processing (like exchanging data between different systems, each having its own XML format) or "big data" processing (like aggregation and other analysis).
As an ironic twist of history while Java and the JVM often serve as the language and platform to do systems integration with lots of XML transformation and it would therefore make sense to have a standard XDM in Java, the opposite is unfortunately true: the JDK comes with interfaces for the DOM (org.w3c.dom.*) and even specifies XPath on top of the DOM although XDM would be much better suited for that! See "XPath.evaluate performance slows down absurdly" for an example where this leads to trouble. Also the Java DOM has a lot of methods which are not thread-safe (because everything is so mutable). Because of its immutability, XDM is better suited to parallel processing of data.
In case you're wondering how to get XDM in Java, I'll quickly mention JSR 255 which specifies it as part of the XQuery proposal which seems to be used mostly for XML databases, and there is Saxon which is (as of 2018) the most active XPath and XSLT processor in the Java world.

- 10,333
- 1
- 21
- 29