⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x5295.htm

📁 Its a xmpp protocol book
💻 HTM
字号:
<HTML
><HEAD
><TITLE
>Namespace usage</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REL="HOME"
TITLE="Programming Jabber"
HREF="book1.htm"><LINK
REL="UP"
TITLE="Jabber Namespaces"
HREF="c5281.htm"><LINK
REL="PREVIOUS"
TITLE="Jabber Namespaces"
HREF="c5281.htm"><LINK
REL="NEXT"
TITLE="The IQ Namespaces"
HREF="x5334.htm"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Programming Jabber</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c5281.htm"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 5a. Jabber Namespaces</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x5334.htm"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="JABTDG-CH-5A-SECT-1"
>Namespace usage</A
></H1
><P
>In the previous chapter, we made quite a few
references to <I
CLASS="EMPHASIS"
>namespaces</I
>. Jabber's namespaces are used
within the message elements to qualify payloads (distinct content) within
these elements. For example:</P
><P
><PRE
CLASS="SCREEN"
>RECV: &#60;iq id='roster_0' type='result' from='dj@yak/Work'&#62;
        &#60;query <TT
CLASS="USERINPUT"
><B
>xmlns='jabber:iq:roster'</B
></TT
>&#62;
          &#60;item jid='sabine@yak' name='sabine' subscription='both'&#62;
            &#60;group&#62;Family&#60;/group&#62;
          &#60;/item&#62;
        &#60;/query&#62;
      &#60;/iq&#62;</PRE
></P
><P
>Here the <TT
CLASS="LITERAL"
>jabber:iq:roster</TT
> namespace is
being used to qualify a chunk of XML that contains roster information
embedded in an <TT
CLASS="LITERAL"
>&#60;iq/&#62;</TT
> element.
A payload exists as a subelement of the main element
(that is, a child tag of the parent
<TT
CLASS="LITERAL"
>&#60;message/&#62;</TT
>,
<TT
CLASS="LITERAL"
>&#60;presence/&#62;</TT
> or
<TT
CLASS="LITERAL"
>&#60;iq/&#62;</TT
> tag) and, in
XML terms, belongs to a different namespace than the main element.</P
><P
>The namespace of the <I
CLASS="EMPHASIS"
>main</I
>
elements in the XML document that is streamed across the
connection&mdash;<TT
CLASS="LITERAL"
>&#60;message/&#62;</TT
>, 
<TT
CLASS="LITERAL"
>&#60;presence/&#62;</TT
>, and 
<TT
CLASS="LITERAL"
>&#60;iq/&#62;</TT
>, and indeed their "standard"
subelements, such as <TT
CLASS="LITERAL"
>&#60;message/&#62;</TT
>'s
<TT
CLASS="LITERAL"
>&#60;subject/&#62;</TT
> tag&mdash;is defined in the
root tag of the XML document, and in this case is 
<TT
CLASS="LITERAL"
>jabber:client</TT
>. Namespaces like
<TT
CLASS="LITERAL"
>jabber:client</TT
> that are  used to qualify
such XML document body fragments are described in
<A
HREF="x3837.htm#JABTDG-CH-5-SECT-5.3.2"
>the section called <I
>The Opening Tag</I
> in Chapter 5</A
>. While the main elements
in our client to server connection are qualified by
<TT
CLASS="LITERAL"
>jabber:client</TT
>, each
distinct payload (&ldquo;attachment&rdquo; is also a good way to think of
these additional chunks of XML) is qualified by one of the specific
namespaces listed in this Chapter.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-5A-SECT-1.1"
>Jabber namespace naming rules</A
></H2
><P
>Standard Jabber namespaces begin
<TT
CLASS="LITERAL"
>jabber:</TT
>; however, there are a few exceptions. It could be argued that the exceptions aren't really Jabber standard since these are the namespaces that describe things like vCards and XHTML payloads.
There's nothing to stop you from defining your own namespaces to qualify
any sort of XML you'd like to attach to a Jabber element. The only
rule is that if you do, it <I
CLASS="EMPHASIS"
>shouldn't</I
> begin with
<TT
CLASS="LITERAL"
>jabber:</TT
>.</P
><P
>Further to the rule that Jabber standard namespaces begin with
<TT
CLASS="LITERAL"
>jabber:</TT
>, the categorization can be
seen as falling into two distinct spaces. The first, the <TT
CLASS="LITERAL"
>iq</TT
> space,
contains namespaces that qualify content within
<TT
CLASS="LITERAL"
>&#60;iq/&#62;</TT
>-based conversations.
The second, the <TT
CLASS="LITERAL"
>x</TT
> space, contains namespaces that qualify extensions
within all the elements (<TT
CLASS="LITERAL"
>&#60;message/&#62;</TT
>, <TT
CLASS="LITERAL"
>&#60;iq/&#62;</TT
>, and
<TT
CLASS="LITERAL"
>&#60;presence/&#62;</TT
>).</P
><P
></P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c5281.htm"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x5334.htm"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Jabber Namespaces</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c5281.htm"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>The IQ Namespaces</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -