Name

query — Required

Synopsis

<iq type='get' to='yak'>
<query xmlns='jabber:iq:version'/>
</iq>

We’ve already seen the <query/> subelement performing the task of container for the info/query activity.

  • For an IQ-get, the subelement usually just contains a qualifying namespace that in turn defines the essence of the get activity. This is evident in the example here, where the <iq/> element is a retrieval of the server (yak) version information.

  • For an IQ-set, it contains the qualifying namespace and also child tags that hold the data to be set, as in this example, in which a vCard (an electronic “business card”) is being updated:

    SEND: <iq type='set'>
            <vCard xmlns='vcard-temp' version='3.0'>
            ... [vCard information] ...
            </vCard>
          </iq>

  • When result information is returned, it is enclosed within a <query/> subelement qualified with the appropriate namespace, as in this IQ-result response to the earlier request for server version information:

    RECV: <iq type='result' to='dj@yak/Work' from='yak'>
            <query xmlns='jabber:iq:version'>
              <name>jsm</name>
              <version>1.4.1</version>
              <os>Linux 2.2.12-45SAP</os>
            </query>
          </iq>

    Of course, there are some results that don’t carry any further information—the so-called Boolean results. When there’s no information to return in a result, the <query/> subelement isn’t necessary. A typical case in which a Boolean result is returned is on successfully authenticating to the Jabber server (where the credentials are sent in an IQ-set request in the jabber:iq:auth ...

Get Programming Jabber now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.