What are "Stanzas"?

Hi All,

I am a newbie , i just want to know what is the meaning of stanza (stanzas) , I was going through the source code of openfire and i have seen that word alot of times … ( it seems a silly question) but i am really looking for exact answer.

1 Like

From http://xmpp.org/rfcs/rfc3920.html

  1. XML Streams

Definition of XML Stanza:
An XML stanza is a discrete semantic unit of structured information that is sent from one entity to another over an XML stream. An XML stanza exists at the direct child level of the root element and is said to be well-balanced if it matches the production [43] content of [XML] (Bray, T., Paoli, J., Sperberg-McQueen, C., and E. Maler, “Extensible Markup Language (XML) 1.0 (2nd ed),” October 2000.). The start of any XML stanza is denoted unambiguously by the element start tag at depth=1 of the XML stream (e.g., ), and the end of any XML stanza is denoted unambiguously by the corresponding close tag at depth=1 (e.g., ). An XML stanza MAY contain child elements (with accompanying attributes, elements, and XML character data) as necessary in order to convey the desired information. The only XML stanzas defined herein are the , , and elements qualified by the default namespace for the stream, as described under XML Stanzas (XML Stanzas); an XML element sent for the purpose of Transport Layer Security (TLS) negotiation (Use of TLS), Simple Authentication and Security Layer (SASL) negotiation (Use of SASL), or server dialback (Server Dialback) is not considered to be an XML stanza.
Consider the example of a client’s session with a server. In order to connect to a server, a client MUST initiate an XML stream by sending an opening tag to the server, optionally preceded by a text declaration specifying the XML version and the character encoding supported (see Inclusion of Text Declaration (Inclusion of Text Declaration); see also Character Encoding (Character Encoding)). Subject to local policies and service provisioning, the server SHOULD then reply with a second XML stream back to the client, again optionally preceded by a text declaration. Once the client has completed SASL negotiation (Use of SASL), the client MAY send an unbounded number of XML stanzas over the stream to any recipient on the network. When the client desires to close the stream, it simply sends a closing tag to the server (alternatively, the stream may be closed by the server), after which both the client and server SHOULD terminate the underlying connection (usually a TCP connection) as well.

From RFC 6120 4.1 Stream Fundamentals

Definition of XML Stanza: An XML stanza is the basic unit of meaning

in XMPP. A stanza is a first-level element (at depth=1 of the

stream) whose element name is “message”, “presence”, or “iq” and

whose qualifying namespace is ‘jabber:client’ or ‘jabber:server’.

By contrast, a first-level element qualified by any other

namespace is not an XML stanza (stream errors, stream features,

TLS-related elements, SASL-related elements, etc.), nor is a

From RFC 6120 8. XML Stanzas

  1. XML Stanzas After a client and a server (or two servers) have completed stream negotiation, either party can send XML stanzas. Three kinds of XML stanza are defined for the ‘jabber:client’ and ‘jabber:server’ namespaces: , , and . In addition, there are five common attributes for these stanza types. These common attributes, as well as the basic semantics of the three stanza types, are defined in this specification; more detailed information regarding the syntax of XML stanzas for instant messaging and presence applications is provided in [XMPP-IM], and for other applications in the relevant XMPP extension specifications.