<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Bookmarks hierarchy</title>
  <abstract>This specification provides a way to organise bookmarks.</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>xxxx</number>
  <status>ProtoXEP</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0060</spec>
    <spec>XEP-0402</spec>
    <spec>Etc.</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>

  <author>
    <firstname>Nicolas</firstname>
    <surname>Cedilnik</surname>
    <email>nicoco@nicoco.fr</email>
    <jid>nicoco@nicoco.fr</jid>
  </author>


  <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>

  <revision>
    <version>0.0.1</version>
    <date>2026-10-17</date>
    <initials>nc</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p>This specification provides a way to organise conversations in directories and to order them.
This can be used as a private, user-specific organisation of chats, or as the server-provided organisation of a give <span class="ref"><link url="https://xmpp.org/extensions/xep-0503.html">Server-side spaces (XEP-0503)</link></span><note>XEP-0503: Server-side spaces &lt;<link url="https://xmpp.org/extensions/xep-0503.html">https://xmpp.org/extensions/xep-0503.html</link>&gt;.</note> node.</p>
</section1>
<section1 topic="Protocol" anchor="protocol">
  <section2 topic="Directories elements" anchor="hierarchy">
    <p>
      Pubsub nodes supporting the protocol defined in this document include an item with an id of <tt>urn:xmpp:bookmarks-hierarchy:0</tt>.
      It has an unique child, the <tt>directories</tt> element, which has one or multiple children <tt>directory</tt> elements.
      These children have two attributes: a unique identifier defined by the <tt>id</tt> attribute (an opaque string), and a human-readable <tt>title</tt> attribute.
      These children are ordered; this defines the order in which these directories SHOULD be displayed to the user.
    </p>
    <example caption="Bookmark directories"><![CDATA[
<item id='urn:xmpp:bookmarks-hierarchy:0'>
  <directories xmlns='urn:xmpp:bookmarks-hierarchy:0'>
    <directory title="Fun stuff"
               id="xxx-xxx-xxxx" />
    <directory title="Boring stuff"
               id="yyy-yyy-yyyy" />
  </directories>
</item>
]]></example>
  </section2>
  <section2 topic="The hierarchy bookmark extension" anchor="hierarchy">
    <p>
      Bookmark items that are part of the same node SHOULD have a <tt>hierarchy</tt> <span class="ref"><link url="https://xmpp.org/extensions/xep-0402.html">PEP Native Bookmarks (XEP-0402)</link></span> <note>XEP-0402: PEP Native Bookmarks &lt;<link url="https://xmpp.org/extensions/xep-0402.html">https://xmpp.org/extensions/xep-0402.html</link>&gt;.</note> bookmark extension.
    </p>
    <p>
      It MUST have a <tt>weight</tt> attribute which value is a decimal number.
      They are sorted by ascending weights.
      Using decimal numbers makes it possible to re-order a single item without modifying the other ones.
    </p>
    <p>
      The <tt>hierarchy</tt> element has an OPTIONAL <tt>directory-id</tt> attribute which value points to the unique ID of a directory defined in the item defined in the previous section.
    </p>
    <example caption="Bookmark hierarchy"><![CDATA[
<hierarchy xmlns='urn:xmpp:bookmarks-hierarchy:0'
           directory-id="gibberish2"
           weight="5.0"/>
]]></example>
  </section2>
</section1>
<section1 topic="Implementation Notes" anchor="impl">
  <p>
    It is possible to use this specification for ordering without organising in directories.
    In this case, the <tt>directories</tt> item is omitted and only weights matter.
  </p>
  <p>
    In the presence of directories, bookmarks are first ordered by directory, and then by weight.
  </p>
  <p>
    Entities supporting this protocol MUST ensure the consistency of the directories identified in the hierarchy element vs the directories element.
    For instance, a <tt>directory-id</tt> MUST not point to an inexisting <tt>id</tt> in the directories item.
  </p>
  <p>
    To avoid transient inconsistencies, deleting a directory MUST be preceded by erasing the corresponding <tt>directory-id</tt>s referring to it.
  </p>
</section1>
<section1 topic="Security Considerations" anchor="security">
  <p>None.</p>
</section1>
<section1 topic="IANA Considerations" anchor="iana">
  <p>None.</p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <p>REQUIRED.</p>
</section1>
<section1 topic="XML Schema" anchor="schema">
<code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:xmpp:bookmarks-hierarchy:0'
    xmlns='urn:xmpp:bookmarks-hierarchy:0'
    elementFormDefault='qualified'>

  <xs:element name='directories'>
    <xs:complexType>
      <xs:sequence>
        <xs:element name='directory' minOccurs='1' maxOccurs='unbounded'>
          <xs:complexType>
            <xs:attribute name='id' type='xs:string' use='required'/>
            <xs:attribute name='title' type='xs:string' use='required'/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <!-- Extension carried by a bookmark item. -->
  <xs:element name='hierarchy'>
    <xs:complexType>
      <xs:attribute name='weight' type='xs:decimal' use='required'/>
      <xs:attribute name='directory-id' type='xs:string' use='optional'/>
    </xs:complexType>
  </xs:element>
</xs:schema>
]]></code>
</section1>
</xep>
