日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

什么是QName

 yliu277 2019-07-21

看代碼時經(jīng)常碰到QName,當時對這個東東具體什么意思也是不太明白;今天在看SOAP消息的時候,想到這個東東,就去仔細看了下。QName其實就是Qualified Name的簡稱,在“NameSpaces in XML1.0(Third Edition)”(http://www./TR/REC-xml-names/#ns-qualnames)中有如下這段話:

URI references can contain characters not allowed in names, and are often inconveniently long, so expanded names are not used directly to name elements and attributes in XML documents. Instead qualified names are used. [Definition: A qualified name is a name subject to namespace interpretation. ] In documents conforming to this specification, element and attribute names appear as qualified names. Syntactically, they are either prefixed names or unprefixed names.

同時文中對QName的定義如下:

In XML documents conforming to this specification, some names (constructs corresponding to the nonterminal Name) MUST be given as qualified names,defined as follows:

Qualified Name

[7]    QName    ::=    PrefixedName
      | UnprefixedName
[8]    PrefixedName    ::=    Prefix ':' LocalPart
[9]    UnprefixedName    ::=    LocalPart
[10]    Prefix    ::=    NCName
[11]    LocalPart    ::=    NCName

The Prefix provides the namespace prefix part of the qualified name, and MUST be associated with a namespace URI reference in a namespace declaration. [Definition: The LocalPart provides the local part of the qualified name.]

Note that the prefix functions only as a placeholder for a namespace name. Applications SHOULD use the namespace name, not the prefix, in constructing names whose scope extends beyond the containing document.

In XML documents conforming to this specification, element names are given as qualified names;

Attributes are either namespace declarations or their names are given as qualified names.

也就是說QName分為兩種,一種是帶前綴的名字,另一種是不帶前綴的。若是帶前綴,則前綴必須和命名空間的URI引用相關(guān)聯(lián),如

<namespace-prefix:envelope xmlns:namespace-prefix='namespaceURI'> ... </namespace-prefix:envelope>,其中<namespace-prefix:envelope>就是QName;不帶前綴,也就是說xml文件使用的默認命名空間,如<rootElement xmlns='namespaceURI'> ... </rootElement>,這里<rootElement>就是QName;在xml文件中,元素和屬性都是用QName表示的;

如果應(yīng)用程序在構(gòu)造QName的時候,同時這個QName的范圍超過了其被包含的xml文檔,比如應(yīng)用程序是Java或C#程序,那么在構(gòu)造QName的時候就需要使用命名空間,而不是前綴,QName可以看做是一個包含了命名空間和local part的二元組,如(namespace, local name).

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多