Xml 架构:空的 targetNamespace [英] Xml schema: empty targetNamespace

查看:27
本文介绍了Xml 架构:空的 targetNamespace的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Xml 模式中不使用 targetNamespace 属性或使用空属性是否合法?

Is it legal to use no targetNamespace attribute or an empty one in an Xml schema?

如果是这样,那么这意味着什么,我们是在空命名空间"(始终存在)中添加"一些东西,还是创建一个与其他架构无关的匿名命名空间"?

If so then what does it mean, are we "adding" something to the "empty namespace" (which always exists) or creating an "anonymous namespace" which is not related to other schemas?

实例 xml 文档会是什么样子,元素是否需要显式绑定到某个命名空间?

How would an instance xml document look like, do elements need to be explicitly bounded to some namespace?

推荐答案

参见 XML Schema第 0 部分:入门,非常简洁地描述了未声明的 targetNamespaces 如何工作.

See XML Schema Part 0: Primer for a very concise description of how undeclared targetNamespaces work.

对于空的 targetNamespace,这是无效的.来自规范:

As for an empty targetNamespace, that's not valid. From the spec:

由于空字符串不是合法的命名空间名称,因此为 targetNamespace 提供空字符串是不连贯的,与根本不指定它是不一样的.对应于其组件没有{目标名称空间}的·架构·的架构文档的适当形式是完全没有指定 targetNamespace 属性的一种.

Since the empty string is not a legal namespace name, supplying an empty string for targetNamespace is incoherent, and is not the same as not specifying it at all. The appropriate form of schema document corresponding to a ·schema· whose components have no {target namespace} is one which has no targetNamespace attribute specified at all.

这篇关于Xml 架构:空的 targetNamespace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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