XML-为什么相对名称空间被认为是无效的? [英] XML - Why are relative namespaces considered to be invalid?

查看:210
本文介绍了XML-为什么相对名称空间被认为是无效的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段要尝试签名的XML,然后验证使用相对名称空间的XML:

I have a piece of XML that I am attempting to sign then verify which uses relative namespaces:

<Organization>
  <OrganizationName xmlns:_xml="xml" _xml:lang="en">name</OrganizationName>
  <OrganizationDisplayName xmlns:_xml="xml" _xml:lang="en">name</OrganizationDisplayName>
  <OrganizationURL xmlns:_xml="xml" _xml:lang="en">http://www.example.com/</OrganizationURL>
</Organization>

OpenSAML引发以下异常:

OpenSAML throws the following exception:

org.apache.xml.security.c14n.CanonicalizationException:元素 OrganizationName具有相对名称空间:_xml ="xml"

org.apache.xml.security.c14n.CanonicalizationException: Element OrganizationName has a relative namespace: _xml="xml"

为什么相对名称空间被认为是不好的?解析器肯定可以在解析真实值时解析名称空间吗?

Why are relative namespaces considered bad? Surely the parser could just resolve the namespace when parsing the true value?

找到了更多信息

2.2部分中的 XML 1.1中的命名空间文档指出:

The Namespaces in XML 1.1 document states under section 2.2:

此相对URI引用的弃用由W3C决定 XML全会投票[相对URI弃用].它还宣布 后来的规范,例如DOM,XPath等,将不会定义 为他们解释".

This deprecation of relative URI references was decided on by a W3C XML Plenary Ballot [Relative URI deprecation]. It also declares that "later specifications such as DOM, XPath, etc. will define no interpretation for them".

这是在有关URI引用的投票上投票赞成的.

This was voted for on the Ballot on relative URI References.

推荐答案

在敲定名称空间规范时,有两种思路:一组认为名称空间名称应仅是名称(字符串)只是出于唯一性而选择),另一个小组认为应该识别Web上的一些资源,以提供对名称空间内容的描述:可能是模式,可能是其他.现在,如果只是一个字符串,那么任何字符串都可以.但是,如果它是资源的位置,那么您将期望相对引用将针对出现该元素的元素的基本URI进行解析.此时,这两种思想流派之间没有妥协的余地,W3C决定不赞成使用一个或另一个组,而是决定不允许将相对URI作为名称空间名称-除非为时已晚,否则不允许它们,因此已弃用.

When the namespaces spec was being hammered out, there were two schools of thought: one group thought that a namespace name should just be a name (a string of characters chosen simply for uniqueness), the other group thought that it should identify some resource on the web providing a description of the contents of the namespace: perhaps a schema, perhaps something else. Now, if it's just a string of characters, then any string will do. But if it's the location of a resource, then you would expect a relative reference to be resolved against the base URI of the element where it appears. At this point there was no room for compromise between the two schools of thought, and rather than deciding in favour of one group or the other, W3C decided that relative URIs as namespace names should not be allowed - except it was too late to disallow them, so they were deprecated instead.

这篇关于XML-为什么相对名称空间被认为是无效的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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