<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>PubSub Type Filtering</title>
  <abstract>This specification provides a way to filter PubSub nodes in a disco query.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0462</number>
  <status>Experimental</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XEP-0004</spec>
    <spec>XEP-0030</spec>
    <spec>XEP-0060</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  
  <author>
    <firstname>Timothée</firstname>
    <surname>Jaussoin</surname>
    <email>edhelas@movim.eu</email>
    <jid>edhelas@movim.eu</jid>
    <uri>https://edhelas.movim.eu</uri>
  </author>

  
  <author>
    <firstname>Maxime</firstname>
    <surname>Buquet</surname>
    <email>pep@bouah.net</email>
    <jid>pep@bouah.net</jid>
  </author>

  <revision>
    <version>0.1.1</version>
    <date>2022-04-22</date>
    <initials>pep</initials>
    <remark>Wording, typos.</remark>
  </revision>
  <revision>
    <version>0.1.0</version>
    <date>2022-03-08</date>
    <initials>XEP Editor (jsc)</initials>
    <remark>Accepted by vote of Council on 2022-02-09.</remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2022-02-01</date>
    <initials>edhelas, pep</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>

<section1 anchor="intro" topic="Introduction">

<p>Implementations have been able to declare a <tt>pubsub#type</tt> attribute on PubSub nodes for about as long as <span class="ref"><link url="https://xmpp.org/extensions/xep-0060.html">Publish-Subscribe (XEP-0060)</link></span> <note>XEP-0060: Publish-Subscribe &lt;<link url="https://xmpp.org/extensions/xep-0060.html">https://xmpp.org/extensions/xep-0060.html</link>&gt;.</note> has existed. This attribute doesn’t seem to be widely used in the community though, maybe due to the vagueness of its description, that has recently changed, or the lack of features associated with it.</p>

<p>This specification provides a way for implementations to allow filtering on this attribute when discovering nodes on a PubSub service.</p>

<p>Filtering is particularly useful for example combined with <span class="ref"><link url="https://xmpp.org/extensions/xep-0277.html">Microblogging Over XMPP (XEP-0277)</link></span> <note>XEP-0277: Microblogging over XMPP &lt;<link url="https://xmpp.org/extensions/xep-0277.html">https://xmpp.org/extensions/xep-0277.html</link>&gt;.</note> and comment nodes that are created on the same service. When listing content nodes of a service, one may want to filter out comment nodes.</p>

</section1>
<section1 anchor="reqs" topic="Requirements">

<ul>
<li>Allow querying only a subset of nodes in a disco items request, in the form of include/exclude</li>
</ul>

</section1>
<section1 anchor="usecases" topic="Use Cases">
<section2 anchor="support" topic="Discovering support">

<p>A service implementing this specification MUST advertize through <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note> a <tt>urn:xmpp:pubsub-filter:0</tt> feature.</p>

</section2>
<section2 anchor="sending-a-disco-request" topic="Sending a disco request">

<p>While requesting disco#items on a PubSub service, an entity might want to only get nodes of certain <tt>pubsub#type</tt>. To do so, it may add a filter child of namespace <tt>urn:xmpp:pubsub-filter:0</tt> to the query element, containing a <span class="ref"><link url="https://xmpp.org/extensions/xep-0004.html">Data Forms (XEP-0004)</link></span> <note>XEP-0004: Data Forms &lt;<link url="https://xmpp.org/extensions/xep-0004.html">https://xmpp.org/extensions/xep-0004.html</link>&gt;.</note> form with FORM_TYPE set to <tt>urn:xmpp:pubsub-filter:0</tt> and an <tt>included-types</tt> or <tt>excluded-types</tt> list-multi type field containing the various types it wants to filter.</p>

<p>When <tt>included-types</tt> is specified, a PubSub service MUST return nodes of matching <tt>pubsub#type</tt> in its response.</p>

<p>When <tt>excluded-types</tt> is specified, a PubSub service MUST return every node but those of matching <tt>pubsub#types</tt> in its response.</p>

<p>Both included and excluded fields MAY contain an empty value to designate nodes with an empty <tt>pubsub#type</tt>.</p>

<example caption="Requesting disco#items with only nodes of the following types, including empty ones"><![CDATA[<iq type='get'
  from='rosa@com.int/desktop'
  to='news.commons.social'
  id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#items'>
    <filter xmlns='urn:xmpp:pubsub-filter:0'>
      <x xmlns='jabber:x:data' type='submit'>
        <field var='FORM_TYPE' type='hidden'>
          <value>urn:xmpp:pubsub-filter:0</value>
        </field>
        <field type='list-multi' var='included-types'>
          <value>urn:xmpp:microblog:0</value>
          <value/>
        </field>
      </x>
    </filter>
  </query>
</iq>]]></example>

<p>If both the included and excluded fields are specified, a service MUST return an error of type <tt>modify</tt> containing a <tt>bad-request</tt> element in the <tt>urn:ietf:params:xml:ns:xmpp-stanzas</tt> namespace.</p>

<example caption="Error returned when a requesting entity includes both fields"><![CDATA[<iq type='error'
    from='news.com.int'
    to='peter@commons.social/desktop'
    id='error1'>
  <error type='modify'>
    <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>]]></example>

</section2>
</section1>
<section1 anchor="iana" topic="IANA Considerations">

<p>None.</p>

</section1>
<section1 anchor="registrar" topic="XMPP Registrar Considerations">

<p>None.</p>

</section1>
<section1 anchor="schema" topic="XML Schema">
<section2 anchor="urnxmpppubsub-filter0" topic="urn:xmpp:pubsub-filter:0">

<code><![CDATA[<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    xmlns:xdata='jabber:x:data'
    targetNamespace='urn:xmpp:pubsub-filter:0'
    xmlns='urn:xmpp:pubsub-filter:0'
    elementFormDefault='qualified'>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-XXXX: http://xmpp.org/extensions/xep-xxxx.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='filter'>
    <xs:complexType>
      <xs:choice xmlns:xdata='jabber:x:data'>
        <xs:element ref='xdata:x'/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>]]></code>

</section2>
</section1>
</xep>
