xmlns到底做了什么? [英] what does xmlns do exactly?

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

问题描述

我看过XMLNS的定义。还有一个问题。


如果为命名空间定义两个不同的''xmlns''怎么办?


ex)


< nsa:aelement xmlns:nsa =" a">

< nsa:aelement xmlns:nsa =" b">

< / nsa:aelement>

< / nsa:aelement>


有可能吗?并且这两个元素完全不同

元素?

解决方案

如果我定义两个不同的'命名空间的'xmlns''?


< nsa:aelement xmlns:nsa =" a">

< nsa:aelement xmlns:nsa =" b">

< / nsa:aelement>

< / nsa:aelement>



命名空间前缀绑定是作用域的。引用nsa:前缀的外部

元素的后代理解它意味着

命名空间a,除了被另一个定义覆盖的地方

你在这里完成了。在这个例子中,内部元素及其所有

后代理解nsa:表示命名空间b。


请记住,前缀只是一个句法速记。真正包含的内容

含义是前缀绑定的URI与前缀后面的

localname的组合。


警告:这些名称空间名称不是很好。根据W3C,命名空间名称应该是

绝对URI引用。如果您打算使用

简短而邋,,在一个例子中,您至少应该使用

" http:// a或类似的东西。 (在W3C中有一个关于

的重大争论,原因是命名空间规范的第一个

草案中的草率措辞和对是否存在的模糊思考

是解释相对名称空间的有用方法。决定是否使用相对名称空间URI来弃用相对名称空间URI,除非有人

说服W3C它们既实用又实用。)


>

有可能吗?这两个元素完全不同

元素?



-

Joe Kesselman /小心愤怒一个耐心的人。 - John Dryden


顺便说一下,XML中的命名空间和规范,可以从

W3C的网站上获得,它说明了命名空间范围的工作原理。


在文章< 45819442中

i''ve looked XMLNS definition. and still have a question.

what if i define two defferent ''xmlns'' for a namespace?

ex)

<nsa:aelement xmlns:nsa="a">
<nsa:aelement xmlns:nsa="b">
</nsa:aelement>
</nsa:aelement>

is it possible? and those two elements work as totaly different
elements?

解决方案

what if i define two defferent ''xmlns'' for a namespace?

<nsa:aelement xmlns:nsa="a">
<nsa:aelement xmlns:nsa="b">
</nsa:aelement>
</nsa:aelement>

Namespace prefix bindings are scoped. The descendants of the outer
element which reference the nsa: prefix understand it to mean the
namespace "a", EXCEPT where that''s overridden by another definition as
you''ve done here. In this example the inner element and all its
descendants understand nsa: to mean the namespace "b".

Remember, the prefix is just a syntactic shorthand. What really carries
meaning is the combination of the URI the prefix is bound to plus the
localname following the prefix.

WARNING: These are NOT good namespace names. Namespace names should be
absolute URI references, according to the W3C. If you''re going to use
something short and sloppy, in an example, you should at least use
"http://a" or something of that sort. (There was a major debate about
this in the W3C, due to a combination of sloppy wording in the first
draft of the namespace spec and some fuzzy thinking about whether there
was any useful way to interpret relative namespaces. The decision was
made to deprecate relative namespace URIs until and unless someone
convinces the W3C that they are both necessary and practical.)

>
is it possible? and those two elements work as totaly different
elements?


--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden


By the way, the "Namespaces in XML" specification, available from the
W3C''s website, does spell out how namespace scoping works.


In article <45819442


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

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