Stanza Matchers¶
The Basic Matcher¶
ID Matching¶
-
class
sleekxmpp.xmlstream.matcher.id.MatcherId(criteria)[source]¶ The ID matcher selects stanzas that have the same stanza ‘id’ interface value as the desired ID.
-
match(xml)[source]¶ Compare the given stanza’s
'id'attribute to the storedidvalue.Parameters: xml – The ElementBasestanza to compare against.
-
Stanza Path Matching¶
-
class
sleekxmpp.xmlstream.matcher.stanzapath.StanzaPath(criteria)[source]¶ The StanzaPath matcher selects stanzas that match a given “stanza path”, which is similar to a normal XPath except that it uses the interfaces and plugins of the stanza instead of the actual, underlying XML.
Parameters: criteria – Object to compare some aspect of a stanza against. -
match(stanza)[source]¶ Compare a stanza against a “stanza path”. A stanza path is similar to an XPath expression, but uses the stanza’s interfaces and plugins instead of the underlying XML. See the documentation for the stanza
match()method for more information.Parameters: stanza – The ElementBasestanza to compare against.
-
XPath¶
-
class
sleekxmpp.xmlstream.matcher.xpath.MatchXPath(criteria)[source]¶ The XPath matcher selects stanzas whose XML contents matches a given XPath expression.
If the value of
IGNORE_NSis set toTrue, then XPath expressions will be matched without using namespaces.-
match(xml)[source]¶ Compare a stanza’s XML contents to an XPath expression.
If the value of
IGNORE_NSis set toTrue, then XPath expressions will be matched without using namespaces.Parameters: xml – The ElementBasestanza to compare against.
-
XMLMask¶
-
class
sleekxmpp.xmlstream.matcher.xmlmask.MatchXMLMask(criteria, default_ns='jabber:client')[source]¶ The XMLMask matcher selects stanzas whose XML matches a given XML pattern, or mask. For example, message stanzas with body elements could be matched using the mask:
<message xmlns="jabber:client"><body /></message>
Use of XMLMask is discouraged, and
MatchXPathorStanzaPathshould be used instead.Parameters: criteria – Either an ElementXML object or XML string to use as a mask.