targetNamespace 和 xmlns:target 有什么区别? [英] What is the difference between targetNamespace and xmlns:target?

查看:28
本文介绍了targetNamespace 和 xmlns:target 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

targetNamespace 的作用是什么?

<schema xmlns="http://www.w3.org/2001/SchemaXML"
        targetNamespace="http://www.example.com/name"
        xmlns:target="http://www.example.com/name">

我了解 xmlns="http://www.w3.org/2001/SchemaXML 定义了 Schema XML 命名空间.

I understand that xmlns="http://www.w3.org/2001/SchemaXML defines the Schema XML namespace.

我也明白 xmlns:target="http://www.example.com/name" 为我自己的词汇定义命名空间,如果我使用前缀目标";这充当 URI http://www.example.com/name 的代理或占位符.

I also understand that xmlns:target="http://www.example.com/name" defines the namespace for my own vocabulary if I'm creating my own schema using the prefix "target"; this acts as a proxy or placeholder for the URI http://www.example.com/name.

这似乎足以定义命名空间参与者所需的边界和词汇.那么为什么我需要一个 targetNamespace 属性来复制 http://www.example.com/name 命名空间?

That seems like enough to define the needed boundries and vocabularies of namespace participants. So why do I need a targetNamespace attribute which duplicates the http://www.example.com/name namespace?

推荐答案

在这里回答得很好:targetNamespace 和没有前缀的xmlns,有什么区别?

重申:

  • targetNamespace="" - 由于当前 XML 文档是一个架构,因此该属性定义了该架构旨在定位或验证的命名空间.

  • targetNamespace="" - As the current XML document is a schema this attribute defines the namespace that this schema is intended to target, or validate.

xmlns="" - 为所有非前缀元素定义当前文档中的默认命名空间(即 < 中没有 yada:yada:elementName>)

xmlns="" - Defines the default namespace within the current document for all non-prefixed elements (i.e no yada: in <yada:elementName>)

xmlns:target="" - 在这里您只是使用前缀 target: 定义自己的命名空间,这与前两个特殊情况无关.

xmlns:target="" - here you are just defining your own namespace with the prefix target:, this is unrelated to the previous two special cases.

这篇关于targetNamespace 和 xmlns:target 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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