[jdev] my own xml in body tag
Ulrich Staudinger
us at activestocks.de
Sun May 15 06:55:19 CDT 2005
> if I've well understood, this is the best way to do it. (even if I
> can't find the spec about the <x> tag ;-) I have to search more... )
>
Yes, any other tag may be transported inside the message tag, as long as
they have a fully qualified namespace [
http://www.ietf.org/rfc/rfc3921.txt ]:
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs='0' maxOccurs='unbounded'>
<xs:element ref='subject'/>
<xs:element ref='body'/>
<xs:element ref='thread'/>
</xs:choice>
<xs:any namespace='##other'
minOccurs='0'
maxOccurs='unbounded'/>
<xs:element ref='error'
minOccurs='0'/>
But do yourself a favor and put things inside an x-tag.
Not the specs but ok [ http://www.oreilly.de/catalog/jabber/chapter/ ]:
*/x/*
------------------------------------------------------------------------
<message to='dj at yak' type='chat' from='sabine at yak/laptop'>
<body>Hi - let me know when you get back. Thanks.</body>
*<x xmlns='jabber:x:delay' from='dj at yak' stamp='20010514T14:44:09'>
Offline Storage
</x>*
</message>
*name: *Optional
The <x/> subelement is special. While the other subelements like <body/>
and <thread/> are fixed into the Jabber building blocks design, the <x/>
subelement allows <message/> elements to be extended to suit
requirements. What the <x/> subelement does is provide an anchor point
for further information to be attached to messages in a structured way.
The information attached to a message is often called the /payload/.
Multiple anchor points can be used to convey multiple payloads, and each
one must be /qualified/ using a namespace.
Just as the content of XML streams is qualified by a namespace (one from
the list in Table 5-2 earlier in this chapter), so the content of the
<x/> /attachment/ must be qualified. There are a number of
Jabber-standard namespaces that are defined for various purposes. One of
these, jabber:x:delay, is used in the example. These standard namespaces
are described in Chapter 6. But there's nothing to stop you defining
your own namespace to describe (and qualify) the data that you wish to
transport in a <message/>. Namespaces beginning jabber: are reserved;
anything else is OK.
Briefly, you can see how payloads are attached from the example. For
every <x/> subelement, there's an xmlns attribute that qualifies it, and
the data contained within the <x/> tag is formatted depending on the
namespace.
In the example, the payload is carried in addition to the <body/>
subelement. However, as the <body/> is actually /optional/ in a message,
it is possible to transmit structured payloads between Jabber entities
without the need for "conventional" message content.
More information about the JDev
mailing list