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 stored id value.
Parameters: xml – The ElementBase stanza 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 ElementBase stanza 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.
Warning
Using this matcher may not produce expected behavior when using attribute selectors. For Python 2.6 and 3.1, the ElementTree find() method does not support the use of attribute selectors. If you need to support Python 2.6 or 3.1, it might be more useful to use a StanzaPath matcher.
If the value of IGNORE_NS is set to True, 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_NS is set to True, then XPath expressions will be matched without using namespaces.
Warning
In Python 2.6 and 3.1 the ElementTree find() method does not support attribute selectors in the XPath expression.
Parameters: xml – The ElementBase stanza 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 MatchXPath or StanzaPath should be used instead.
Parameters: criteria – Either an Element XML object or XML string to use as a mask.