`
iluoxuan
  • 浏览: 571938 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

XMPP -- 0055 search

 
阅读更多

XEP-0055: Jabber Search

Abstract: This specification provides canonical documentation of the jabber:iq:search namespace currently in use within the Jabber community.
Author: Peter Saint-Andre
Copyright: © 1999 - 2013 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status: Active
Type: Historical
Version: 1.3
Last Updated: 2009-09-15

NOTICE: This Historical specification provides canonical documentation of a protocol that is in use within the Jabber/XMPP community. This document is not a standards-track specification within the XMPP Standards Foundation's standards process; however, it might be converted to standards-track in the future or might be obsoleted by a more modern protocol.


Table of Contents


1. Introduction

This specification documents a protocol currently used to search information repositories on the Jabber network. To date, the jabber:iq:search protocol has been used mainly to search for people who have registered with user directories (e.g., the "Jabber User Directory" hosted at users.jabber.org). However, the jabber:iq:search protocol is not limited to user directories, and could be used to search other Jabber information repositories (such as chatroom directories) or even to provide a Jabber interface to conventional search engines.

The basic functionality is to query an information repository regarding the possible search fields, to send a search query, and to receive search results. Note well that there is currently no mechanism for paging through results or limiting the number of "hits", and that the allowable search fields are limited to those defined in the XML schema; however, extensibility MAY be provided via the Data Forms [1] protocol, as described below.

2. Use Cases

2.1 Searching

搜索一个字段

In order to search an information respository, a user first needs to discover what search fields are supported by the service:

Example 1. Requesting Search Fields

<iqtype='get'
    from='romeo@montague.net/home'
    to='characters.shakespeare.lit'
    id='search1'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'/>
</iq>
    

The service MUST then return the possible search fields to the user, and MAY include instructions:

Example 2. Receiving Search Fields

<iqtype='result'
    from='characters.shakespeare.lit'
    to='romeo@montague.net/home'
    id='search1'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'>
    <instructions>
      Fill in one or more fields to search
      for any matching Jabber users.
    </instructions>
    <first/>
    <last/>
    <nick/>
    <email/>
  </query>
</iq>
    

The user MAY then submit a search request, specifying values for any desired fields:

Example 3. Submitting a Search Request

<iqtype='set'
    from='romeo@montague.net/home'
    to='characters.shakespeare.lit'
    id='search2'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'>
    <last>Capulet</last>
  </query>
</iq>
    

The service SHOULD then return a list of search results that match the values

provided:

服务器必须返回匹配结果值的搜索结果列表

Example 4. Receiving Search Results

<iqtype='result'
    from='characters.shakespeare.lit'
    to='romeo@montague.net/home'
    id='search2'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'>
    <itemjid='juliet@capulet.com'>
      <first>Juliet</first>
      <last>Capulet</last>
      <nick>JuliC</nick>
      <email>juliet@shakespeare.lit</email>
    </item>
    <itemjid='tybalt@shakespeare.lit'>
      <first>Tybalt</first>
      <last>Capulet</last>
      <nick>ty</nick>
      <email>tybalt@shakespeare.lit</email>
    </item>
  </query>
</iq>
    

If there are no matching directory entries, the service MUST return an empty <query/> element:

如果没有匹配的实体,服务器必须返回一个空的<query/>节点

Example 5. Service Informs User that No Records Match

<iqtype='result'
    from='characters.shakespeare.lit'
    to='romeo@montague.net/home'
    id='search2'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'/>
</iq>
    

3. Extensibility

The fields defined in the 'jabber:iq:search' namespace are strictly limited to those specified in the schema. If a host needs to gather additional information, Data Forms SHOULD be used; a host MUST NOT add new fields to the 'jabber:iq:search' namespace. Support for extensibility via Data Forms is RECOMMENDED, but is not required for compliance with this document.

The extensibility mechanism for searching makes use of a hidden FORM_TYPE field for the purpose of standardizing field names within the form, as defined in Field Standardization for Data Forms [2]. Implementations supporting this extensibility mechanism SHOULD support field standardization as well.

Example 6. Entity Requests Search Fields from Service

<iqtype='get'
    from='juliet@capulet.com/balcony'
    to='characters.shakespeare.lit'
    id='search3'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'/>
</iq>
  

Example 7. Host Returns Search Form to Entity

<iqtype='result'
    from='characters.shakespeare.lit'
    to='juliet@capulet.com/balcony'
    id='search3'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'>
    <instructions>
      Use the enclosed form to search. If your Jabber client does not
      support Data Forms, visit http://shakespeare.lit/
    </instructions>
    <xxmlns='jabber:x:data'type='form'>
      <title>User Directory Search</title>
      <instructions>
        Please provide the following information
        to search for Shakespearean characters.
      </instructions>
      <fieldtype='hidden'
             var='FORM_TYPE'>
        <value>jabber:iq:search</value>
      </field>
      <fieldtype='text-single'
             label='Given Name'
             var='first'/>
      <fieldtype='text-single'
             label='Family Name'
             var='last'/>
      <fieldtype='list-single'
             label='Gender'
             var='x-gender'>
        <optionlabel='Male'><value>male</value></option>
        <optionlabel='Female'><value>female</value></option>
      </field>
    </x>
  </query>
</iq>
  

Example 8. Entity Submits Search Form

<iqtype='set'
    from='juliet@capulet.com/balcony'
    to='characters.shakespeare.lit'
    id='search4'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'>
    <xxmlns='jabber:x:data'type='submit'>
      <fieldtype='hidden'var='FORM_TYPE'>
        <value>jabber:iq:search</value>
      </field>
      <fieldvar='x-gender'>
        <value>male</value>
      </field>
    </x>
  </query>
</iq>
  

Example 9. Service Returns Search Results

<iqtype='result'
    from='characters.shakespeare.lit'
    to='juliet@capulet.com/balcony'
    id='search4'
    xml:lang='en'>
  <queryxmlns='jabber:iq:search'>
    <xxmlns='jabber:x:data'type='result'>
      <fieldtype='hidden'var='FORM_TYPE'>
        <value>jabber:iq:search</value>
      </field>
      <reported>
        <fieldvar='first'label='Given Name'type='text-single'/>
        <fieldvar='last'label='Family Name'type='text-single'/>
        <fieldvar='jid'label='Jabber ID'type='jid-single'/>
        <fieldvar='x-gender'label='Gender'type='list-single'/>
      </reported>
      <item>
        <fieldvar='first'><value>Benvolio</value></field>
        <fieldvar='last'><value>Montague</value></field>
        <fieldvar='jid'><value>benvolio@montague.net</value></field>
        <fieldvar='x-gender'><value>male</value></field>
      </item>
      <item>
        <fieldvar='first'><value>Romeo</value></field>
        <fieldvar='last'><value>Montague</value></field>
        <fieldvar='jid'><value>romeo@montague.net</value></field>
        <fieldvar='x-gender'><value>male</value></field>
      </item>
    </x>
  </query>
</iq>
  

4. Internationalization Considerations

The intent of the <first/> and <last/> elements (and associated data form fields) is that they map to given name and family name, respectively. Therefore, cultures that place the family name first and the given name second (e.g., as is done in China) would use <first/> for the given name and <last/> for the family name, NOT the other way around.

For example, the name of the Chinese philosopher Confucius would be rendered as shown below because his given name was Qui and his family name was Kong.

Example 10. Internationalization of names

<iqtype='submit'
    from='confucius@scholars.lit/home'
    to='registrar.scholars.lit'
    id='kj3b157n'
    xml:lang='en'>
  <queryxmlns='jabber:iq:register'>
    <username>confucius</username>
    <first>Qui</first>
    <last>Kong</last>
  </query>
</iq>
  

5. Security Considerations

There are no security features or concerns related to this proposal.

6. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [3].

7. XMPP Registrar Considerations

The XMPP Registrar [4] shall include the following information in its registries.

7.1 Protocol Namespaces

The XMPP Registrar includes the 'jabber:iq:search' namespace in its registry of protocol namespaces.

7.2 Field Standardization

The following fields are reserved for use within jabber:x:data forms scoped by a FORM_TYPE of 'jabber:iq:search'; additional fields MAY be added via the XMPP Registrar's normal registration process but are outside the scope of this document.

Registry Submission

<form_type>
  <name>jabber:iq:search</name>
  <doc>XEP-0055</doc>
  <desc>Forms enabling directory searches.</desc>
  <field
      var='first'
      type='text-single'
      label='Given Name'/>
  <field
      var='last'
      type='text-single'
      label='Family Name'/>
  <field
      var='nick'
      type='text-single'
      label='Nickname'/>
  <field
      var='email'
      type='text-single'
      label='Email Address'/>
</form_type>
    

8. XML Schema

 

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='jabber:iq:search'
    xmlns='jabber:iq:search'
    elementFormDefault='qualified'>

  <xs:importnamespace='jabber:x:data'
             schemaLocation='http://www.xmpp.org/schemas/x-data.xsd'/>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-0055: http://www.xmpp.org/extensions/xep-0055.html
    </xs:documentation>
  </xs:annotation>

  <xs:elementname='query'>
    <xs:complexType>
      <xs:choice>
        <xs:allxmlns:xdata='jabber:x:data'>
          <xs:elementname='instructions'type='xs:string'/>
          <xs:elementname='first'type='xs:string'/>
          <xs:elementname='last'type='xs:string'/>
          <xs:elementname='nick'type='xs:string'/>
          <xs:elementname='email'type='xs:string'/>
          <xs:elementref='xdata:x'minOccurs='0'/>
        </xs:all>
        <xs:elementref='item'minOccurs='0'maxOccurs='unbounded'/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:elementname='item'>
    <xs:complexType>
      <xs:all>
        <xs:elementname='first'type='xs:string'/>
        <xs:elementname='last'type='xs:string'/>
        <xs:elementname='nick'type='xs:string'/>
        <xs:elementname='email'type='xs:string'/>
      </xs:all>
      <xs:attributename='jid'type='xs:string'use='required'/>
    </xs:complexType>
  </xs:element>

</xs:schema>
  

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics