XML 规范化词典排序
XML Canonicalization lexicographical ordering
这里有 XML 规范化的官方测试用例:Test cases for Canonical XML 2.0
其中一个看起来像这样:
<!DOCTYPE doc [<!ATTLIST e9 attr CDATA "default">]>
<doc>
<e1 />
<e2 ></e2>
<e3 name = "elem3" id="elem3" />
<e4 name="elem4" id="elem4" ></e4>
<e5 a:attr="out" b:attr="sorted" attr2="all" attr="I'm"
xmlns:b="http://www.ietf.org"
xmlns:a="http://www.w3.org"
xmlns="http://example.org"/>
<e6 xmlns="" xmlns:a="http://www.w3.org">
<e7 xmlns="http://www.ietf.org">
<e8 xmlns="" xmlns:a="http://www.w3.org">
<e9 xmlns="" xmlns:a="http://www.ietf.org"/>
</e8>
</e7>
</e6>
</doc>
给定的规范化形式是
<doc>
<e1></e1>
<e2></e2>
<e3 id="elem3" name="elem3"></e3>
<e4 id="elem4" name="elem4"></e4>
<e5 xmlns="http://example.org" xmlns:a="http://www.w3.org" xmlns:b="http://www.ietf.org" attr="I'm" attr2="all" b:attr="sorted" a:attr="out"></e5>
<e6>
<e7 xmlns="http://www.ietf.org">
<e8 xmlns="">
<e9 attr="default"></e9>
</e8>
</e7>
</e6>
</doc>
我想知道为什么 b:attr="sorted"
在排序输出中出现在 a:attr="out"
之前...如果有人能为我澄清这一点,我将非常感激。
不要看命名空间前缀;查看名称空间 URI。
虽然a
在b
之前,i
在w
之前:
xmlns:b="http://www.ietf.org"
xmlns:a="http://www.w3.org"
因此 b:attr="sorted"
规范地排在 a:attr="out"
之前。
这在section 2.3中有解释:
Note: In e5
, b:attr
precedes a:attr
because the primary key is namespace URI not namespace prefix
这里有 XML 规范化的官方测试用例:Test cases for Canonical XML 2.0
其中一个看起来像这样:
<!DOCTYPE doc [<!ATTLIST e9 attr CDATA "default">]>
<doc>
<e1 />
<e2 ></e2>
<e3 name = "elem3" id="elem3" />
<e4 name="elem4" id="elem4" ></e4>
<e5 a:attr="out" b:attr="sorted" attr2="all" attr="I'm"
xmlns:b="http://www.ietf.org"
xmlns:a="http://www.w3.org"
xmlns="http://example.org"/>
<e6 xmlns="" xmlns:a="http://www.w3.org">
<e7 xmlns="http://www.ietf.org">
<e8 xmlns="" xmlns:a="http://www.w3.org">
<e9 xmlns="" xmlns:a="http://www.ietf.org"/>
</e8>
</e7>
</e6>
</doc>
给定的规范化形式是
<doc>
<e1></e1>
<e2></e2>
<e3 id="elem3" name="elem3"></e3>
<e4 id="elem4" name="elem4"></e4>
<e5 xmlns="http://example.org" xmlns:a="http://www.w3.org" xmlns:b="http://www.ietf.org" attr="I'm" attr2="all" b:attr="sorted" a:attr="out"></e5>
<e6>
<e7 xmlns="http://www.ietf.org">
<e8 xmlns="">
<e9 attr="default"></e9>
</e8>
</e7>
</e6>
</doc>
我想知道为什么 b:attr="sorted"
在排序输出中出现在 a:attr="out"
之前...如果有人能为我澄清这一点,我将非常感激。
不要看命名空间前缀;查看名称空间 URI。
虽然a
在b
之前,i
在w
之前:
xmlns:b="http://www.ietf.org"
xmlns:a="http://www.w3.org"
因此 b:attr="sorted"
规范地排在 a:attr="out"
之前。
这在section 2.3中有解释:
Note: In
e5
,b:attr
precedesa:attr
because the primary key is namespace URI not namespace prefix