XDM和DOM模型之间有什么区别? [英] What's the difference between XDM and DOM models?

查看:107
本文介绍了XDM和DOM模型之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须描述这些模型之间的差异。我知道类型和用途上还有其他区别吗?

I must describe differences between those models. I know there is difference in types and purpose anything else?

推荐答案

迈克尔·凯(Michael Kay)已经对数据做了很好的总结,水平差异;我会尽力为您提供一些设计上的差异。

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.

在最基本的层次上,XDM建模项目序列,而DOM建模节点的层次结构。这种区别会影响其设计的其他各个方面,从可以表示什么数据到如何访问和操纵数据。例如,在XQuery(甚至是多个文档)中同时处理文档的不同部分的节点非常简单,而DOM则要困难得多。

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.

DOMString DOMTimeStamp DOMUserData DOMObject ) 。 XDM具有广泛且可扩展的类型系统,包括从 xs:unsignedByte s到 xs:language 标识符到所有标识符的类型类似于DOM的属性 s,并且需要使用它的任何语言来完全理解这种类型的系统。另一方面,DOM类型系统的范围仅限于指定其API所必需的范围(主要是 Node 的各种扩展),并试图做到与语言无关

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:unsignedBytes to xs:language identifiers to DOM-like attributes, 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.

第三,DOM是一种读/写数据模型,由使用和操作它的API定义。 XDM是一个只读模型,在很大程度上以更抽象的术语定义了表达式的允许值,并使用最少的API来描述节点数据访问器。由于这些不同的方法,XDM非常适合用于功能性编程语言,而DOM被设计用于命令式语言。另外,XDM本身并不能真正有用。需要其他语言层(例如XPath / XQuery函数和运算符规范)才能实际访问和操作数据。相比之下,DOM API是处理DOM数据所需的全部。

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.

这篇关于XDM和DOM模型之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆