Network Working Group J. Urpalainen Request for Comments: 5261 Nokia Category: Standards Track September 2008
Network Working Group J. Urpalainen Request for Comments: 5261 Nokia Category: Standards Track September 2008
An Extensible Markup Language (XML) Patch Operations Framework Utilizing XML Path Language (XPath) Selectors
利用XML路径语言(XPath)选择器的可扩展标记语言(XML)修补程序操作框架
Status of This Memo
关于下段备忘
This document specifies an Internet standards track protocol for the Internet community, and requests discussion and suggestions for improvements. Please refer to the current edition of the "Internet Official Protocol Standards" (STD 1) for the standardization state and status of this protocol. Distribution of this memo is unlimited.
本文件规定了互联网社区的互联网标准跟踪协议,并要求进行讨论和提出改进建议。有关本协议的标准化状态和状态,请参考当前版本的“互联网官方协议标准”(STD 1)。本备忘录的分发不受限制。
Abstract
摘要
Extensible Markup Language (XML) documents are widely used as containers for the exchange and storage of arbitrary data in today's systems. In order to send changes to an XML document, an entire copy of the new version must be sent, unless there is a means of indicating only the portions that have changed. This document describes an XML patch framework utilizing XML Path language (XPath) selectors. These selector values and updated new data content constitute the basis of patch operations described in this document. In addition to them, with basic <add>, <replace>, and <remove> directives a set of patches can then be applied to update an existing XML document.
在当今的系统中,可扩展标记语言(XML)文档被广泛用作交换和存储任意数据的容器。为了向XML文档发送更改,必须发送新版本的完整副本,除非有一种方法仅指示已更改的部分。本文档描述了一个使用XML路径语言(XPath)选择器的XML修补程序框架。这些选择器值和更新的新数据内容构成本文档中描述的修补程序操作的基础。除此之外,使用基本的<add>、<replace>和<remove>指令,还可以应用一组补丁来更新现有的XML文档。
Table of Contents
目录
1. Introduction ....................................................3 2. Conventions .....................................................3 3. Basic Features and Requirements .................................4 4. Patch Operations ................................................5 4.1. Locating the Target of a Patch .............................6 4.2. Namespace Mangling .........................................6 4.2.1. Namespaces Used in Selectors ........................7 4.2.2. Departures from XPath Requirements ..................7 4.2.3. Namespaces and Added/Changed Content ................8 4.3. <add> Element .............................................10 4.3.1. Adding an Element ..................................11 4.3.2. Adding an Attribute ................................11 4.3.3. Adding a Prefixed Namespace Declaration ............12 4.3.4. Adding Node(s) with the 'pos' Attribute ............12 4.3.5. Adding Multiple Nodes ..............................12 4.4. <replace> Element .........................................13
1. Introduction ....................................................3 2. Conventions .....................................................3 3. Basic Features and Requirements .................................4 4. Patch Operations ................................................5 4.1. Locating the Target of a Patch .............................6 4.2. Namespace Mangling .........................................6 4.2.1. Namespaces Used in Selectors ........................7 4.2.2. Departures from XPath Requirements ..................7 4.2.3. Namespaces and Added/Changed Content ................8 4.3. <add> Element .............................................10 4.3.1. Adding an Element ..................................11 4.3.2. Adding an Attribute ................................11 4.3.3. Adding a Prefixed Namespace Declaration ............12 4.3.4. Adding Node(s) with the 'pos' Attribute ............12 4.3.5. Adding Multiple Nodes ..............................12 4.4. <replace> Element .........................................13
4.4.1. Replacing an Element ...............................14 4.4.2. Replacing an Attribute Value .......................14 4.4.3. Replacing a Namespace Declaration URI ..............14 4.4.4. Replacing a Comment Node ...........................14 4.4.5. Replacing a Processing Instruction Node ............15 4.4.6. Replacing a Text Node ..............................15 4.5. <remove> Element ..........................................15 4.5.1. Removing an Element ................................15 4.5.2. Removing an Attribute ..............................16 4.5.3. Removing a Prefixed Namespace Declaration ..........16 4.5.4. Removing a Comment Node ............................16 4.5.5. Removing a Processing Instruction Node .............16 4.5.6. Removing a Text Node ...............................16 5. Error Handling .................................................17 5.1. Error Elements ............................................17 6. Usage of Patch Operations ......................................19 7. Usage of Selector Values .......................................19 8. XML Schema Types of Patch Operation Elements ...................19 9. XML Schema of Patch Operation Errors ...........................21 10. IANA Considerations ...........................................23 10.1. URN Sub-Namespace Registration ...........................23 10.2. application/patch-ops-error+xml MIME Type ................24 10.3. Patch-Ops-Types XML Schema Registration ..................25 10.4. Patch-Ops-Error XML Schema Registration ..................25 11. Security Considerations .......................................26 12. Acknowledgments ...............................................26 13. References ....................................................26 13.1. Normative References .....................................26 13.2. Informative References ...................................28 Appendix A. Informative Examples .................................29 A.1. Adding an Element .........................................29 A.2. Adding an Attribute .......................................29 A.3. Adding a Prefixed Namespace Declaration ...................30 A.4. Adding a Comment Node with the 'pos' Attribute ............30 A.5. Adding Multiple Nodes .....................................31 A.6. Replacing an Element ......................................31 A.7. Replacing an Attribute Value ..............................32 A.8. Replacing a Namespace Declaration URI .....................32 A.9. Replacing a Comment Node ..................................33 A.10. Replacing a Processing Instruction Node ...................33 A.11. Replacing a Text Node .....................................34 A.12. Removing an Element .......................................34 A.13. Removing an Attribute .....................................35 A.14. Removing a Prefixed Namespace Declaration .................35 A.15. Removing a Comment Node ...................................36 A.16. Removing a Processing Instruction Node ....................36 A.17. Removing a Text Node ......................................37 A.18. Several Patches With Namespace Mangling ...................38
4.4.1. Replacing an Element ...............................14 4.4.2. Replacing an Attribute Value .......................14 4.4.3. Replacing a Namespace Declaration URI ..............14 4.4.4. Replacing a Comment Node ...........................14 4.4.5. Replacing a Processing Instruction Node ............15 4.4.6. Replacing a Text Node ..............................15 4.5. <remove> Element ..........................................15 4.5.1. Removing an Element ................................15 4.5.2. Removing an Attribute ..............................16 4.5.3. Removing a Prefixed Namespace Declaration ..........16 4.5.4. Removing a Comment Node ............................16 4.5.5. Removing a Processing Instruction Node .............16 4.5.6. Removing a Text Node ...............................16 5. Error Handling .................................................17 5.1. Error Elements ............................................17 6. Usage of Patch Operations ......................................19 7. Usage of Selector Values .......................................19 8. XML Schema Types of Patch Operation Elements ...................19 9. XML Schema of Patch Operation Errors ...........................21 10. IANA Considerations ...........................................23 10.1. URN Sub-Namespace Registration ...........................23 10.2. application/patch-ops-error+xml MIME Type ................24 10.3. Patch-Ops-Types XML Schema Registration ..................25 10.4. Patch-Ops-Error XML Schema Registration ..................25 11. Security Considerations .......................................26 12. Acknowledgments ...............................................26 13. References ....................................................26 13.1. Normative References .....................................26 13.2. Informative References ...................................28 Appendix A. Informative Examples .................................29 A.1. Adding an Element .........................................29 A.2. Adding an Attribute .......................................29 A.3. Adding a Prefixed Namespace Declaration ...................30 A.4. Adding a Comment Node with the 'pos' Attribute ............30 A.5. Adding Multiple Nodes .....................................31 A.6. Replacing an Element ......................................31 A.7. Replacing an Attribute Value ..............................32 A.8. Replacing a Namespace Declaration URI .....................32 A.9. Replacing a Comment Node ..................................33 A.10. Replacing a Processing Instruction Node ...................33 A.11. Replacing a Text Node .....................................34 A.12. Removing an Element .......................................34 A.13. Removing an Attribute .....................................35 A.14. Removing a Prefixed Namespace Declaration .................35 A.15. Removing a Comment Node ...................................36 A.16. Removing a Processing Instruction Node ....................36 A.17. Removing a Text Node ......................................37 A.18. Several Patches With Namespace Mangling ...................38
Extensible Markup Language (XML) [W3C.REC-xml-20060816] documents are widely used as containers for the exchange and storage of arbitrary data in today's systems. In order to send changes to an XML document, an entire copy of the new version must be sent, unless there is a means of indicating only the portions that have changed (patches).
可扩展标记语言(XML)[W3C.REC-XML-20060816]文档被广泛用作当今系统中任意数据交换和存储的容器。为了向XML文档发送更改,必须发送新版本的完整副本,除非有方法仅指示已更改的部分(补丁)。
This document describes an XML patch framework that utilizes XML Path language (XPath) [W3C.REC-xpath-19991116] selectors. An XPath selector is used to pinpoint the specific portion of the XML that is the target for the change. These selector values and updated new data content constitute the basis of patch operations described in this document. In addition to them, with basic <add>, <replace>, and <remove> directives a set of patches can be applied to update an existing target XML document. With these patch operations, a simple semantics for data oriented XML documents [W3C.REC-xmlschema-2-20041028] is achieved, that is, modifications like additions, removals, or substitutions of elements and attributes can easily be performed. This document does not describe a full XML diff format, only basic patch operation elements that can be embedded within a full format that typically has additional semantics.
本文档描述了一个利用XML路径语言(XPath)[W3C.REC-XPath-19991116]选择器的XML修补程序框架。XPath选择器用于精确定位XML中作为更改目标的特定部分。这些选择器值和更新的新数据内容构成本文档中描述的修补程序操作的基础。除此之外,通过基本的<add>、<replace>和<remove>指令,可以应用一组补丁来更新现有的目标XML文档。通过这些补丁操作,实现了面向数据的XML文档[W3C.REC-xmlschema-2-20041028]的简单语义,即可以轻松执行元素和属性的添加、删除或替换等修改。本文档不描述完整的XML diff格式,只描述可以嵌入到通常具有附加语义的完整格式中的基本补丁操作元素。
As one concrete example, in the Session Initiation Protocol (SIP) [RFC3903] based presence system a partial PIDF XML document format [RFC5262] consists of the existing Presence Information Data Format (PIDF) document format combined with the patch operations elements described in this document. In general, patch operations can be used in any application that exchanges XML documents, for example, within the SIP Events framework [RFC3265]. Yet another example is XCAP-diff [SIMPLE-XCAP], which uses this framework for sending partial updates of changes to XCAP [RFC4825] resources.
As one concrete example, in the Session Initiation Protocol (SIP) [RFC3903] based presence system a partial PIDF XML document format [RFC5262] consists of the existing Presence Information Data Format (PIDF) document format combined with the patch operations elements described in this document. In general, patch operations can be used in any application that exchanges XML documents, for example, within the SIP Events framework [RFC3265]. Yet another example is XCAP-diff [SIMPLE-XCAP], which uses this framework for sending partial updates of changes to XCAP [RFC4825] resources.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119, BCP 14 [RFC2119] and indicate requirement levels for compliant implementations.
本文件中的关键词“必须”、“不得”、“要求”、“应”、“不应”、“应”、“不应”、“建议”、“可”和“可选”应按照RFC 2119、BCP 14[RFC2119]中的描述进行解释,并指出合规实施的要求级别。
The following terms are used in this document:
本文件中使用了以下术语:
Target XML document: A target XML document that is going to be updated with a set of patches.
目标XML文档:将使用一组修补程序更新的目标XML文档。
XML diff document: An XML document that contains patch operation elements, namespace declarations, and all the document content changes that are needed in order to transform a target XML document into a new patched XML document.
XML diff document:一个XML文档,包含补丁操作元素、名称空间声明以及将目标XML文档转换为新的补丁XML文档所需的所有文档内容更改。
Patched XML document: An XML document that results after applying one or more patch operations defined in the XML diff document to the target XML document.
修补XML文档:将XML diff文档中定义的一个或多个修补操作应用于目标XML文档后生成的XML文档。
Patch operation: A single change, i.e., a patch that is being applied to update a target XML document.
修补程序操作:单个更改,即应用于更新目标XML文档的修补程序。
Patch operation element: An XML element that represents a single patch operation.
补丁操作元素:表示单个补丁操作的XML元素。
Type definition for an element: A World Wide Web Consortium (W3C) Schema type definition for an element that describes a patch operation content.
元素的类型定义:描述修补程序操作内容的元素的万维网联盟(W3C)架构类型定义。
In-scope namespace declaration: A list of all in-scope namespace declarations within a context node. The QName (qualified name) expansion of a context node is based on mapping a prefix with one of these declarations. For an element, one namespace binding may have an empty prefix.
范围内命名空间声明:上下文节点内所有范围内命名空间声明的列表。上下文节点的QName(限定名)扩展基于将前缀映射到这些声明之一。对于一个元素,一个命名空间绑定可能有一个空前缀。
Positional constraint: A number enclosed with square brackets. It can be used as a location step predicate.
位置约束:用方括号括起来的数字。它可以用作位置步骤谓词。
Located target node: A node that was found from the target XML document with the aid of an XPath selector value.
定位目标节点:借助XPath选择器值从目标XML文档中找到的节点。
White space text node: A text node that contains only white space.
空白文本节点:仅包含空白的文本节点。
In this framework, XPath selector values and new data content are embedded within XML elements, the names of which specify the modification to be performed: <add>, <replace>, or <remove>. These elements (patch operations) are defined by schema types with the W3C Schema language [W3C.REC-xmlschema-1-20041028]. XPath selectors pinpoint the target for a change and they are expressed as attributes of these elements. The child node(s) of patch operation elements contain the new data content. In general when applicable, the new content SHOULD be moved unaltered to the patched XML document.
在此框架中,XPath选择器值和新数据内容嵌入到XML元素中,这些元素的名称指定要执行的修改:<add>、<replace>或<remove>。这些元素(补丁操作)由W3C模式语言[W3C.REC-xmlschema-1-20041028]的模式类型定义。XPath选择器精确定位更改的目标,并将其表示为这些元素的属性。修补程序操作元素的子节点包含新的数据内容。通常,在适用的情况下,应将新内容原封不动地移动到经过修补的XML文档中。
XML documents that are equivalent for the purposes of many applications MAY differ in their physical representation. The aim of this document is to describe a deterministic framework where the
对于许多应用程序来说是等效的XML文档,其物理表示形式可能有所不同。本文档的目的是描述一个确定性框架,其中
canonical form with comments [W3C.REC-xml-c14n-20010315] of an XML document determines logical equivalence. For example, white space text nodes MUST be processed properly in order to fulfill this requirement as white space is by default significant [W3C.REC-xml-c14n-20010315].
xml文档的带有注释[W3C.REC-xml-c14n-20010315]的规范形式确定了逻辑等价性。例如,必须正确处理空白文本节点才能满足此要求,因为默认情况下,空白是重要的[W3C.REC-xml-c14n-20010315]。
The specifications referencing these element schema types MUST define the full XML diff format with an appropriate MIME type [RFC3023] and a character set, e.g., UTF-8 [RFC3629]. For example, the partial PIDF format [RFC5262] includes this schema and describes additional definitions to produce a complete XML diff format for partial presence information updates.
引用这些元素模式类型的规范必须使用适当的MIME类型[RFC3023]和字符集(例如UTF-8[RFC3629])定义完整的XML diff格式。例如,部分PIDF格式[RFC5262]包括该模式,并描述了为部分存在信息更新生成完整XML diff格式的其他定义。
As the schema defined in this document does not declare any target namespace, the type definitions inherit the target namespace of the including schema. Therefore, additional namespace declarations within the XML diff documents can be avoided.
由于本文档中定义的架构没有声明任何目标命名空间,因此类型定义继承包含架构的目标命名空间。因此,可以避免XMLDiff文档中的附加名称空间声明。
It is anticipated that applications using these types will define <add>, <replace>, and <remove> elements based on the corresponding type definitions in this schema. In addition, an application may reference only a subset of these type definitions. A future extension can introduce other operations, e.g., with document-oriented models [W3C.REC-xmlschema-2-20041028], a <move> operation and a text node patching algorithm combined with <move> would undoubtedly produce smaller XML diff documents.
预计使用这些类型的应用程序将基于此模式中的相应类型定义定义<add>、<replace>和<remove>元素。此外,应用程序可能仅引用这些类型定义的子集。未来的扩展可以引入其他操作,例如,使用面向文档的模型[W3C.REC-xmlschema-2-20041028],与<move>相结合的<move>操作和文本节点修补算法无疑会产生更小的XML差异文档。
The instance document elements based on these schema type definitions MUST be well formed and SHOULD be valid.
基于这些架构类型定义的实例文档元素必须格式良好,并且应该有效。
The following XPath 1.0 data model node types can be added, replaced, or removed with this framework: elements, attributes, namespaces, comments, texts, and processing instructions. The full XML prolog, including for example XML entities [W3C.REC-xml-20060816] and the root node of an XML document, cannot be patched according to this framework. However, patching of comments and processing instructions of the root node is allowed. Naturally, the removal or addition of a document root element is not allowed as any valid XML document MUST always contain a single root element. Also, note that support for external entities is beyond the scope of this framework.
可以使用此框架添加、替换或删除以下XPath 1.0数据模型节点类型:元素、属性、名称空间、注释、文本和处理说明。完整的XML prolog,包括例如XML实体[W3C.REC-XML-20060816]和XML文档的根节点,不能根据此框架进行修补。但是,允许对根节点的注释和处理指令进行修补。当然,不允许删除或添加文档根元素,因为任何有效的XML文档必须始终包含单个根元素。另外,请注意,对外部实体的支持超出了此框架的范围。
An XML diff document contains a collection of patch operation elements, including one or more <add>, <replace>, and <remove> elements. These patch operations will be applied sequentially in the document order. After the first patch has been applied to update a target XML document, the patched XML document becomes a new
XML diff文档包含修补程序操作元素的集合,包括一个或多个<add>、<replace>和<remove>元素。这些修补程序操作将按文档顺序依次应用。应用第一个修补程序更新目标XML文档后,修补后的XML文档将成为新文档
independent XML document against which the next patch will be applied. This procedure repeats until all patches have successfully been processed.
将应用下一个修补程序的独立XML文档。重复此过程,直到成功处理所有修补程序。
Each patch operation element contains a 'sel' attribute. The value of this attribute is an XPath selector with a restricted subset of the full XPath 1.0 recommendation. The 'sel' value is used to locate a single unique target node from the target XML document. This located node pinpoints the target for a change and usually it is an element, which is for example either updated itself or some child node(s) are added into it. It MAY also be, for instance, a comment node, after which some other sibling node(s) are inserted. In any case, it is an error condition if multiple nodes are found during the evaluation of this selector value.
每个修补程序操作元素都包含一个“sel”属性。此属性的值是一个XPath选择器,具有完整XPath 1.0建议的受限子集。“sel”值用于从目标XML文档中定位单个唯一的目标节点。这个定位的节点精确定位更改的目标,通常它是一个元素,例如更新了自身或添加了一些子节点。例如,它也可以是注释节点,之后插入一些其他同级节点。在任何情况下,如果在此选择器值求值期间发现多个节点,则为错误情况。
The XPath selections of the 'sel' attribute always start from the root node of a document. Thus, relative location paths SHOULD be used so that the starting root node selection "/" can be omitted. When locating elements in a document tree, a node test can either be a "*" character or a QName [W3C.REC-xml-names-20060816]. A "*" character selects all element children of the context node. Right after the node test, a location step can contain one or more predicates in any order. An attribute value comparison is one of the most typical predicates. The string value of the current context node or a child element may alternatively be used to identify elements in the tree. The character ".", which denotes a current context node selection, is an abbreviated form of "self::node()". Lastly, positional constraints like "[2]" can also be used as an additional predicate.
“sel”属性的XPath选择始终从文档的根节点开始。因此,应使用相对位置路径,以便可以省略起始根节点选择“/”。在文档树中定位元素时,节点测试可以是“*”字符或QName[W3C.REC-xml-names-20060816]。“*”字符选择上下文节点的所有元素子元素。在节点测试之后,位置步骤可以包含一个或多个任意顺序的谓词。属性值比较是最典型的谓词之一。当前上下文节点或子元素的字符串值也可用于标识树中的元素。字符“.”表示当前上下文节点选择,是“self::node()”的缩写形式。最后,像“[2]”这样的位置约束也可以用作附加谓词。
An XPath 1.0 "id()" node-set function MAY also be used to identify unique elements from the document tree. The schema that describes the content model of the document MUST then use an attribute with the type ID [W3C.REC-xmlschema-2-20041028] or with non-validating XML parsers, an "xml:id" [W3C.WD-xml-id-20041109] attribute MUST have been used within an instance document.
XPath 1.0“id()”节点集函数也可用于标识文档树中的唯一元素。然后,描述文档内容模型的架构必须使用类型ID为[W3C.REC-xmlschema-2-20041028]的属性,或者对于非验证性XML解析器,实例文档中必须使用“XML:ID”[W3C.WD-XML-ID-20041109]属性。
The normal model for namespace prefixes is that they are local in scope. Thus, an XML diff document MAY have different prefixes for the namespaces used in the target document. The agent parsing the diff document MUST resolve prefixes separately in both documents in order to match the resulting QNames (qualified name) from each.
命名空间前缀的正常模型是它们在作用域中是局部的。因此,对于目标文档中使用的名称空间,XML diff文档可能具有不同的前缀。解析diff文档的代理必须分别解析两个文档中的前缀,以便匹配每个文档中生成的qname(限定名)。
The XML diff document MUST contain declarations for all namespaces used in the diff document. The diff document declarations are always used to determine what namespaces apply within the diff document.
XML diff文档必须包含diff文档中使用的所有名称空间的声明。diff文档声明始终用于确定diff文档中应用的名称空间。
A selector in a diff document may use prefixes when naming elements. If it does use a prefix, the prefix must be looked up in the diff document namespace declarations.
diff文档中的选择器在命名元素时可以使用前缀。如果它确实使用前缀,则必须在diff文档名称空间声明中查找前缀。
For example, the patch operation element of a diff document has an in-scope namespace declaration "xmlns:a='foo:'" with a selector "sel='a:bar'". The agent processing this patch MUST then look for a 'bar' element qualified with the 'foo:' namespace regardless of whether the 'foo:' namespace has a prefix assigned in the target document or what that prefix is.
例如,diff文档的patch operation元素有一个范围内命名空间声明“xmlns:a='foo:'”和一个选择器“sel='a:bar'”。然后,处理此修补程序的代理必须查找使用“foo:”命名空间限定的“bar”元素,而不管“foo:”命名空间是否在目标文档中分配了前缀或该前缀是什么。
Default namespaces make this model a little more complicated. When the diff document has a default namespace declaration, any element selector without a prefix MUST be evaluated using that namespace.
默认名称空间使该模型稍微复杂一些。当diff文档具有默认名称空间声明时,任何不带前缀的元素选择器都必须使用该名称空间进行求值。
For example, the patch operation element of a diff document has an in-scope namespace declaration "xmlns='foo:'" with a selector "sel='bar'". The agent processing this patch MUST then look for a 'bar' element qualified with the 'foo:' namespace, regardless of whether the 'foo:' namespace has a prefix assigned in the target document or what that prefix is.
例如,diff文档的patch operation元素具有范围内命名空间声明“xmlns='foo:”,并带有选择器“sel='bar'”。然后,处理此修补程序的代理必须查找使用“foo:”命名空间限定的“bar”元素,而不管“foo:”命名空间是否在目标文档中分配了前缀或该前缀是什么。
Unqualified names are also possible. If there is no default namespace declared, and an element name appears without a prefix, then it is an unqualified element name. If this appears in a selector, it MUST match an unqualified element in the target document.
也可以使用非限定名称。如果没有声明默认名称空间,并且出现的元素名称没有前缀,则该元素名称是非限定元素名称。如果这出现在选择器中,则它必须与目标文档中的非限定元素匹配。
For example, the patch operation element of a diff document has only one in-scope namespace declaration "xmlns:a='foo:'" with a selector "sel='bar'". Since the 'bar' element has no prefix, and there is no default namespace declaration in scope, the agent processing this patch can only match the selector against a 'bar' element that has no prefix and also no default namespace in scope.
例如,diff文档的patch operation元素只有一个范围内命名空间声明“xmlns:a='foo:'”和选择器“sel='bar'”。由于“bar”元素没有前缀,并且作用域中没有默认命名空间声明,因此处理此修补程序的代理只能将选择器与没有前缀且作用域中也没有默认命名空间的“bar”元素相匹配。
The prefix matching rules described previously in this section are different from those required in XPath 1.0 and 2.0 [W3C.REC-xpath20-20070123]. In XPath 1.0, a "bar" selector always locates an unqualified <bar> element. In XPath 2.0, a "bar" selector not only matches an unqualified <bar> element, but also matches a
本节前面描述的前缀匹配规则不同于XPath 1.0和2.0[W3C.REC-xpath20-20070123]中要求的规则。在XPath 1.0中,“bar”选择器始终定位不合格的<bar>元素。在XPath2.0中,“bar”选择器不仅匹配不合格的<bar>元素,还匹配
qualified <bar> element that is in scope of a default namespace declaration. In contrast, in this specification, a selector without a prefix only matches one element, and it may match an element with or without a prefix but only if the namespace it's qualified with (or none) is an exact match.
在默认命名空间声明范围内的限定<bar>元素。相反,在本规范中,不带前缀的选择器只匹配一个元素,它可以匹配带前缀或不带前缀的元素,但前提是它限定的名称空间(或无名称空间)完全匹配。
The XPath 1.0 recommendation specifies "namespace-uri()" and "local-name()" node-set functions that can be used within predicates. These functions may be utilized during XPath evaluations if there are no other means to "register" prefixes with associated namespace URIs. They can also be used when handling selections where default namespaces are attached to elements. However, this specification does not allow the usage of these functions.
XPath 1.0建议指定可以在谓词中使用的“namespace-uri()”和“local-name()”节点集函数。如果没有其他方法用关联的命名空间URI“注册”前缀,则可以在XPath求值期间使用这些函数。当处理将默认名称空间附加到元素的选择时,也可以使用它们。但是,本规范不允许使用这些函数。
Elements within the changed data content are also in scope of namespace declarations. For example, when adding a new namespace qualified element to the target XML document, the diff document MUST contain a namespace declaration that applies to the element. The agent processing the diff document MUST ensure that the target document also contains the same namespace declaration. Similar to XPath, the same namespace declaration in this context means that the namespace URIs MUST be equal, but the prefixes MAY be different in the diff and target documents.
更改的数据内容中的元素也在命名空间声明的范围内。例如,在向目标XML文档添加新的命名空间限定元素时,diff文档必须包含应用于该元素的命名空间声明。处理diff文档的代理必须确保目标文档也包含相同的命名空间声明。与XPath类似,此上下文中相同的名称空间声明意味着名称空间URI必须相等,但在diff和目标文档中前缀可能不同。
For example, if a new added <a:bar> element has a namespace declaration reference to "xmlns:a='foo:'" in the diff document and the target document has only a single in-scope namespace declaration "xmlns:b='foo:'" at the insertion point, the namespace reference MUST be changed so that a <b:bar> element will then exist in the patched document. The same rule applies although default namespaces were used in either or both of the documents, the namespace URIs determine what will be the correct references (prefixes) in the patched document.
例如,如果新添加的<a:bar>元素在diff文档中具有对“xmlns:a='foo:'”的名称空间声明引用,并且目标文档在插入点处只有一个范围内名称空间声明“xmlns:b='foo:”,则必须更改名称空间引用,以便在修补的文档中存在<b:bar>元素。同样的规则也适用,尽管在其中一个或两个文档中都使用了默认名称空间,但名称空间URI将确定修补文档中的正确引用(前缀)。
When the new or changed content has elements that declare new namespaces (locally scoped), these declarations are copied unaltered (prefix and everything) from the XML diff document to the target XML document. Default namespace declarations can only be added in this way, but prefixed namespace declarations MAY be added or removed with XPath namespace axis semantics shown later in this document (look Section 4.3.3).
当新的或更改的内容包含声明新名称空间(本地范围)的元素时,这些声明将原封不动地(前缀和所有内容)从XML diff文档复制到目标XML文档。默认名称空间声明只能以这种方式添加,但前缀名称空间声明可以使用本文档后面所示的XPath名称空间轴语义添加或删除(参见第4.3.3节)。
A fairly difficult use case for these rules is found when the target document has several namespace declarations in scope for the same namespace. A target document might declare several different
当目标文档在同一名称空间的作用域中有多个名称空间声明时,就会发现这些规则的一个相当困难的用例。目标文档可能会声明几个不同的
prefixes for the same namespace. Normally, the agent applying the diff document chooses *the* appropriate prefix for adding new elements to the target document, but in this special case there's more than one. These requirements create deterministic behavior for this special and in practice rare case:
相同名称空间的前缀。通常,应用diff文档的代理会选择*适当的前缀*向目标文档添加新元素,但在这种特殊情况下,有不止一个前缀。这些要求为这种特殊且在实践中罕见的情况创建了确定性行为:
- If the diff document happens to use a prefix that is one of the prefixes declared for the same namespace in the evaluation context node of the target document, this prefix MUST be used in the resulting patched document. An empty evaluable prefix and an existing in-scope default namespace declaration means that the default namespace MUST be chosen. In other words, the expanded names are then equal within the diff and patched documents.
- 如果diff文档恰好使用了一个前缀,该前缀是为目标文档的求值上下文节点中的同一命名空间声明的前缀之一,则必须在生成的修补文档中使用该前缀。空的可计算前缀和现有的范围内默认命名空间声明意味着必须选择默认命名空间。换句话说,扩展名在diff和补丁文档中是相等的。
In an <add> operation, the evaluation context node is the parent element of the inserted node, for example, with a selector "sel='*/ bar'" and without a 'pos' attribute directive (look Section 4.3), it is the <bar> element of the root document element. With modifications of elements, the evaluation context node is the parent element of the modified element, and in the previous example thus the root document element.
在<add>操作中,求值上下文节点是插入节点的父元素,例如,带有选择器“sel=”*/bar',并且没有“pos”属性指令(参见第4.3节),它是根文档元素的<bar>元素。元素修改后,评估上下文节点是修改后的元素的父元素,在上一个示例中是根文档元素。
- Secondly, the prefix (also empty) of the evaluation context node MUST be chosen if the namespace URIs are equal.
- 其次,如果名称空间URI相等,则必须选择求值上下文节点的前缀(也是空的)。
- Lastly, if the above two rules still don't apply, first all in-scope namespace prefixes of the evaluation context node are arranged alphabetically in an ascending order. If a default namespace declaration exists, it is interpreted as the first entry in this list. The prefix from the list is then chosen that appears as the closest and just before the compared prefix if it were inserted into the list. If the compared prefix were to exist before the first prefix, the first prefix in the list MUST be selected (i.e., there's no default namespace).
- 最后,如果上述两条规则仍然不适用,那么首先,求值上下文节点的所有范围内名称空间前缀都按字母升序排列。如果存在默认名称空间声明,它将被解释为此列表中的第一个条目。然后选择列表中的前缀,如果将其插入列表中,则该前缀将显示为最接近的前缀,并且恰好位于比较的前缀之前。如果要在第一个前缀之前存在比较的前缀,则必须选择列表中的第一个前缀(即,没有默认名称空间)。
For example, if the list of in-scope prefixes in the target document is "x", "y" and the compared prefix in the diff document is "xx", then the "x" prefix MUST be chosen. If an "a" prefix were evaluated, the "x" prefix, the first entry MUST be chosen. If there were also an in-scope default namespace declaration, an evaluable "a" prefix would then select the default declaration. Note that unprefixed attributes don't inherit the default namespace declaration. When adding qualified attributes, the default namespace declaration is then not on this matching list of prefixes (see Section 4.3.2).
例如,如果目标文档中的范围内前缀列表为“x”、“y”,而差异文档中的比较前缀为“xx”,则必须选择“x”前缀。如果计算了“a”前缀,“x”前缀,则必须选择第一个条目。如果还存在范围内默认名称空间声明,则可计算的“a”前缀将选择默认声明。请注意,未固定的属性不会继承默认的命名空间声明。添加限定属性时,默认名称空间声明不在此前缀匹配列表中(请参阅第4.3.2节)。
Note that these requirements might mean that a resulting patched document could contain unused and/or superfluous namespace declarations. The resulting patched document MUST NOT be "cleaned up" such that these namespace declarations are removed.
请注意,这些要求可能意味着生成的修补文档可能包含未使用和/或多余的命名空间声明。不能“清理”生成的修补文档,从而删除这些命名空间声明。
Note: In practice, the agent constructing a diff document can usually freely select the appropriate prefixes for the namespace declarations and it doesn't need to know or care about the actual prefixes in the target document unless there are overlapping declarations. In other words, the diff format content is typically independent of the target documents usage of namespace prefixes. However, it may be very useful to know where namespaces are declared in the target document. The most typical use case is such though, that the agent generating a diff has both the previous (target) and new (patched) documents available, and namespace declarations are thus exactly known. Note also, that in a case where the target document is not exactly known, it is allowed to use locally scoped namespace declarations, the consequences of which are larger and less human-readable patched documents.
注意:在实践中,构建diff文档的代理通常可以为名称空间声明自由选择适当的前缀,并且不需要知道或关心目标文档中的实际前缀,除非存在重叠声明。换句话说,diff格式的内容通常独立于目标文档名称空间前缀的使用。但是,了解名称空间在目标文档中的声明位置可能非常有用。不过,最典型的用例是,生成差异的代理既有以前的(目标)文档,也有新的(补丁)文档,因此名称空间声明是完全已知的。还要注意的是,在目标文档不完全已知的情况下,允许使用本地作用域的命名空间声明,其结果是更大、人类可读性更低的修补文档。
The <add> element represents the addition of some new content to the target XML document: for example, a new element can be appended into an existing element.
元素表示将一些新内容添加到目标XML文档中:例如,可以将新元素附加到现有元素中。
The new data content exists as the child node(s) of the <add> element. When adding attributes and namespaces, the child node of the <add> element MUST be a single text node. Otherwise, the <add> element MAY contain any mixture of element, text, comment or processing instruction nodes in any order. All children of the <add> element are then copied into a target XML document. The described namespace mangling procedure applies to added elements, which include all of their attribute, namespace and descendant nodes.
新数据内容作为<add>元素的子节点存在。添加属性和名称空间时,<add>元素的子节点必须是单个文本节点。否则,<add>元素可能以任何顺序包含元素、文本、注释或处理指令节点的任意组合。然后将<add>元素的所有子元素复制到目标XML文档中。所描述的名称空间损坏过程适用于添加的元素,这些元素包括其所有属性、名称空间和子节点。
The <add> element type has three attributes: 'sel', 'type', and 'pos'.
元素类型有三个属性:“sel”、“type”和“pos”。
The value of the optional 'type' attribute is only used when adding attributes and namespaces. Then, the located target node MUST be an element into which new attributes and namespace declarations are inserted. When the value of this 'type' attribute equals "@attr", the string "attr" is the name of the actual attribute being added. The value of this new 'attr' attribute is the text node content of the <add> element. The less frequently used prefixed (i.e., namespace-qualified) attributes can also be added. If the value of the 'type' attribute equals "namespace::pref", "pref" is the actual
可选“type”属性的值仅在添加属性和名称空间时使用。然后,定位的目标节点必须是插入新属性和名称空间声明的元素。当此“type”属性的值等于“@attr”时,字符串“attr”是要添加的实际属性的名称。这个新的“attr”属性的值是<add>元素的文本节点内容。还可以添加使用频率较低的前缀(即命名空间限定)属性。如果“type”属性的值等于“namespace::pref”,“pref”是实际值
prefix string to be used for the namespace declaration in the patched document and the text node content of the <add> element contains the corresponding namespace URI.
用于修补文档中名称空间声明的前缀字符串,<add>元素的文本节点内容包含相应的名称空间URI。
Note: The 'type' attribute is thus also an XPath selector, but it only locates attributes and namespaces. Attribute axis "attribute" has an abbreviated form "@" unlike the "namespace" axis, which doesn't have an abbreviated form. Double colons "::" are used as an axis separator in XPath.
注意:“type”属性因此也是一个XPath选择器,但它只定位属性和名称空间。属性轴“Attribute”具有缩写形式“@”,而“namespace”轴没有缩写形式。双冒号“:”在XPath中用作轴分隔符。
The value of the optional 'pos' attribute indicates the positioning of new data content. It is not used when adding attributes or namespaces. When neither 'type' nor 'pos' attribute exist, the children of the <add> element are then appended as the last child node(s) of the located target element. When the value of 'pos' attribute is "prepend" the new node(s) are added as the first child node(s) of the located target element. With the value of "before", the added new node(s) MUST be the immediate preceding sibling node(s), and with "after", the immediate following sibling node(s) of the located target node.
可选“pos”属性的值表示新数据内容的位置。添加属性或名称空间时不使用它。当“type”和“pos”属性都不存在时,<add>元素的子元素将被追加为定位的目标元素的最后一个子节点。当“pos”属性的值为“prepend”时,新节点被添加为定位目标元素的第一个子节点。如果值为“before”,则添加的新节点必须是定位目标节点的前一个兄弟节点,如果值为“after”,则必须是定位目标节点的后一个兄弟节点。
Some examples follow that describe the use cases of these <add> element attributes. The nodes are not namespace qualified and prefixes are therefore not used, and the whole XML diff content is not shown in these examples, only patch operation elements. Full examples are given in an Appendix A.
下面的一些示例描述了这些<add>元素属性的用例。这些节点不是命名空间限定的,因此不使用前缀,在这些示例中不显示整个XML diff内容,只显示补丁操作元素。附录A中给出了完整的示例。
An example for an addition of an element:
添加元素的示例如下:
<add sel="doc"><foo id="ert4773">This is a new child</foo></add>
<add sel="doc"><foo id="ert4773">This is a new child</foo></add>
Once the <doc> element has been found from the target XML document, a new <foo> element is appended as the last child node of the <doc> element. The located target node: the <doc> element is naturally the root element of the target XML document. The new <foo> element contains an 'id' attribute and a child text node.
从目标XML文档中找到<doc>元素后,将添加一个新的<foo>元素作为<doc>元素的最后一个子节点。定位的目标节点:<doc>元素自然是目标XML文档的根元素。新的<foo>元素包含一个“id”属性和一个子文本节点。
An example for an addition of an attribute:
添加属性的示例如下:
<add sel="doc/foo[@id='ert4773']" type="@user">Bob</add>
<add sel="doc/foo[@id='ert4773']" type="@user">Bob</add>
This operation adds a new 'user' attribute to the <foo> element that was located by using an 'id' attribute value predicate. The value of this new 'user' attribute is "Bob".
此操作向使用“id”属性值谓词定位的<foo>元素添加新的“user”属性。这个新的“user”属性的值是“Bob”。
A similar patched XML document is achieved when using a validating XML parser, if the 'sel' selector value had been 'id("ert4773")' and if the data type of the 'id' attribute is "ID" [W3C.REC-xmlschema-2-20041028].
如果“sel”选择器值为“id”(“ert4773”),“id”属性的数据类型为“id”[W3C.REC-xmlschema-2-20041028],则在使用验证XML解析器时,可以获得类似的修补XML文档。
Note that with namespace qualified attributes, the prefix matching rules within the 'type' attribute are evaluated with similar rules described in Section 4.2.3. Also, note that then the possible default namespace declaration of the context element isn't applicable.
请注意,对于命名空间限定属性,“type”属性中的前缀匹配规则将使用第4.2.3节中描述的类似规则进行评估。另外,请注意,上下文元素可能的默认名称空间声明不适用。
Note: As the 'sel' selector value MAY contain quotation marks, escaped forms: """ or "'" can be used within attribute values. However, it is often more appropriate to use the apostrophe (') character as shown in these examples. An alternative is also to interchange the apostrophes and quotation marks.
注意:“sel”选择器值可能包含引号,因此可以在属性值中使用转义形式:“或”apos“。但是,如这些示例所示,使用撇号(')字符通常更合适。另一种方法是交换撇号和引号。
An example for an addition of a prefixed namespace declaration:
添加带前缀的命名空间声明的示例:
<add sel="doc" type="namespace::pref">urn:ns:xxx</add>
<add sel="doc" type="namespace::pref">urn:ns:xxx</add>
This operation adds a new namespace declaration to the <doc> element. The prefix of this new namespace node is thus "pref" and the namespace URI is "urn:ns:xxx".
此操作向<doc>元素添加新的命名空间声明。因此,这个新名称空间节点的前缀是“pref”,名称空间URI是“urn:ns:xxx”。
An example for an addition of a comment node:
添加注释节点的示例如下:
<add sel="doc/foo[@id='ert4773']" pos="before"><!-- comment --></add>
<add sel="doc/foo[@id='ert4773']" pos="before"><!-- comment --></add>
This operation adds a new comment node just before the <foo> element as an immediate preceding sibling node. This is also an example how a 'pos' attribute directive can be used.
此操作在<foo>元素之前添加一个新的注释节点,作为前一个同级节点。这也是如何使用“pos”属性指令的示例。
Some complexity arises when so-called white space text nodes exist within a target XML document. The XPath 1.0 data model requires that a text node MUST NOT have another text node as an immediate sibling node. For instance, if an add operation is like this:
当目标XML文档中存在所谓的空白文本节点时,会出现一些复杂性。XPath 1.0数据模型要求文本节点不能有另一个文本节点作为直接同级节点。例如,如果添加操作如下所示:
<add sel="doc"> <foo id="ert4773">This is a new child</foo></add>
<add sel="doc"> <foo id="ert4773">This is a new child</foo></add>
The <add> element then has two child nodes: a white space text node (a linefeed and two spaces) and a <foo> element. If the existing last child of the <doc> element is a text node, its content and the white space text node content MUST then be combined together. Otherwise, (white space) text nodes can be added just like elements, and thus, the canonical form of the patched XML document easily remains deterministic. As several sibling nodes can be inserted with a single <add> operation, a "pretty printing" style can easily be maintained.
然后,<add>元素有两个子节点:一个空白文本节点(一个换行符和两个空格)和一个<foo>元素。如果<doc>元素的现有最后一个子元素是文本节点,则其内容和空白文本节点内容必须组合在一起。否则,(空白)文本节点可以像元素一样添加,因此,补丁XML文档的规范形式很容易保持确定性。由于可以通过一个<add>操作插入多个同级节点,因此可以很容易地维护“漂亮打印”样式。
Still another example about the handling of text nodes. Consider this example:
还有一个关于文本节点处理的示例。考虑这个例子:
<add sel="*/foo/text()[2]" pos="after">new<bar/>elem</add>
<add sel="*/foo/text()[2]" pos="after">new<bar/>elem</add>
The second text node child of the <foo> element is first located. The added new content contains two text nodes and an element. As there cannot be immediate sibling text nodes, the located target text node content and the first new text node content MUST be combined together. In essence, if the 'pos' value had been "before", the second new text node content would effectively have been prepended to the located target text node.
首先定位<foo>元素的第二个文本节点子节点。添加的新内容包含两个文本节点和一个元素。由于不存在直接同级文本节点,因此必须将定位的目标文本节点内容和第一个新文本节点内容组合在一起。本质上,如果“pos”值是“before”,则第二个新文本节点内容将有效地预先添加到定位的目标文本节点。
Note: It is still worth noting that text nodes MAY contain CDATA sections, the latter of which are not treated as separate nodes. Once these CDATA sections exist within the new text nodes, they SHOULD be moved unaltered to the patched XML document.
注意:仍然值得注意的是,文本节点可能包含CDATA节,后者不被视为单独的节点。一旦这些CDATA节存在于新的文本节点中,就应该将它们原封不动地移动到修补过的XML文档中。
While XML entities [W3C.REC-xml-20060816] cannot be patched with this framework, the references to other than predefined internal entities can exist within text nodes or attributes when the XML prolog contains those declarations. These references may then be preserved if both the XML diff and the target XML document have identical declarations within their prologs. Otherwise, references may be replaced with identical text as long as the "canonically equivalent" rule is obeyed.
虽然XML实体[W3C.REC-XML-20060816]无法使用此框架修补,但当XML prolog包含这些声明时,对预定义内部实体以外的其他实体的引用可以存在于文本节点或属性中。如果XML diff和目标XML文档在其序言中具有相同的声明,则可以保留这些引用。否则,只要遵守“规范等效”规则,就可以用相同的文本替换引用。
The <replace> element represents a replacement operation: for example, an existing element is updated with a new element or an attribute value is replaced with a new value. This <replace> operation always updates a single node or node content at a time.
<replace>元素表示替换操作:例如,用新元素更新现有元素或用新值替换属性值。此<replace>操作始终一次更新单个节点或节点内容。
The <replace> element type only has a 'sel' attribute. If the located target node is an element, a comment or a processing instruction, then the child of the <replace> element MUST also be of the same type. Otherwise, the <replace> element MUST have text
The <replace> element type only has a 'sel' attribute. If the located target node is an element, a comment or a processing instruction, then the child of the <replace> element MUST also be of the same type. Otherwise, the <replace> element MUST have text
content or it MAY be empty when replacing an attribute value or a text node content.
内容,或者在替换属性值或文本节点内容时它可能为空。
An example for a replacement of an element:
替换元件的示例如下:
<replace sel="doc/foo[@a='1']"><bar a="2"/></replace>
<replace sel="doc/foo[@a='1']"><bar a="2"/></replace>
This will update the <foo> element that has an 'a' attribute with value "1". The located target element is replaced with the <bar> element. So all descendant nodes, namespace declarations, and attributes of the replaced <foo> element, if any existed, are thus removed.
这将更新具有值为“1”的“a”属性的<foo>元素。定位的目标元素将替换为<bar>元素。因此,被替换的<foo>元素的所有子代节点、名称空间声明和属性(如果存在)都将被删除。
An example for a replacement of an attribute value:
替换属性值的示例如下:
<replace sel="doc/@a">new value</replace>
<replace sel="doc/@a">new value</replace>
This will replace the 'a' attribute content of the <doc> element with the value "new value". If the <replace> element is empty, the 'a' attribute MUST then remain in the patched XML document appearing like <doc a=""/>.
这将用值“new value”替换<doc>元素的“a”属性内容。如果<replace>元素为空,则“a”属性必须保留在已修补的XML文档中,看起来像<doc a=”“/>。
An example for a replacement of a namespace URI:
替换命名空间URI的示例如下:
<replace sel="doc/namespace::pref">urn:new:xxx</replace>
<replace sel="doc/namespace::pref">urn:new:xxx</replace>
This will replace the URI value of 'pref' prefixed namespace node with "urn:new:xxx". The parent node of the namespace declaration MUST be the <doc> element, otherwise an error occurs.
这将用“urn:new:xxx”替换前缀为“pref”的命名空间节点的URI值。命名空间声明的父节点必须是<doc>元素,否则会发生错误。
An example for a replacement of a comment node:
替换注释节点的示例如下:
<replace sel="doc/comment()[1]"><!-- This is the new content --></replace>
<replace sel="doc/comment()[1]"><!-- This is the new content --></replace>
This will replace a comment node. The located target node is the first comment node child of the <doc> element.
这将替换注释节点。定位的目标节点是<doc>元素的第一个注释节点子节点。
An example for a replacement of a processing instruction node:
处理指令节点的替换示例:
<replace sel='doc/processing-instruction("test")'><?test bar="foobar" ?></replace>
<replace sel='doc/processing-instruction("test")'><?test bar="foobar" ?></replace>
This will replace the processing instruction node "test" whose parent is the <doc> element.
这将替换其父元素为<doc>元素的处理指令节点“test”。
An example for a replacement of a text node:
替换文本节点的示例如下:
<replace sel="doc/foo/text()[1]">This is the new text content</replace>
<replace sel="doc/foo/text()[1]">This is the new text content</replace>
This will replace the first text node child of the <foo> element. The positional constraint "[1]" is not usually needed as the element content is rarely of mixed type [W3C.REC-xmlschema-1-20041028] where several text node siblings typically exist.
这将替换<foo>元素的第一个文本节点子节点。通常不需要位置约束“[1]”,因为元素内容很少是混合类型[W3C.REC-xmlschema-1-20041028],其中通常存在多个文本节点同级。
If a text node is updated and the <replace> element is empty, the text node MUST thus be removed as a text node MUST always have at least one character of data.
如果文本节点已更新且<replace>元素为空,则必须删除该文本节点,因为文本节点必须始终具有至少一个数据字符。
The <remove> element represents a removal operation of, for example, an existing element or an attribute.
<remove>元素表示删除操作,例如,现有元素或属性。
The <remove> element type has two attributes: 'sel' and 'ws'. The value of the optional 'ws' attribute is used to remove the possible white space text nodes that exist either as immediate following or preceding sibling nodes of the located target node. The usage of 'ws' attribute is only allowed when removing other types than text, attribute and namespace nodes. If the value of 'ws' is "before", the purpose is to remove the immediate preceding sibling node that MUST be a white space text node and if the value is "after", the corresponding following node. If the 'ws' value is "both", both the preceding and following white space text nodes MUST be removed.
<remove>元素类型有两个属性:“sel”和“ws”。可选“ws”属性的值用于删除可能存在的空白文本节点,这些节点作为定位目标节点的紧挨着的同级节点或紧挨着的同级节点存在。仅当删除除文本、属性和命名空间节点以外的其他类型时,才允许使用“ws”属性。如果“ws”的值为“before”,则目的是删除必须是空白文本节点的前一个同级节点,如果值为“after”,则删除相应的后一个节点。如果“ws”值为“both”,则必须删除前面和后面的空白文本节点。
An example of a removal of an element including all of its descendant, attribute, and namespace nodes:
删除包含其所有子代、属性和命名空间节点的元素的示例:
<remove sel="doc/foo[@a='1']" ws="after"/>
<remove sel="doc/foo[@a='1']" ws="after"/>
This will remove the <foo> element as well as the immediate following sibling white space text node of the <foo> element. If the immediate following sibling node is not a white space text node, an error occurs.
这将删除<foo>元素以及<foo>元素紧跟其后的同级空白文本节点。如果紧跟其后的同级节点不是空白文本节点,则会发生错误。
An example for a removal of an attribute node:
删除属性节点的示例如下:
<remove sel="doc/@a"/>
<remove sel="doc/@a"/>
This will remove the 'a' attribute node from the <doc> element.
这将从<doc>元素中删除“a”属性节点。
An example for a removal of a prefixed namespace node:
删除带前缀的命名空间节点的示例:
<remove sel="doc/foo/namespace::pref"/>
<remove sel="doc/foo/namespace::pref"/>
This will remove the 'pref' prefixed namespace node from the <foo> element. Naturally, this prefix MUST NOT be associated with any node prior to the removal of this namespace node. Also, the parent node of this namespace declaration MUST be the <foo> element.
这将从<foo>元素中删除带有“pref”前缀的命名空间节点。当然,在删除此命名空间节点之前,此前缀不得与任何节点相关联。此外,此命名空间声明的父节点必须是<foo>元素。
An example for a removal of a comment node:
删除注释节点的示例如下:
<remove sel="doc/comment()[1]"/>
<remove sel="doc/comment()[1]"/>
This will remove the first comment node child of the <doc> element.
这将删除<doc>元素的第一个注释节点子节点。
An example for a removal of a processing instruction node:
移除处理指令节点的示例:
<remove sel='doc/processing-instruction("test")'/>
<remove sel='doc/processing-instruction("test")'/>
This will remove the "test" processing instruction node child of the <doc> element.
这将删除<doc>元素的“test”处理指令节点子节点。
An example for a removal of a text node:
删除文本节点的示例如下:
<remove sel="doc/foo/text()[1]"/>
<remove sel="doc/foo/text()[1]"/>
This will remove the first text node child of the <foo> element.
这将删除<foo>元素的第一个文本节点子节点。
When removing an element, a comment, or a processing instruction node that has immediate preceding and following sibling text nodes without the 'ws' directive, the content of these two text nodes MUST be combined together. The latter text node thus disappears from the document.
删除元素、注释或处理指令节点时,如果该元素、注释或处理指令节点的前一个和后一个兄弟文本节点没有“ws”指令,则这两个文本节点的内容必须组合在一起。因此,后一个文本节点将从文档中消失。
It is an error condition if any of the patch operations cannot be unambiguously fulfilled. In other words, once a particular patch operation fails, it is an error condition and processing of further patch operations is hardly sensible.
如果无法明确执行任何修补程序操作,则为错误情况。换句话说,一旦某个特定的修补程序操作失败,这就是一种错误情况,处理进一步的修补程序操作几乎是不明智的。
A new MIME error format is defined for applications that require deterministic error handling when patching cannot be applied. It is anticipated that these error elements can be used within other MIME types that allow extension elements.
当无法应用修补程序时,为需要确定性错误处理的应用程序定义了一种新的MIME错误格式。预计这些错误元素可以在允许扩展元素的其他MIME类型中使用。
The root element of the error document is <patch-ops-error>. The content of this element is a specific error condition. Each error condition is represented by a different element. This allows for different error conditions to provide different data about the nature of the error. All error elements support a "phrase" attribute, which can contain text meant for rendering to a human user. The optional "xml:lang" MAY be used to describe the language of the "phrase" attribute. Most of the error condition elements are supposed to contain the patch operation element that caused the patch to fail.
错误文档的根元素是<patch ops error>。此元素的内容是特定的错误条件。每个错误条件由不同的元素表示。这允许不同的错误条件提供有关错误性质的不同数据。所有错误元素都支持“短语”属性,该属性可以包含用于呈现给人类用户的文本。可选的“xml:lang”可用于描述“短语”属性的语言。大多数错误条件元素都应该包含导致修补程序失败的修补程序操作元素。
The following error elements are defined by this specification:
本规范定义了以下错误元素:
<invalid-attribute-value>: The validity constraints of 'sel', 'type', 'ws', or 'pos' attribute values MAY be indicated with this error, i.e., non-allowable content has been used. Also, this error can be used to indicate if an added or a modified attribute content is not valid, for example, CDATA sections were used when a new attribute was intended to be added.
<无效属性值>:“sel”、“type”、“ws”或“pos”属性值的有效性约束可能与此错误一起指示,即使用了不允许的内容。此外,此错误还可用于指示添加或修改的属性内容是否无效,例如,在打算添加新属性时使用了CDATA节。
<invalid-character-set>: The patch could not be applied because the diff and the patched document use different character sets.
<invalid character set>:无法应用修补程序,因为diff和修补的文档使用不同的字符集。
<invalid-diff-format>: This indicates that the diff body of the request was not a well-formed XML document or a valid XML document according to its schema.
<invalid diff format>:这表示请求的diff主体不是格式良好的XML文档,也不是符合其架构的有效XML文档。
<invalid-entity-declaration>: An entity reference was found but corresponding declaration could not be located or resolved.
<invalid entity declaration>:找到实体引用,但无法找到或解析相应的声明。
<invalid-namespace-prefix>: The namespace URI for the given prefix could not be located or resolved, e.g., within the 'sel' attribute a prefix was used but its declaration is missing from the target document.
<无效命名空间前缀>:无法定位或解析给定前缀的命名空间URI,例如,在“sel”属性中使用了前缀,但目标文档中缺少其声明。
<invalid-namespace-uri>: The namespace URI value is not valid or the target document did not have this declaration.
<无效命名空间uri>:命名空间uri值无效或目标文档没有此声明。
<invalid-node-types>: The node types of a <replace> operation did not match, i.e., for example, the 'sel' selector locates an element but the replaceable content is of text type. Also, a <replace> operation may locate a unique element, but replaceable content had multiple nodes.
<invalid node types>:<replace>操作的节点类型不匹配,例如,“sel”选择器定位元素,但可替换内容为文本类型。另外,<replace>操作可以定位唯一的元素,但可替换内容有多个节点。
<invalid-patch-directive>: A patch directive could not be fulfilled because the given directives were not understood.
<invalid patch directive>:无法执行修补程序指令,因为未理解给定的指令。
<invalid-root-element-operation>: The root element of the document cannot be removed or another sibling element for the document root element cannot be added.
<invalid root element operation>:无法删除文档的根元素,或者无法添加文档根元素的另一个同级元素。
<invalid-xml-prolog-operation>: Patch failure related to XML prolog nodes.
<invalid xml prolog operation>:与xml prolog节点相关的修补程序故障。
<invalid-whitespace-directive>: A <remove> operation requires a removal of a white space node that doesn't exist in the target document.
<invalid whitespace directive>:<remove>操作需要删除目标文档中不存在的空白节点。
<unlocated-node>: A single unique node (typically an element) could not be located with the 'sel' attribute value. Also, the location of multiple nodes can lead to this error.
<unlocated node>:无法使用“sel”属性值定位单个唯一节点(通常为元素)。此外,多个节点的位置也可能导致此错误。
<unsupported-id-function>: The nodeset function id() is not supported, and thus attributes with the ID type are not known.
<unsupported id function>:不支持节点集函数id(),因此id类型的属性未知。
<unsupported-xml-id>: The attribute xml:id as an ID attribute in XML documents is not supported.
<unsupported xml id>:不支持将属性xml:id作为xml文档中的id属性。
Additional error elements can be indicated within the root <patch-ops-error> element from any namespace. However, the IETF MAY specify additional error elements in the "urn:ietf:params:xml:ns:patch-ops-error" namespace.
可以在任何名称空间的根<patch ops error>元素中指示其他错误元素。但是,IETF可以在“urn:IETF:params:xml:ns:patch ops error”命名空间中指定其他错误元素。
As an example, the following document indicates that it was attempted to add a new <note> element with white space into a document, but the parent element could not be located:
例如,以下文档表示试图将带有空白的新<note>元素添加到文档中,但找不到父元素:
<?xml version="1.0" encoding="UTF-8"?> <patch-ops-error xmlns:p="urn:ietf:params:xml:ns:pidf-diff" xmlns="urn:ietf:params:xml:ns:patch-ops-error"> <unlocated-node phrase="a unique node could not be located with the id() function." ><p:add sel='id("ert4773")'> <p:note>some text added</p:note> </p:add></unlocated-node> </patch-ops-error>
<?xml version="1.0" encoding="UTF-8"?> <patch-ops-error xmlns:p="urn:ietf:params:xml:ns:pidf-diff" xmlns="urn:ietf:params:xml:ns:patch-ops-error"> <unlocated-node phrase="a unique node could not be located with the id() function." ><p:add sel='id("ert4773")'> <p:note>some text added</p:note> </p:add></unlocated-node> </patch-ops-error>
An XML diff document SHOULD contain only the nodes that have been modified as the intention is to try to reduce bandwidth/storage requirements. However, when there's a large collection of changes it can be desirable to exchange the full document content instead. How this will be done in practice is beyond the scope of this document.
XML diff文档应仅包含已修改的节点,因为其目的是试图减少带宽/存储需求。但是,当有大量更改时,最好交换完整的文档内容。如何在实践中做到这一点超出了本文件的范围。
Some applications MAY require that the full versioning history MUST be indicated although the history had superfluous changes. This framework doesn't mandate any specific behavior, applications MAY decide the appropriate semantics themselves. Also, in practice, applications are free to select the proper algorithms when generating diff document content.
一些应用程序可能要求必须指示完整的版本控制历史记录,尽管历史记录有多余的更改。这个框架不要求任何特定的行为,应用程序可以自己决定合适的语义。此外,在实践中,应用程序可以在生成差异文档内容时自由选择适当的算法。
It is up to the application to decide what kind of selector values to use. Positional element selectors like "*/*[3]/*[2]" provide the shortest selectors, but care must to taken when using them. When there are several removals of sibling elements, the positional element indexes change after each update. Likewise these indexes change when new elements are inserted into the tree. Using names with possible attribute predicates like "doc[@sel='foo']" is usually easier for an application, be it for example an auto diff tool, but it leads to larger diff documents.
由应用程序决定使用哪种选择器值。像“*/*[3]/*[2]”这样的位置元素选择器提供了最短的选择器,但在使用它们时必须小心。当有多个同级元素被删除时,位置元素索引在每次更新后都会更改。同样,当新元素插入到树中时,这些索引也会发生变化。对于应用程序来说,将名称与可能的属性谓词(如“doc[@sel='foo'])一起使用通常更容易,例如自动差异工具,但它会导致更大的差异文档。
The schema types for the patch operation elements.
修补程序操作元素的架构类型。
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE schema [ <!ENTITY ncname "\i\c*"> <!ENTITY qname "(&ncname;:)?&ncname;"> <!ENTITY aname "@&qname;"> <!ENTITY pos "\[\d+\]">
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE schema [ <!ENTITY ncname "\i\c*"> <!ENTITY qname "(&ncname;:)?&ncname;"> <!ENTITY aname "@&qname;"> <!ENTITY pos "\[\d+\]">
<!ENTITY attr "\[&aname;='(.)*'\]|\[&aname;="(.)*"\]"> <!ENTITY valueq "\[(&qname;|\.)="(.)*"\]"> <!ENTITY value "\[(&qname;|\.)='(.)*'\]|&valueq;"> <!ENTITY cond "&attr;|&value;|&pos;"> <!ENTITY step "(&qname;|\*)(&cond;)*"> <!ENTITY piq "processing-instruction\(("&ncname;")\)"> <!ENTITY pi "processing-instruction\(('&ncname;')?\)|&piq;"> <!ENTITY id "id\(('&ncname;')?\)|id\(("&ncname;")?\)"> <!ENTITY com "comment\(\)"> <!ENTITY text "text\(\)"> <!ENTITY nspa "namespace::&ncname;"> <!ENTITY cnodes "(&text;(&pos;)?)|(&com;(&pos;)?)|((π)(&pos;)?)"> <!ENTITY child "&cnodes;|&step;"> <!ENTITY last "(&child;|&aname;|&nspa;)"> ]> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<!ENTITY attr "\[&aname;='(.)*'\]|\[&aname;="(.)*"\]"> <!ENTITY valueq "\[(&qname;|\.)="(.)*"\]"> <!ENTITY value "\[(&qname;|\.)='(.)*'\]|&valueq;"> <!ENTITY cond "&attr;|&value;|&pos;"> <!ENTITY step "(&qname;|\*)(&cond;)*"> <!ENTITY piq "processing-instruction\(("&ncname;")\)"> <!ENTITY pi "processing-instruction\(('&ncname;')?\)|&piq;"> <!ENTITY id "id\(('&ncname;')?\)|id\(("&ncname;")?\)"> <!ENTITY com "comment\(\)"> <!ENTITY text "text\(\)"> <!ENTITY nspa "namespace::&ncname;"> <!ENTITY cnodes "(&text;(&pos;)?)|(&com;(&pos;)?)|((π)(&pos;)?)"> <!ENTITY child "&cnodes;|&step;"> <!ENTITY last "(&child;|&aname;|&nspa;)"> ]> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:simpleType name="xpath"> <xsd:restriction base="xsd:string"> <xsd:pattern value="(/)?((&id;)((/&step;)*(/&last;))?|(&step;/)*(&last;))"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="xpath"> <xsd:restriction base="xsd:string"> <xsd:pattern value="(/)?((&id;)((/&step;)*(/&last;))?|(&step;/)*(&last;))"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="xpath-add"> <xsd:restriction base="xsd:string"> <xsd:pattern value="(/)?((&id;)((/&step;)*(/&child;))?|(&step;/)*(&child;))"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="xpath-add"> <xsd:restriction base="xsd:string"> <xsd:pattern value="(/)?((&id;)((/&step;)*(/&child;))?|(&step;/)*(&child;))"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="pos"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="before"/> <xsd:enumeration value="after"/> <xsd:enumeration value="prepend"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="pos"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="before"/> <xsd:enumeration value="after"/> <xsd:enumeration value="prepend"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="type"> <xsd:restriction base="xsd:string"> <xsd:pattern value="&aname;|&nspa;"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="type"> <xsd:restriction base="xsd:string"> <xsd:pattern value="&aname;|&nspa;"/> </xsd:restriction> </xsd:simpleType>
<xsd:complexType name="add">
<xsd:complexType name="add">
<xsd:complexContent mixed="true"> <xsd:restriction base="xsd:anyType"> <xsd:sequence> <xsd:any processContents="lax" namespace="##any" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="sel" type="xpath-add" use="required"/> <xsd:attribute name="pos" type="pos"/> <xsd:attribute name="type" type="type"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType>
<xsd:complexContent mixed="true"> <xsd:restriction base="xsd:anyType"> <xsd:sequence> <xsd:any processContents="lax" namespace="##any" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="sel" type="xpath-add" use="required"/> <xsd:attribute name="pos" type="pos"/> <xsd:attribute name="type" type="type"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType>
<xsd:complexType name="replace"> <xsd:complexContent mixed="true"> <xsd:restriction base="xsd:anyType"> <xsd:sequence> <xsd:any processContents="lax" namespace="##any" minOccurs="0" maxOccurs="1"/> </xsd:sequence> <xsd:attribute name="sel" type="xpath" use="required"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType>
<xsd:complexType name="replace"> <xsd:complexContent mixed="true"> <xsd:restriction base="xsd:anyType"> <xsd:sequence> <xsd:any processContents="lax" namespace="##any" minOccurs="0" maxOccurs="1"/> </xsd:sequence> <xsd:attribute name="sel" type="xpath" use="required"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType>
<xsd:simpleType name="ws"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="before"/> <xsd:enumeration value="after"/> <xsd:enumeration value="both"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="ws"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="before"/> <xsd:enumeration value="after"/> <xsd:enumeration value="both"/> </xsd:restriction> </xsd:simpleType>
<xsd:complexType name="remove"> <xsd:attribute name="sel" type="xpath" use="required"/> <xsd:attribute name="ws" type="ws"/> </xsd:complexType>
<xsd:complexType name="remove"> <xsd:attribute name="sel" type="xpath" use="required"/> <xsd:attribute name="ws" type="ws"/> </xsd:complexType>
</xsd:schema>
</xsd:schema>
The patch operation errors definitions.
修补程序操作错误定义。
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="urn:ietf:params:xml:ns:patch-ops-error"
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="urn:ietf:params:xml:ns:patch-ops-error"
xmlns:tns="urn:ietf:params:xml:ns:patch-ops-error" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
xmlns:tns="urn:ietf:params:xml:ns:patch-ops-error" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- This import brings in the XML language attribute xml:lang--> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
<!-- This import brings in the XML language attribute xml:lang--> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
<!-- ROOT document element for signaling patch-ops errors --> <xsd:element name="patch-ops-error"> <xsd:complexType> <xsd:sequence> <xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:anyAttribute processContents="lax"/> </xsd:complexType> </xsd:element>
<!-- ROOT document element for signaling patch-ops errors --> <xsd:element name="patch-ops-error"> <xsd:complexType> <xsd:sequence> <xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:anyAttribute processContents="lax"/> </xsd:complexType> </xsd:element>
<!-- patch-ops error elements: not intended to be used as root documnet elements --> <xsd:element name="invalid-attribute-value" type="tns:patch-error"/> <xsd:element name="invalid-character-set" type="tns:patch-error-simple"/> <xsd:element name="invalid-diff-format" type="tns:patch-error-simple"/> <xsd:element name="invalid-entity-declaration" type="tns:patch-error"/> <xsd:element name="invalid-namespace-prefix" type="tns:patch-error"/> <xsd:element name="invalid-namespace-uri" type="tns:patch-error"/> <xsd:element name="invalid-node-types" type="tns:patch-error"/> <xsd:element name="invalid-patch-directive" type="tns:patch-error"/> <xsd:element name="invalid-root-element-operation" type="tns:patch-error"/> <xsd:element name="invalid-xml-prolog-operation" type="tns:patch-error"/> <xsd:element name="invalid-whitespace-directive" type="tns:patch-error"/> <xsd:element name="unlocated-node" type="tns:patch-error"/> <xsd:element name="unsupported-id-function" type="tns:patch-error"/>
<!-- patch-ops error elements: not intended to be used as root documnet elements --> <xsd:element name="invalid-attribute-value" type="tns:patch-error"/> <xsd:element name="invalid-character-set" type="tns:patch-error-simple"/> <xsd:element name="invalid-diff-format" type="tns:patch-error-simple"/> <xsd:element name="invalid-entity-declaration" type="tns:patch-error"/> <xsd:element name="invalid-namespace-prefix" type="tns:patch-error"/> <xsd:element name="invalid-namespace-uri" type="tns:patch-error"/> <xsd:element name="invalid-node-types" type="tns:patch-error"/> <xsd:element name="invalid-patch-directive" type="tns:patch-error"/> <xsd:element name="invalid-root-element-operation" type="tns:patch-error"/> <xsd:element name="invalid-xml-prolog-operation" type="tns:patch-error"/> <xsd:element name="invalid-whitespace-directive" type="tns:patch-error"/> <xsd:element name="unlocated-node" type="tns:patch-error"/> <xsd:element name="unsupported-id-function" type="tns:patch-error"/>
<xsd:element name="unsupported-xml-id" type="tns:patch-error"/>
<xsd:element name="unsupported-xml-id" type="tns:patch-error"/>
<!-- simple patch-ops error type --> <xsd:complexType name="patch-error-simple"> <xsd:attribute name="phrase" type="xsd:string"/> <xsd:attribute ref="xml:lang"/> <xsd:anyAttribute processContents="lax"/> </xsd:complexType>
<!-- simple patch-ops error type --> <xsd:complexType name="patch-error-simple"> <xsd:attribute name="phrase" type="xsd:string"/> <xsd:attribute ref="xml:lang"/> <xsd:anyAttribute processContents="lax"/> </xsd:complexType>
<!-- error type which includes patch operation --> <xsd:complexType name="patch-error"> <xsd:sequence> <xsd:any namespace="##any" processContents="lax"/> </xsd:sequence> <xsd:attribute name="phrase" type="xsd:string"/> <xsd:attribute ref="xml:lang"/> <xsd:anyAttribute processContents="lax"/> </xsd:complexType>
<!-- error type which includes patch operation --> <xsd:complexType name="patch-error"> <xsd:sequence> <xsd:any namespace="##any" processContents="lax"/> </xsd:sequence> <xsd:attribute name="phrase" type="xsd:string"/> <xsd:attribute ref="xml:lang"/> <xsd:anyAttribute processContents="lax"/> </xsd:complexType>
</xsd:schema>
</xsd:schema>
IANA has completed the following actions:
IANA已完成以下操作:
o registered a new XML namespace URN according to the procedures of RFC 3688 [RFC3688].
o 根据RFC 3688[RFC3688]的过程注册了一个新的XML名称空间URN。
o registered a new MIME type 'application/patch-ops-error+xml' according to the procedures of RFC 4288 [RFC4288] and guidelines in RFC 3023 [RFC3023].
o 根据RFC 4288[RFC4288]的程序和RFC 3023[RFC3023]中的指南注册了新的MIME类型“应用程序/补丁操作错误+xml”。
o registered two XML Schemas according to the procedures of RFC 3688 [RFC3688].
o 根据RFC 3688[RFC3688]的过程注册了两个XML模式。
This specification registers a new XML namespace, as per the guidelines in RFC 3688 [RFC3688].
根据RFC 3688[RFC3688]中的指南,本规范注册了一个新的XML名称空间。
URI: The URI for this namespace is urn:ietf:params:xml:ns:patch-ops-error
URI: The URI for this namespace is urn:ietf:params:xml:ns:patch-ops-error
Registrant Contact: IETF, SIMPLE working group, (simple@ietf.org), Jari Urpalainen (jari.urpalainen@nokia.com).
注册人联系人:IETF,简单工作组(simple@ietf.org),Jari Urpalainen(Jari。urpalainen@nokia.com).
XML:
XML:
BEGIN <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/> <title>Patch-Ops Error Namespace</title> </head> <body> <h1>Namespace for Patch-Ops Error Documents</h1> <h2>urn:ietf:params:xml:ns:patch-ops-error</h2> <p>See <a href="http://www.rfc-editor.org/rfc/rfc5261.txt">RFC5261</a>.</p> </body> </html> END
BEGIN <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/> <title>Patch-Ops Error Namespace</title> </head> <body> <h1>Namespace for Patch-Ops Error Documents</h1> <h2>urn:ietf:params:xml:ns:patch-ops-error</h2> <p>See <a href="http://www.rfc-editor.org/rfc/rfc5261.txt">RFC5261</a>.</p> </body> </html> END
MIME media type name: application
MIME媒体类型名称:应用程序
MIME subtype name: patch-ops-error+xml
MIME子类型名称:修补程序操作错误+xml
Mandatory parameters: none
强制参数:无
Optional parameters: Same as charset parameter application/xml as specified in RFC 3023 [RFC3023].
可选参数:与RFC 3023[RFC3023]中指定的字符集参数application/xml相同。
Encoding considerations: Same as encoding considerations of application/xml as specified in RFC 3023 [RFC3023].
编码注意事项:与RFC 3023[RFC3023]中指定的应用程序/xml的编码注意事项相同。
Security considerations: See Section 10 of RFC 3023 [RFC3023].
安全注意事项:参见RFC 3023[RFC3023]第10节。
Interoperability considerations: none.
互操作性考虑:无。
Published specification: RFC 5261
已发布规范:RFC 5261
Applications which use this media type: This document type has been used to support transport of Patch-Ops errors in RFC 5261.
使用此媒体类型的应用程序:此文档类型已用于支持RFC 5261中补丁操作错误的传输。
Additional Information:
其他信息:
Magic Number: None
神奇数字:无
File Extension: .xer
文件扩展名:.xer
Macintosh file type code: "TEXT"
Macintosh文件类型代码:“文本”
Personal and email address for further information: Jari Urpalainen, jari.urpalainen@nokia.com
更多信息的个人和电子邮件地址:Jari Urpalainen,Jari。urpalainen@nokia.com
Intended usage: COMMON
预期用途:普通
Author/Change controller: The IETF
作者/变更控制者:IETF
This section registers a new XML Schema, the sole content of which is shown in Section 8.
本节注册了一个新的XML模式,其唯一内容如第8节所示。
URI: urn:ietf:params:xml:schema:patch-ops
URI: urn:ietf:params:xml:schema:patch-ops
Registrant Contact: IETF, SIMPLE working group, <simple@ietf.org> Jari Urpalainen, <jari.urpalainen@nokia.com>
Registrant Contact: IETF, SIMPLE working group, <simple@ietf.org> Jari Urpalainen, <jari.urpalainen@nokia.com>
This section registers a new XML Schema, the sole content of which is shown in Section 9.
本节注册了一个新的XML模式,其唯一内容如第9节所示。
URI: urn:ietf:params:xml:schema:patch-ops-error
URI: urn:ietf:params:xml:schema:patch-ops-error
Registrant Contact: IETF, SIMPLE working group, <simple@ietf.org> Jari Urpalainen, <jari.urpalainen@nokia.com>
Registrant Contact: IETF, SIMPLE working group, <simple@ietf.org> Jari Urpalainen, <jari.urpalainen@nokia.com>
Security considerations depend very much on the application that utilizes this framework. Since each application will have different needs, threat models, and security features, it will be necessary to consider these on an application-by-application basis.
安全考虑在很大程度上取决于使用此框架的应用程序。由于每个应用程序都有不同的需求、威胁模型和安全特性,因此有必要在应用程序的基础上考虑这些问题。
However, this framework utilizes a limited subset of XPath 1.0. Applications may thus be vulnerable to XPath injection attacks that can reveal some non-allowable content of an XML document. Injection attacks are most likely with shareable resources where access to a resource is limited to only some specific parts for a user, contrary to a typical use case of this framework. To defend against those attacks the input MUST be sanitized which can be done, for example, by validating the diff formats with these restrictive schemas.
但是,该框架使用XPath1.0的有限子集。因此,应用程序可能容易受到XPath注入攻击,这些攻击可能会泄露XML文档中某些不允许的内容。与此框架的典型用例相反,注入攻击最有可能发生在可共享资源中,其中用户对资源的访问仅限于某些特定部分。为了防御这些攻击,必须对输入进行消毒,这可以通过使用这些限制性模式验证diff格式来完成。
The author would like to thank Lisa Dusseault for her efforts including BoF arrangements, comments and editing assistance. The author would also like to thank Eva Leppanen, Mikko Lonnfors, Aki Niemi, Jonathan Rosenberg, Miguel A. Garcia, Anat Angel, Stephane Bortzmeyer, Dave Crocker, Joel Halpern, Jeffrey Hutzelman, David Ward, and Chris Newman for their valuable comments and Ted Hardie for his input and support.
作者要感谢Lisa Dusseault的努力,包括BoF安排、评论和编辑协助。作者还要感谢伊娃·莱普潘、米科·隆福斯、阿基·尼米、乔纳森·罗森博格、米格尔·加西亚、安纳特·安吉尔、斯蒂芬·博茨迈耶、戴夫·克罗克、乔尔·哈尔潘、杰弗里·哈泽尔曼、大卫·沃德和克里斯·纽曼的宝贵评论,以及泰德·哈代的投入和支持。
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,1997年3月。
[W3C.REC-xml-20060816] Maler, E., Paoli, J., Bray, T., Yergeau, F., and C. Sperberg-McQueen, "Extensible Markup Language (XML) 1.0 (Fourth Edition)", World Wide Web Consortium Recommendation REC-xml-20060816, August 2006, <http://www.w3.org/TR/2006/REC-xml-20060816>.
[W3C.REC-xml-20060816]Maler,E.,Paoli,J.,Bray,T.,Yergeau,F.,和C.Sperberg McQueen,“可扩展标记语言(xml)1.0(第四版)”,万维网联盟建议REC-xml-20060816,2006年8月<http://www.w3.org/TR/2006/REC-xml-20060816>.
[W3C.REC-xpath-19991116] DeRose, S. and J. Clark, "XML Path Language (XPath) Version 1.0", World Wide Web Consortium Recommendation REC-xpath-19991116, November 1999, <http://www.w3.org/TR/1999/REC-xpath-19991116>.
[W3C.REC-xpath-19991116]DeRose,S.和J.Clark,“XML路径语言(xpath)1.0版”,万维网联盟建议REC-xpath-19991116,1999年11月<http://www.w3.org/TR/1999/REC-xpath-19991116>.
[W3C.REC-xml-names-20060816] Hollander, D., Bray, T., Layman, A., and R. Tobin, "Namespaces in XML 1.0 (Second Edition)", World Wide Web Consortium Recommendation REC-xml-names-20060816, August 2006, <http://www.w3.org/TR/2006/REC-xml-names-20060816>.
[W3C.REC-xml-names-20060816]Hollander,D.,Bray,T.,Layman,A.,和R.Tobin,“xml 1.0中的名称空间(第二版)”,万维网联盟建议REC-xml-names-20060816,2006年8月<http://www.w3.org/TR/2006/REC-xml-names-20060816>.
[W3C.REC-xmlschema-1-20041028] Beech, D., Thompson, H., Maloney, M., and N. Mendelsohn, "XML Schema Part 1: Structures Second Edition", World Wide Web Consortium Recommendation REC-xmlschema-1-20041028, October 2004, <http://www.w3.org/TR/2004/REC-xmlschema-1-20041028>.
[W3C.REC-xmlschema-1-20041028]Beech,D.,Thompson,H.,Maloney,M.,和N.Mendelsohn,“XML模式第1部分:结构第二版”,万维网联盟建议REC-xmlschema-1-20041028,2004年10月<http://www.w3.org/TR/2004/REC-xmlschema-1-20041028>.
[W3C.REC-xml-c14n-20010315] Boyer, J., "Canonical XML Version 1.0", World Wide Web Consortium Recommendation REC-xml-c14n-20010315, March 2001, <http://www.w3.org/TR/2001/REC-xml-c14n-20010315>.
[W3C.REC-xml-c14n-20010315]Boyer,J.,“规范xml版本1.0”,万维网联盟建议REC-xml-c14n-20010315,2001年3月<http://www.w3.org/TR/2001/REC-xml-c14n-20010315>.
[W3C.REC-xmlschema-2-20041028] Malhotra, A. and P. Biron, "XML Schema Part 2: Datatypes Second Edition", World Wide Web Consortium Recommendation REC-xmlschema-2-20041028, October 2004, <http://www.w3.org/TR/2004/REC-xmlschema-2-20041028>.
[W3C.REC-xmlschema-2-20041028]Malhotra,A.和P.Biron,“XML模式第2部分:数据类型第二版”,万维网联盟建议REC-xmlschema-2-20041028,2004年10月<http://www.w3.org/TR/2004/REC-xmlschema-2-20041028>.
[W3C.WD-xml-id-20041109] Veillard, D., Walsh, N., and J. Marsh, "xml:id Version 1.0", W3C LastCall WD-xml-id-20041109, November 2004.
[W3C.WD-xml-id-20041109]Veillard,D.,Walsh,N.,和J.Marsh,“xml:id版本1.0”,W3C LastCall WD-xml-id-20041109,2004年11月。
[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, November 2003.
[RFC3629]Yergeau,F.,“UTF-8,ISO 10646的转换格式”,STD 63,RFC 3629,2003年11月。
[RFC3023] Murata, M., St. Laurent, S., and D. Kohn, "XML Media Types", RFC 3023, January 2001.
[RFC3023]Murata,M.,St.Laurent,S.,和D.Kohn,“XML媒体类型”,RFC 3023,2001年1月。
[RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, January 2004.
[RFC3688]Mealling,M.“IETF XML注册表”,BCP 81,RFC 3688,2004年1月。
[RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and Registration Procedures", BCP 13, RFC 4288, December 2005.
[RFC4288]Freed,N.和J.Klensin,“介质类型规范和注册程序”,BCP 13,RFC 4288,2005年12月。
[W3C.REC-xpath20-20070123] Berglund, A., Fernandez, M., Chamberlin, D., Boag, S., Robie, J., Kay, M., and J. Simeon, "XML Path Language (XPath) 2.0", World Wide Web Consortium Recommendation REC-xpath20-20070123, January 2007, <http://www.w3.org/TR/2007/REC-xpath20-20070123>.
[W3C.REC-xpath20-20070123]Berglund,A.,Fernandez,M.,Chamberlin,D.,Boag,S.,Robie,J.,Kay,M.,和J.Simeon,“XML路径语言(XPath)2.0”,万维网联盟建议REC-xpath20-20070123,2007年1月<http://www.w3.org/TR/2007/REC-xpath20-20070123>.
[RFC4825] Rosenberg, J., "The Extensible Markup Language (XML) Configuration Access Protocol (XCAP)", RFC 4825, May 2007.
[RFC4825]Rosenberg,J.,“可扩展标记语言(XML)配置访问协议(XCAP)”,RFC4825,2007年5月。
[RFC3265] Roach, A., "Session Initiation Protocol (SIP)-Specific Event Notification", RFC 3265, June 2002.
[RFC3265]Roach,A.,“会话启动协议(SIP)-特定事件通知”,RFC3265,2002年6月。
[RFC5262] Lonnfors, M., Leppanen, E., Khartabil, H., and J. Urpalainen, "Presence Information Data format (PIDF) Extension for Partial Presence", RFC 5262, September 2008.
[RFC5262]Lonnfors,M.,Leppanen,E.,Khartabil,H.,和J.Urpalainen,“部分存在的存在信息数据格式(PIDF)扩展”,RFC 5262,2008年9月。
[SIMPLE-XCAP] Urpalainen, J. and J. Rosenberg, "An Extensible Markup Language (XML) Document Format for Indicating A Change in XML Configuration Access Protocol (XCAP) Resources", Work in Progress, May 2008.
[SIMPLE-XCAP]Urpalainen,J.和J.Rosenberg,“用于指示XML配置访问协议(XCAP)资源更改的可扩展标记语言(XML)文档格式”,正在进行的工作,2008年5月。
[RFC3903] Niemi, A., Ed., "Session Initiation Protocol (SIP) Extension for Event State Publication", RFC 3903, October 2004.
[RFC3903]Niemi,A.,编辑,“事件状态发布的会话启动协议(SIP)扩展”,RFC 3903,2004年10月。
All following examples assume an imaginary XML diff document including these patch operation elements.
以下所有示例都假设一个虚构的XML diff文档,其中包含这些补丁操作元素。
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc"><foo id="ert4773">This is a new child</foo></add> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc"><foo id="ert4773">This is a new child</foo></add> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc/foo[@id='ert4773']" type="@user">Bob</add> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc/foo[@id='ert4773']" type="@user">Bob</add> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773" user="Bob">This is a new child</foo></doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773" user="Bob">This is a new child</foo></doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc" type="namespace::pref">urn:ns:xxx</add> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc" type="namespace::pref">urn:ns:xxx</add> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:ns:xxx"> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:ns:xxx"> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <foo id="ert4773">This is a new child</foo></doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc/foo[@id='ert4773']" pos="before"><!-- comment --></add> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc/foo[@id='ert4773']" pos="before"><!-- comment --></add> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <!-- comment --><foo id="ert4773">This is a new child</foo></doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> <!-- comment --><foo id="ert4773">This is a new child</foo></doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc"> <foo id="ert4773">This is a new child</foo></add> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <add sel="doc"> <foo id="ert4773">This is a new child</foo></add> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note>
<?xml version="1.0" encoding="UTF-8"?> <doc> <note>This is a sample document</note>
<foo id="ert4773">This is a new child</foo></doc>
<foo id="ert4773">This is a new child</foo></doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/foo[@a='1']"><bar a="2"/></replace> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/foo[@a='1']"><bar a="2"/></replace> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <bar a="2"/> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <bar a="2"/> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc a="test"> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc a="test"> <foo a="1">This is a sample document</foo> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/@a">new value</replace> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/@a">new value</replace> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc a="new value"> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc a="new value"> <foo a="1">This is a sample document</foo> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:test"> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:test"> <foo a="1">This is a sample document</foo> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/namespace::pref">urn:new:xxx</replace> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/namespace::pref">urn:new:xxx</replace> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:new:xxx"> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:new:xxx"> <foo a="1">This is a sample document</foo> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:test"> <foo a="1">This is a sample document</foo> <!-- comment --> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:test"> <foo a="1">This is a sample document</foo> <!-- comment --> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/comment()[1]"><!-- This is the new content --></replace> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/comment()[1]"><!-- This is the new content --></replace> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:test"> <foo a="1">This is a sample document</foo> <!-- This is the new content --> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns:pref="urn:test"> <foo a="1">This is a sample document</foo> <!-- This is the new content --> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <?test foo="bar"?> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <?test foo="bar"?> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel='doc/processing-instruction("test")' ><?test bar="foobar"?></replace> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel='doc/processing-instruction("test")' ><?test bar="foobar"?></replace> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <?test bar="foobar"?> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <?test bar="foobar"?> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/foo/text()[1]" >This is the new text content</replace></diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <replace sel="doc/foo/text()[1]" >This is the new text content</replace></diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is the new text content</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is the new text content</foo> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/foo[@a='1']" ws="after"/> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/foo[@a='1']" ws="after"/> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc a="foo"> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc a="foo"> <foo a="1">This is a sample document</foo> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/@a"/> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/@a"/> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1" xmlns:pref="urn:test" >This is a sample document</foo> <!-- comment --> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1" xmlns:pref="urn:test" >This is a sample document</foo> <!-- comment --> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/foo/namespace::pref"/> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/foo/namespace::pref"/> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <!-- comment --> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <!-- comment --> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <!-- comment --> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <!-- comment --> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/comment()[1]" ws="after"/> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/comment()[1]" ws="after"/> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <?test?> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> <?test?> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel='doc/processing-instruction("test")'/> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel='doc/processing-instruction("test")'/> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
An example target XML document:
一个示例目标XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1">This is a sample document</foo> </doc>
An XML diff document:
XML差异文档:
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/foo/text()[1]"/> </diff>
<?xml version="1.0" encoding="UTF-8"?> <diff> <remove sel="doc/foo/text()[1]"/> </diff>
A result XML document:
结果XML文档:
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1"/> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc> <foo a="1"/> </doc>
An example target XML document where namespace qualified elements exist:
存在命名空间限定元素的目标XML文档示例:
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns="urn:ietf:params:xml:ns:xxx" xmlns:z="urn:ietf:params:xml:ns:yyy"> <note>This is a sample document</note> <elem a="foo"> <child/> </elem> <elem a="bar"> <z:child/> </elem> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns="urn:ietf:params:xml:ns:xxx" xmlns:z="urn:ietf:params:xml:ns:yyy"> <note>This is a sample document</note> <elem a="foo"> <child/> </elem> <elem a="bar"> <z:child/> </elem> </doc>
An imaginary XML diff document where prefix "p" corresponds the targetNamespace of this imaginary schema:
一个虚构的XML diff文档,其中前缀“p”对应于此虚构架构的targetNamespace:
<?xml version="1.0" encoding="UTF-8"?> <p:diff xmlns="urn:ietf:params:xml:ns:xxx" xmlns:y="urn:ietf:params:xml:ns:yyy" xmlns:p="urn:ietf:params:xml:ns:diff">
<?xml version="1.0" encoding="UTF-8"?> <p:diff xmlns="urn:ietf:params:xml:ns:xxx" xmlns:y="urn:ietf:params:xml:ns:yyy" xmlns:p="urn:ietf:params:xml:ns:diff">
<p:add sel="doc/elem[@a='foo']"> <!-- This is a new child --> <child id="ert4773"> <y:node/> </child> </p:add>
<p:add sel="doc/elem[@a='foo']"> <!-- This is a new child --> <child id="ert4773"> <y:node/> </child> </p:add>
<p:replace sel="doc/note/text()">Patched doc</p:replace>
<p:replace sel="doc/note/text()">Patched doc</p:replace>
<p:remove sel="*/elem[@a='bar']/y:child" ws="both"/>
<p:remove sel="*/elem[@a='bar']/y:child" ws="both"/>
<p:add sel="*/elem[@a='bar']" type="@b">new attr</p:add>
<p:add sel="*/elem[@a='bar']" type="@b">new attr</p:add>
</p:diff>
</p:diff>
One possible form of the result XML document after applying the patches:
应用修补程序后结果XML文档的一种可能形式:
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns="urn:ietf:params:xml:ns:xxx" xmlns:z="urn:ietf:params:xml:ns:yyy"> <note>Patched doc</note> <elem a="foo"> <child/> <!-- This is a new child --> <child id="ert4773"> <z:node/> </child> </elem> <elem a="bar" b="new attr"/> </doc>
<?xml version="1.0" encoding="UTF-8"?> <doc xmlns="urn:ietf:params:xml:ns:xxx" xmlns:z="urn:ietf:params:xml:ns:yyy"> <note>Patched doc</note> <elem a="foo"> <child/> <!-- This is a new child --> <child id="ert4773"> <z:node/> </child> </elem> <elem a="bar" b="new attr"/> </doc>
The <node> and removed <child> element prefixes within the XML diff document are different than what are the "identical" namespace declarations in the target XML document. If the target XML document had used a prefixed namespace declaration instead of the default one, the XML diff document could still have been the same. The added new qualified elements would just have inherited that prefix.
XML diff文档中的<node>和removed<child>元素前缀与目标XML文档中的“相同”名称空间声明不同。如果目标XML文档使用了前缀名称空间声明而不是默认名称空间声明,则XML diff文档可能仍然是相同的。添加的新限定元素将继承该前缀。
Author's Address
作者地址
Jari Urpalainen Nokia Itamerenkatu 11-13 Helsinki 00180 Finland
芬兰赫尔辛基乌尔帕莱宁诺基亚伊塔梅伦卡图11-13 00180
Phone: +358 7180 37686 EMail: jari.urpalainen@nokia.com
Phone: +358 7180 37686 EMail: jari.urpalainen@nokia.com
Full Copyright Statement
完整版权声明
Copyright (C) The IETF Trust (2008).
版权所有(C)IETF信托基金(2008年)。
This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights.
本文件受BCP 78中包含的权利、许可和限制的约束,除其中规定外,作者保留其所有权利。
This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
本文件及其包含的信息以“原样”为基础提供,贡献者、他/她所代表或赞助的组织(如有)、互联网协会、IETF信托基金和互联网工程任务组不承担任何明示或暗示的担保,包括但不限于任何保证,即使用本文中的信息不会侵犯任何权利,或对适销性或特定用途适用性的任何默示保证。
Intellectual Property
知识产权
The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79.
IETF对可能声称与本文件所述技术的实施或使用有关的任何知识产权或其他权利的有效性或范围,或此类权利下的任何许可可能或可能不可用的程度,不采取任何立场;它也不表示它已作出任何独立努力来确定任何此类权利。有关RFC文件中权利的程序信息,请参见BCP 78和BCP 79。
Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr.
向IETF秘书处披露的知识产权副本和任何许可证保证,或本规范实施者或用户试图获得使用此类专有权利的一般许可证或许可的结果,可从IETF在线知识产权存储库获取,网址为http://www.ietf.org/ipr.
The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf-ipr@ietf.org.
IETF邀请任何相关方提请其注意任何版权、专利或专利申请,或其他可能涵盖实施本标准所需技术的专有权利。请将信息发送至IETF的IETF-ipr@ietf.org.