For faster navigation, this Iframe is preloading the Wikiwand page for 限定名.

限定名

合法名(英語:QNames),又譯限定名,是XML命名空间引入的概念,用来作为URI引用。[1] 其名稱來自於英語:qualified name(意为合法的名字)定义了元素和属性的合法的标识符。合法名通常在XML文档中用作特定元素或属性的引用。

合法名原称限定名,因与XML命名空间[2]中的表述有冲突,并且qualified译为合法也是合理的,因此对其进行了编辑。

[3]

动机

[编辑]

由于URI引用可能会很长并且可能包含XML元素/属性命名中禁止的字符,因此,需要建立命名空间缩写到URI之间的映射,这样可以在XML元素/属性名中使用命名空间的缩写,这样就可以更加方便地书写XML文档。这种使用命名空间缩写的方法来给XML元素/属性命名的方式,即为“合法名”命名(参见示例)。

形式化定义

[编辑]

万维网联盟给出的合法名的形式化定义如下[4]

  QName ::= PrefixedName | UnprefixedName
  
  PrefixedName   ::= Prefix ':' LocalPart
  UnprefixedName ::= LocalPart

其中Prefix(前缀)是名字空间的一个符号,而LocalPart是限定名的本地部分。本地部分可以是属性名或元素名。

维基百科“XML名字空间”词条,将合法名具体分为如下两种[2]: XML文档中的元素名和属性名可以使用限定名或非限定名,限定名由命名空间的前缀和局部名组合而成,例如"xhtml:hr"。非限定名只有局部名,没有前缀。非限定名被认为属于缺省命名空间,如果缺省命名空间没有定义,则属于无命名空间。 限定名即对应上例中的PrefixedName。非限定名即对应上例中的UnprefixedName。

示例

[编辑]
  <?xml version='1.0'?>
  <doc xmlns:x="http://example.com/ns/foo">
    <x:p/>
  </doc>

在第二行中,前缀“x”被声明与URI"http://example.com/ns/foo"相关联。这个前缀后面可用作名字空间的缩写。后面的标签“x:p”是一个限定名,“x”是命名空间引用,“p”是本地部分。而标签“doc”也是一个非限定名,仅包含本地部分。它们都属于合法名。[5]

参见

[编辑]
  • CURIE:紧凑的URI
  • 全限定名

参考文献

[编辑]
  1. ^ Namespaces in XML 1.0 (Second Edition). [2011-03-08]. (原始内容存档于2011-03-16). 
  2. ^ 2.0 2.1 存档副本. [2014-06-27]. (原始内容存档于2014-07-02). 
  3. ^ Using Qualified Names (QNames) as Identifiers in XML Content. [2011-03-08]. (原始内容存档于2011-09-05). 
  4. ^ Namespaces in XML 1.0 (Second Edition). [2011-03-08]. (原始内容存档于2011-03-16). 
  5. ^ Namespaces in XML 1.0 (Second Edition). [2011-03-08]. (原始内容存档于2011-03-16). 
{{bottomLinkPreText}} {{bottomLinkText}}
限定名
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?