xml – DOM splitText和normalize组合应该给出身份吗?

昨天我卷入了关于DOM实现怪癖的讨论,引发了一个关于Text.splitText和Element.normalise行为以及它们应该如何表现的有趣问题.

DOM Level 1 Core中,Text.splitText被定义为……

Breaks this Text node into two Text nodes at the specified offset,keeping both in the tree as siblings. This node then only contains all the content up to the offset point. And a new Text node,which is inserted as the next sibling of this node,contains all the content at and after the offset point.

标准化是……

Puts all Text nodes in the full depth of the sub-tree underneath this Element into a “normal” form where only markup (e.g.,tags,comments,processing instructions,CDATA sections,and entity references) separates Text nodes,i.e.,there are no adjacent Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded,and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.

所以,如果我采用一个包含“Hello World”的文本节点,在textNode中引用,并且执行

textNode.splitText(3)

textNode现在具有内容“Hello”,以及包含“World”的新兄弟

如果我那么

textNode.parent.normalize()

什么是textNode?该规范没有明确表示textNode仍然是它的前一个父节点的子节点,只是更新为包含所有相邻的文本节点(然后被删除).它似乎是一个删除所有相邻文本节点的一个conforment行为,然后重新创建一个具有值的串联的新节点,使textNode指向不再是树的一部分的东西.或者,我们可以以与splitText相同的方式更新textNode,因此它保留了它的树位置,并获得了一个新值.

行为的选择实际上是完全不同的,我无法找到关于哪个是正确的澄清,或者这只是规范中的疏忽(它似乎在2级或3级似乎没有澄清).任何DOM / XML专家都可以解决这个问题吗?

我早期就在DOM工作组工作;我确信我们的意思是textNode包含新的连接值,但是如果我们没有在规范中说出来,那么某些实现可能会创建一个新节点而不是重用textNode,尽管这需要更多的工作.实现者.

如有疑问,请采取防御措施.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念
xml文件介绍及使用
xml编程(一)-xml语法
XML文件结构和基本语法
第2章 包装类
XML入门的常见问题(二)
Java对象的强、软、弱和虚引用
JS解析XML文件和XML字符串详解
java中枚举的详细使用介绍
了解Xml格式
XML入门的常见问题(四)
深入SQLite多线程的使用总结详解
PlayFramework完整实现一个APP(一)
XML和YAML的使用方法
XML轻松学习总节篇