<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>vCard4 Over XMPP</title>
  <abstract>This document specifies an XMPP extension for use of the vCard4 XML format in XMPP systems, with the intent of obsoleting the vcard-temp format.</abstract>
  &LEGALNOTICE;
  <number>0292</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>RFC 6350</spec>
    <spec>RFC 6351</spec>
  </dependencies>
  <supersedes>
    <spec>XEP-0054</spec>
  </supersedes>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  &stpeter;
  <author>
    <firstname>Samantha</firstname>
    <surname>Mizzi</surname>
    <email>samizzi@cisco.com</email>
    <jid>samizzi@cisco.com</jid>
  </author>
  <revision>
    <version>0.10</version>
    <date>2013-09-12</date>
    <initials>psa</initials>
    <remark><p>Added information about determining support; corrected the XSLT; corrected data: URL example and added reference to RFC 2397; corrected mapping of middle name property.</p></remark>
  </revision>
  <revision>
    <version>0.9</version>
    <date>2011-10-09</date>
    <initials>psa</initials>
    <remark><p>Described how to use the vCard format for storing private data about one's contacts; added XMPP Registrar considerations.</p></remark>
  </revision>
  <revision>
    <version>0.8</version>
    <date>2011-08-31</date>
    <initials>psa</initials>
    <remark><p>Updated to reflect RFC 6350, RFC 6351, and draft-ietf-vcarddav-kind-app.</p></remark>
  </revision>
  <revision>
    <version>0.7</version>
    <date>2011-07-10</date>
    <initials>psa</initials>
    <remark><p>Updated to reflect draft-saintandre-vcarddav-thing-02.</p></remark>
  </revision>
  <revision>
    <version>0.6</version>
    <date>2011-06-27</date>
    <initials>sm/psa</initials>
    <remark><p>Clarified status of VERSION and TZ properties.</p></remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2011-06-24</date>
    <initials>psa</initials>
    <remark><p>Corrected XSLT script; provided detailed examples of the vcard-temp and vCard4 XML formats.</p></remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2011-06-20</date>
    <initials>psa</initials>
    <remark><p>Defined provisional mapping from vcard-temp to vCard4.</p></remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2011-04-07</date>
    <initials>psa</initials>
    <remark><p>Updated to track base vCard4 specs; defined IQ transport, with pubsub for notifications; added examples for server vCards; described several problematic aspects of mapping from vcard-temp.</p></remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2011-04-07</date>
    <initials>psa</initials>
    <remark><p>Updated to track base vCard4 specs; defined IQ transport, with pubsub for notifications; added examples for server vCards; specified mapping from vcard-temp.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2011-03-02</date>
    <initials>psa</initials>
    <remark><p>Initial published version.</p></remark>
  </revision>
  <revision>
    <version>0.0.5</version>
    <date>2011-02-28</date>
    <initials>psa</initials>
    <remark><p>Corrected more errors in the examples.</p></remark>
  </revision>
  <revision>
    <version>0.0.4</version>
    <date>2011-02-25</date>
    <initials>psa</initials>
    <remark><p>Corrected some errors in the examples.</p></remark>
  </revision>
  <revision>
    <version>0.0.3</version>
    <date>2011-02-12</date>
    <initials>psa</initials>
    <remark><p>Third draft.</p></remark>
  </revision>
  <revision>
    <version>0.0.2</version>
    <date>2011-01-31</date>
    <initials>srm</initials>
    <remark><p>Second draft.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2010-11-30</date>
    <initials>srm</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>

<section1 topic='Introduction' anchor='intro'>
  <p>Since 1999, the Jabber/XMPP community has used an interim, unofficial XML representation of vCard data for personal contacts, called &xep0054;. Recently, the IETF has upgraded vCard from vCard3 to vCard 4 (&rfc6350;), and at the same time has defined an official XML format for vCard4 (&rfc6351;). This document specifies an XMPP extension for use of the vCard4 XML format in XMPP systems, with the intent of obsoleting the vcard-temp format. Primarily this document defines the encapsulation method itself; secondarily it also defines transport methods and a mapping to the vcard-temp format for migration by clients and servers.</p>
</section1>

<section1 topic='Requirements' anchor='reqs'>
  <p>This specification was designed with the following requirements in mind.</p>
  <ol>
    <li>Reuse vCard4 as defined in <cite>RFC 6350</cite>.</li>
    <li>Reuse the vCard4 XML format as defined in <cite>RFC 6351</cite>.</li>
    <li>Ensure that clients and servers can easily migrate from vcard-temp to the new encapsulation format.</li>
    <li>Notify interested parties of changes to vCard data using standard XMPP extensions, specifically &xep0163;.</li>
    <li>Support vCards for non-human entities such as XMPP servers and &xep0045; rooms.</li>
    <li>Enable XMPP servers to store vCard4 XML data in LDAP directories if desired.</li>
  </ol>
</section1>

<section1 topic='Reuse of vCard4' anchor='reuse'>
  <p>Because there is now an XML namespace for the official vCard format, we can simply re-use that namespace: "urn:ietf:params:xml:ns:vcard-4.0".</p>
  <p>The vCard XML format defined at the IETF specifies that the root element is &lt;vcards/&gt;, where the only defined child element is &lt;vcard/&gt;. For use in XMPP, we specify that the root element shall be &lt;vcard/&gt;, not &lt;vcards/&gt;.</p>
</section1>

<section1 topic='Self vCards' anchor='public'>

  <p>This section describes the use of the vCard format for self-publication and retrieval of publicly-accessible information about any entity on an XMPP network, thus fulfilling all the use cases of the old vcard-temp format.</p>

  <section2 topic='IQ-Based Publication and Retrieval' anchor='self-iq'>
    <p>As in <cite>XEP-0054</cite>, the primary method for publishing and retrieving vCards is the XMPP &IQ; stanza. (Although it would have been possible to use &xep0222; for public storage and retrieval, community consensus is that storage via IQ is more backward-compatible with <cite>XEP-0054</cite>, and that publish-subscribe is more appropriate only for event notifications.)</p>
    <section3 topic='Retrieval' anchor='self-iq-retrieval'>
      <p>An XMPP entity retrieves the vCard of another entity (or itself) by sending an IQ-get to the target entity containing a &lt;vcard/&gt; child element (note the lowercase "c"!) qualified by the 'urn:ietf:params:xml:ns:vcard-4.0' namespace.</p>
      <example caption="vCard Retrieval Request"><![CDATA[
  <iq from='samizzi@cisco.com/foo'
      id='bx81v356'
      to='stpeter@jabber.org'
      type='get'>
    <vcard xmlns='urn:ietf:params:xml:ns:vcard-4.0'/>
  </iq>
]]></example>
      <p>If a vCard exists for the target entity, the responsible entity (e.g., the XMPP server that hosts the account for a bare JID) MUST return the data in an IQ-result:</p>
      <example caption="Server Returns vCard"><![CDATA[
  <iq from='stpeter@jabber.org'
      id='bx81v356'
      to='samizzi@cisco.com/foo'
      type='result'>
    <vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0">
      <fn><text>Peter Saint-Andre</text></fn>
      <n><surname>Saint-Andre</surname><given>Peter</given><additional></additional></n>
      <nickname><text>stpeter</text></nickname>
      <nickname><text>psa</text></nickname>
      <photo><uri>https://stpeter.im/images/stpeter_oscon.jpg</uri></photo>
      <bday><date>1966-08-06</date></bday>
      <adr>
        <parameters>
          <type><text>work</text><text>voice</text></type>
          <pref><integer>1</integer></pref>
        </parameters>
        <ext>Suite 600</ext>
        <street>1899 Wynkoop Street</street>
        <locality>Denver</locality>
        <region>CO</region>
        <code>80202</code>
        <country>USA</country>
      </adr>
      <adr>
        <parameters><type><text>home</text></type></parameters>
        <ext></ext>
        <street></street>
        <locality>Parker</locality>
        <region>CO</region>
        <code>80138</code>
        <country>USA</country>
      </adr>
      <tel>
        <parameters>
          <type><text>work</text><text>voice</text></type>
          <pref><integer>1</integer></pref>
        </parameters>
        <uri>tel:+1-303-308-3282</uri>
      </tel>
      <tel>
        <parameters><type><text>work</text><text>fax</text></type></parameters>
        <uri>tel:+1-303-308-3219</uri>
      </tel>
      <tel>
        <parameters>
          <type><text>cell</text><text>voice</text><text>text</text></type>
        </parameters>
        <uri>tel:+1-720-256-6756</uri>
      </tel>
      <tel>
        <parameters><type><text>home</text><text>voice</text></type></parameters>
        <uri>tel:+1-303-555-1212</uri>
      </tel>
      <geo><uri>geo:39.59,-105.01</uri></geo>
      <title><text>Executive Director</text></title>
      <role><text>Patron Saint</text></role>
      <org>
        <parameters><type><text>work</text></type></parameters>
        <text>XMPP Standards Foundation</text>
      </org>
      <url><uri>https://stpeter.im/</uri></url>
      <note>
        <text>
        More information about me is located on my
        personal website: https://stpeter.im/
        </text>
      </note>
      <gender><sex><text>M</text></sex></gender>
      <lang>
        <parameters><pref>1</pref></parameters>
        <language-tag>en</language-tag>
      </lang>
      <email>
        <parameters><type><text>work</text></type></parameters>
        <text>psaintan@cisco.com</text>
      </email>
      <email>
        <parameters><type><text>home</text></type></parameters>
        <text>stpeter@jabber.org</text>
      </email>
      <impp>
        <parameters><type><text>work</text></type></parameters>
        <uri>xmpp:psaintan@cisco.com</uri>
      </impp>
      <impp>
        <parameters><type><text>home</text></type></parameters>
        <uri>xmpp:stpeter@jabber.org</uri>
      </impp>
      <key>
        <uri>https://stpeter.im/stpeter.asc</uri>
      </key>
    </vcard>
  </iq>
]]></example>
      <p>If no vCard exists, the server MUST return an IQ-result containing an empty &lt;vcard/&gt; element.</p>
      <example caption="No vCard (empty element)"><![CDATA[
  <iq from='stpeter@jabber.org'
      id='bx81v356'
      to='samizzi@cisco.com/foo'
      type='result'>
    <vcard xmlns='urn:ietf:params:xml:ns:vcard-4.0'/>
  </iq>
]]></example>
    </section3>
    <section3 topic='Publication' anchor='self-iq-publication'>
      <p>An XMPP entity publishes or updates its vCard by sending an IQ-set to itself (typically its bare JID), containing a &lt;vcard/&gt; child element qualified by the 'urn:ietf:params:xml:ns:vcard-4.0' namespace. The publication request needs to include the entire vCard, not a "diff" against the prior data (if any).</p>
      <example caption="vCard Publication Request"><![CDATA[
  <iq from='stpeter@jabber.org/squire
      id='h3vz319m'
      to='stpeter@jabber.org'
      type='set'>
    <vcard xmlns='urn:ietf:params:xml:ns:vcard-4.0'>
      [...]
    </vcard>
  </iq>
]]></example>
      <p>If no error occurs, the responsible entity returns an IQ-result.</p>
      <example caption="Server Acknowledges Publication"><![CDATA[
  <iq from='stpeter@jabber.org'
      id='bx81v356'
      to='stpeter@jabber.org/squire'
      type='result'/>
]]></example>
      <p>Note: An entity MAY have authorization to update the vCard of another entity (e.g., a server administrator might have authorization to modify the server's vCard).</p>
    </section3>

  </section2>
  <section2 topic='Event Notifications' anchor='self-pubsub'>
    <p>&xep0060; provides a way to subscribe to events, and &xep0163; defines a pubsub profile for events associated with instant messaging (IM) accounts. If PEP is supported by an IM server, it can be used to automatically generate event notifications when a user's vCard is modified.</p>
    <section3 topic='Location' anchor='self-pubsub-location'>
      <p>The canonical location for notifications regarding a user's vCard is a pubsub node whose name is "urn:xmpp:vcard4".</p>
    </section3>
    <section3 topic='Subscribing to vCard Notifications' anchor='self-pubsub-subscribe'>
      <p>Let us imagine that Juliet wishes to receive the updates that Romeo publishes to his vCard. She has two options:</p>
      <ol>
        <li>Implicitly subscribe by advertising support for "urn:xmpp:vcard4+notify" in her &xep0115; data. Romeo's PEP service then automatically sends vCard updates to her when it receives presence from her, until and unless she sends presence of type unavailable or stops advertising an interest in vCard updates. This is in accordance with XEP-0060, section 6.1.</li>
        <li>Explicitly subscribe by sending a formal subscription request to the "urn:xmpp:vcard4" node at Romeo's JabberID. Romeo's PEP service might send her all vCard updates even if she is offline at the time (depending on service policies regarding presence integration).</li>
      </ol>
    </section3>
    <section3 topic='Receiving a vCard Notification'>
      <p>Because Juliet has sent presence to Romeo including Entity Capabilities data that includes the "urn:xmpp:vcard4+notify" feature, Romeo's XMPP server will send a PEP notification to Juliet. The notification can include an XMPP message body for backward-compatibility with XMPP clients that are not pubsub-capable. This is in accordance with XEP-0060, second 6.1.7.</p>
      <example caption="Receiving a vCard publication/update"><![CDATA[
  <message from='romeo@montague.lit'
           to='juliet@capulet.lit'
           type='headline'>
    <event xmlns='http://jabber.org/protocol/pubsub#event'>
      <items node='urn:xmpp:vcard4'>
        <item id='current'/>
      </items>
    </event>
  </message>
]]></example>
      <p>Note: There is no payload, because this is a pure notification (the receiver needs to retrieve the vCard using an IQ-get as described earlier).</p>
    </section3>
  </section2>

</section1>

<section1 topic='Contact vCards' anchor='contacts'>

  <p>In addition to enabling the publication and retrieval of vCards about any entity on an XMPP network, the vCard format can also be used to store information about an entity's contacts.</p>

  <section2 topic='Format' anchor='contacts-format'>
    <p>A contact is simply a vCard about someone else (or something else, in the case of automated entities). If the other person or entity is in the user's roster &rfc6121;, the vCard SHOULD contain the Jabber ID of the person or entity. This enables a user to store information about the contact outside of the roster, thus obviating the need for changes or extensions to the roster namespace itself (as in &xep0145;).</p>
    <example caption="Contact"><![CDATA[
<vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0">
  <fn><text>Samantha Mizzi</text></fn>
  <n>
    <surname>Mizzi</surname>
    <given>Samantha</given>
    <additional></additional>
  </n>
  <nickname><text>Sam</text></nickname>
  <nickname><text>samizzi</text></nickname>
  <geo><uri>geo:39.59,-105.01</uri></geo>
  <org>
    <parameters><type><text>work</text></type></parameters>
    <text>Cisco</text>
  </org>
  <note>
    <text>
      My co-author on XEP-0292. She's cool!
    </text>
  </note>
  <impp>
    <parameters><type><text>work</text></type></parameters>
    <uri>xmpp:samizzi@cisco.com</uri>
  </impp>
</vcard>
]]></example>
  </section2>

  <section2 topic='Storage' anchor='contacts-storage'>
    <p>Because contact vCards are private information, they are best stored using &xep0223;. The canonical location is a well-known pubsub node "urn:xmpp:contacts". In accordance with <cite>XEP-0223</cite>, this node MUST have an access type of "whitelist" by default. When a client stores items at this node, it SHOULD NOT include an ItemID, so that the pubsub service can assign those identifiers.</p>
    <example caption='Storing a Contact vCard'><![CDATA[
<iq from='stpeter@stpeter.im/squire' type='set' id='h3vs7163'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <publish node='urn:xmpp:contacts'>
      <item>
        <vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0">
          <fn><text>Samantha Mizzi</text></fn>
          <n>
            <surname>Mizzi</surname>
            <given>Samantha</given>
            <additional></additional>
          </n>
          <nickname><text>Sam</text></nickname>
          <nickname><text>samizzi</text></nickname>
          <geo><uri>geo:39.59,-105.01</uri></geo>
          <org>
            <parameters><type><text>work</text></type></parameters>
            <text>Cisco</text>
          </org>
          <note>
            <text>
              My co-author on XEP-0292. She's cool!
            </text>
          </note>
          <impp>
            <parameters><type><text>work</text></type></parameters>
            <uri>xmpp:samizzi@cisco.com</uri>
          </impp>
        </vcard>
      </item>
    </publish>
    <publish-options>
      <x xmlns='jabber:x:data' type='submit'>
        <field var='FORM_TYPE' type='hidden'>
          <value>http://jabber.org/protocol/pubsub#publish-options</value>
        </field>
        <field var='pubsub#persist_items'>
          <value>true</value>
        </field>
        <field var='pubsub#access_model'>
          <value>whitelist</value>
        </field>
      </x>
    </publish-options>
  </pubsub>
</iq>
]]></example>
    <p>When a contact's vCard is stored in a private node, it is pushed out to all of the user's resources that have included in their entity capabilities (XEP-0115) data a service discovery feature of "urn:xmpp:contacts+notify" (in the following example those resources are "squire" and "roundabout").</p>
    <example caption='Publisher resources receive event notification'><![CDATA[
<message from='stpeter@stpeter.im'
         to='stpeter@stpeter.im/squire'
         type='headline'
         id='ka92g1b5'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='urn:xmpp:contacts'>
      <item id='9703CC4E-CF7E-4A86-9E61-2C670235F9CB'>
        <vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0">
          <fn><text>Samantha Mizzi</text></fn>
          <n>
            <surname>Mizzi</surname>
            <given>Samantha</given>
            <additional></additional>
          </n>
          <nickname><text>Sam</text></nickname>
          <nickname><text>samizzi</text></nickname>
          <geo><uri>geo:39.59,-105.01</uri></geo>
          <org>
            <parameters><type><text>work</text></type></parameters>
            <text>Cisco</text>
          </org>
          <note>
            <text>
              My co-author on XEP-0292. She's cool!
            </text>
          </note>
          <impp>
            <parameters><type><text>work</text></type></parameters>
            <uri>xmpp:samizzi@cisco.com</uri>
          </impp>
        </vcard>
      </item>
    </items>
  </event>
</message>

<message from='stpeter@stpeter.im'
         to='stpeter@stpeter.im/roundabout'
         type='headline'
         id='pty14x69'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='urn:xmpp:contacts'>
      <item id='9703CC4E-CF7E-4A86-9E61-2C670235F9CB'>
        <vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0">
          <fn><text>Samantha Mizzi</text></fn>
          <n>
            <surname>Mizzi</surname>
            <given>Samantha</given>
            <additional></additional>
          </n>
          <nickname><text>Sam</text></nickname>
          <nickname><text>samizzi</text></nickname>
          <geo><uri>geo:39.59,-105.01</uri></geo>
          <org>
            <parameters><type><text>work</text></type></parameters>
            <text>Cisco</text>
          </org>
          <note>
            <text>
              My co-author on XEP-0292. She's cool!
            </text>
          </note>
          <impp>
            <parameters><type><text>work</text></type></parameters>
            <uri>xmpp:samizzi@cisco.com</uri>
          </impp>
        </vcard>
      </item>
    </items>
  </event>
</message>
]]></example>
  </section2>

</section1>

<section1 topic='vCards of Automated Entities' anchor='apps'>
  <p>Traditionally, vCards have been used on the XMPP network for entities other than human users, e.g. by XMPP servers and chatrooms. When such automated entities use vCards, it is RECOMMENDED to specify a value of "application" for the vCard4 KIND property &rfc6473;, as illustrated in the following example:</p>
  <example caption="vCard for a Thing"><![CDATA[
<iq from='jabber.org'
    id='yhx51c35'
    to='samizzi@cisco.com/foo'
    type='result'>
  <vcard xmlns='urn:ietf:params:xml:ns:vcard-4.0'>
    <fn><text>jabber.org IM service</text></fn>
    <url><uri>http://www.jabber.org/</uri></url>
    <lang>
      <parameters><pref>1</pref></parameters>
      <language-tag>en</language-tag>
    </lang>
    <email><text>xmpp@jabber.org</text></email>
    <impp><uri>xmpp:jabber.org</uri></impp>
    <logo><uri>http://www.jabber.org/images/logo.png</uri></logo>
    <geo><uri>geo:42.25,-91.05</uri></geo>
    <tz><text>America/Chicago</text></tz>
    <kind><text>application</text></kind>
  </vcard>
</iq>
]]></example>
</section1>

<section1 topic='Determining Support' anchor='disco'>
  <p>If an XMPP client or server supports the vCard4 namespace, it MUST advertise that fact in its responses to &xep0030; information ("disco#info") requests by returning a feature of "urn:ietf:params:xml:ns:vcard-4.0":</p>
  <example caption='A disco#info query'><![CDATA[
<iq type='get'
    from='stpeter@jabber.org/squire'
    to='samizzi@cisco.com/foo'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
  <example caption='A disco#info response'><![CDATA[
<iq type='result'
    from='samizzi@cisco.com/foo'
    to='stpeter@jabber.org/squire'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='urn:ietf:params:xml:ns:vcard-4.0'/>
    ...
  </query>
</iq>
]]></example>
  <p>In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.</p>
</section1>

<section1 topic='Security Considerations' anchor='security'>
  <p>The vCard information published to one's XMPP server is world-readable; therefore, users should exercise due caution when determining what information to include (e.g., street addresses, personal telephone numbers, or email addresses).</p>
</section1>

<section1 topic='IANA Considerations' anchor='iana'>
  <p>This document does not require interaction with &IANA;.</p>
</section1>

<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  <section2 topic='Well-Known Service Discovery Nodes' anchor='registrar-nodes'>
    <p>The &REGISTRAR; shall include 'urn:xmpp:contact' and 'urn:xmpp:vcard4' in its registry of Nodes for Service Discovery and Publish-Subscribe at &NODES;.</p>
  </section2>
</section1>

<section1 topic='Mapping from vcard-temp to vCard4' anchor='mapping'>
  <p>This section provides a more detailed description of mapping vcard-temp properties to vcard4 properties.</p>
  <section2 topic='Properties Defined in vcard-temp but not in vCard3 or vCard4' anchor='mapping-temponly'>
    <section3 topic='DESC' anchor='mapping-temponly-desc'>
      <p>The vcard-temp specification defined a &lt;DESC/&gt; element. This element was not part of the vCard3 schema. Mapping the vcard-temp &lt;DESC/&gt; element to the vCard4 NOTE property is appropriate.</p>
      <example caption="Deprecated DESC element"><![CDATA[
<DESC>
   More information about me is located on my
   personal website: https://stpeter.im/
</DESC>
]]></example>
      <example caption="NOTE property"><![CDATA[
<note>
  <text>
     More information about me is located on my
     personal website: https://stpeter.im/
  </text>
</note>
]]></example>
    </section3>
    <section3 topic='JABBERID' anchor='mapping-temponly-jabberid'>
      <p>The vcard-temp specification defined a &lt;JABBERID/&gt; element:</p>
      <example caption="Deprecated JABBERID element"><![CDATA[
<JABBERID>stpeter@jabber.org</JABBERID>
]]></example>
      <p>Although the JABBERID field was not part of the vCard3 schema and was simply hacked into vcard-temp, &rfc4770; defined an IMPP property for instant messaging and presence addresses, which was ported to vCard4. In the vCard4 XML format, the IMPP property for a JabberID would be as follows.</p>
      <example caption="IMPP property"><![CDATA[
<impp>
  <uri>xmpp:stpeter@jabber.org</uri>
</impp>
]]></example>
    </section3>
    <section3 topic='MIDDLE' anchor='mapping-temponly-middle'>
      <p>The vcard-temp specification defined a &lt;MIDDLE/&gt; element as the third allowable element within the &lt;N/&gt; ("name") element. This element was not part of the vCard3 schema, although the Dawson drafts did contain an &lt;other/&gt; element in the third position of child elements within the &lt;n/&gt; element. It is appropriate to map the vcard-temp &lt;MIDDLE/&gt; element to the vCard4 "Additional Name" part of the "N" structured property value, which in xCard is the &lt;additional/&gt; child of the &lt;n/&gt; element.</p>
    </section3>
  </section2>
  <section2 topic='Properties Defined Incorrectly in vcard-temp' anchor='mapping-incorrect'>
    <p>Several of the properties in vcard-temp are defined differently in vCard3. In fact, the definitions even differ from those provisionally made in the so-called "Dawson drafts" from which vcard-temp was supposedly derived (for reference, the last of these is archived at &lt;<link url='http://www.watersprings.org/pub/id/draft-dawson-vcard-xml-dtd-03.txt'>http://www.watersprings.org/pub/id/draft-dawson-vcard-xml-dtd-03.txt</link>&gt;). The reasons for these discrepancies are unknown. However, care must be taken in correctly mapping these properties from vcard-temp to vCard4.</p>
    <section3 topic='KEY' anchor='mapping-incorrect-key'>
      <p>The DTD in <cite>XEP-0054</cite> provided this definition for the KEY element:</p>
      <code><![CDATA[
<!ELEMENT KEY (TYPE?, CRED)>
]]></code>
      <p>However, the DTD in the final Dawson draft provided the following definition:</p>
      <code><![CDATA[
<!ELEMENT key (extref | b64bin)>
]]></code>
      <p>The relevant RelaxNG definition in vCard4 XML is as follows:</p>
      <code><![CDATA[
property-key = element key {
    (value-uri | value-text)
  }
]]></code>
      <p>The source of the spurious &lt;TYPE/&gt; and &lt;CRED/&gt; elements is unknown. The vcard-temp &lt;CRED/&gt; element is mapped to the vCard4 value-text construction.</p>
    </section3>
    <section3 topic='SOUND' anchor='mapping-incorrect-sound'>
      <p>The DTD in <cite>XEP-0054</cite> provided this definition for the SOUND element:</p>
      <code><![CDATA[
<!ELEMENT SOUND (PHONETIC | BINVAL | EXTVAL)>
]]></code>
      <p>However, the DTD in the final Dawson draft provided the following definition:</p>
      <code><![CDATA[
<!ELEMENT sound (extref | b64bin)>
]]></code>
      <p>The source of the spurious vcard-temp &lt;PHONETIC/&gt; element is unknown. However, it does not exist in vCard4 and therefore is simply discarded when mapping. The vcard-temp &lt;BINVAL/&gt; element is mapped to the vCard4 b64bin construction and the vcard-temp &lt;EXTVAL/&gt; element is mapped to the vCard4 extref construction.</p>
    </section3>
    <section3 topic='VERSION' anchor='mapping-incorrect-version'>
      <p>As explained in <cite>XEP-0054</cite>, the &lt;VERSION/&gt; element from the final Dawson draft was not used in vcard-temp; instead, the vcard-temp protocol used a 'version' attribute (in fact the Dawson drafts were inconsistent, since the DTD defined a &lt;VERSION/&gt; element and the body of the specification used a 'version' attribute).</p>
    </section3>
  </section2>
  <section2 topic='Properties Defined Differently in vcard-temp, vCard3, and vCard4' anchor='mapping-different'>
    <p>The following properties are defined differently in vcard-temp and vCard4. As a result, the mappings are workable but might not preserve all information that could have been contained in vcard-temp data.</p>
    <section3 topic='ADR' anchor='mapping-different-adr'>
      <p>The following address type values allowed in vCard3 were removed from vCard4:</p>
      <ul>
        <li>DOM</li>
        <li>INTL</li>
        <li>PARCEL</li>
        <li>POSTAL</li>
      </ul>
    </section3>
    <section3 topic='AGENT' anchor='mapping-different-agent'>
      <p>In vCard3 and vcard-temp, the AGENT property was allowed to contain the inline vCard of someone who could act as an agent for the primary owner of the referenced vCard. In vCard4, inline vCards are disallowed. Therefore only pointers to external vCard objects are now allowed, by means of a URI.</p>
    </section3>
    <section3 topic='ORG' anchor='mapping-different-org'>
      <p>The ORGUNIT property was removed from vCard4, with the result that the ORGNAME property becomes the only child of ORG.</p>
    </section3>
    <section3 topic='SORT-STRING' anchor='mapping-different-sortstring'>
      <p>The SORT-STRING property from vCard3 was renamed to SORT-AS in vCard4.</p>
    </section3>
    <section3 topic='TEL' anchor='mapping-different-tel'>
      <p>The following telephony type values allowed in vCard3 were removed from vCard4:</p>
      <ul>
        <li>BBS</li>
        <li>ISDN</li>
        <li>MODEM</li>
        <li>MSG</li>
        <li>PCS</li>
      </ul>
      <p>In addition, in vCard4 the telephone number is represented as a tel: URI, not by means of a NUMBER property.</p>
    </section3>
  </section2>
  <section2 topic='Properties Defined Similarly in vcard-temp, vCard3, and vCard4' anchor='mapping-similar'>
    <p>The following properties are defined similarly in vcard-temp, vCard3, and vCard4. The mappings are fairly straightforward (a future version of this document might provide more detailed narrative descriptions of the mappings).</p>
    <ul>
      <li>BDAY</li>
      <li>CATEGORIES</li>
      <li>EMAIL</li>
      <li>FN</li>
      <li>GEO</li>
      <li>LOGO</li>
      <li>N</li>
      <li>NICKNAME</li>
      <li>NOTE</li>
      <li>PHOTO (mapped to a 'data:' URI in vCard4, see &rfc2397;)</li>
      <li>PRODID</li>
      <li>REV</li>
      <li>ROLE</li>
      <li>TITLE</li>
      <li>TZ</li>
      <li>UID</li>
      <li>URL</li>
    </ul>
  </section2>
  <section2 topic='Properties Defined in vCard3 but Removed from vCard4' anchor='mapping-removed'>
    <p>The following properties were defined in vCard3 but were removed from vCard4:</p>
    <ul>
      <li>CLASS</li>
      <li>LABEL</li>
      <li>MAILER</li>
    </ul>
    <p>There is no mapping from these properties to vCard4.</p>
  </section2>
</section1>
<section1 topic='Migration Tools' anchor='migration'>
  <p>This section contains three tools that are intended to help developers in migrating from vcard-temp to vCard4 XML:</p>
  <ol>
    <li>An Extensible Stylesheet Language Transformation (XSLT) script for automatically translating the vcard-temp XML format into the vCard4 XML format.</li>
    <li>An example of vcard-temp data that uses most of the elements defined in <cite>XEP-0054</cite> that can be mapped to vCard4 properties (note that some of these elements were never used in practice).</li>
    <li>An example of vCard4 XML data showing the transformation of the vcard-temp example using the XSLT stylesheet.</li>
  </ol>
  <p>The tools are <strong>purely informational</strong> and are not a normative part of this specification.</p>
  <section2 topic='Extensible Stylesheet Language Transformation (XSLT) from vcard-temp to vCard4' anchor='migration-xslt'>
    <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<!--

Copyright (c) 1999 - 2017 XMPP Standards Foundation

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.

-->

<!-- Author: stpeter@jabber.org -->

<!-- Version: 0.0.3 -->

<!-- Last Updated: 2012-09-12 -->

<xsl:stylesheet
     xmlns='urn:ietf:params:xml:ns:vcard-4.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
     version='1.0'>

  <xsl:output method='xml'/>

  <xsl:template match='/'>
    <vcard>

      <!-- BEGIN VARIABLES -->

      <!-- in case we need them, count instances of the vcard-temp
           elements per the DTD in XEP-0054 -->

      <xsl:variable name='FN.count' select='count(/vCard/FN)'/>
      <xsl:variable name='N.count' select='count(/vCard/N)'/>
      <xsl:variable name='NICKNAME.count' select='count(/vCard/NICKNAME)'/>
      <xsl:variable name='PHOTO.count' select='count(/vCard/PHOTO)'/>
      <xsl:variable name='BDAY.count' select='count(/vCard/BDAY)'/>
      <xsl:variable name='ADR.count' select='count(/vCard/ADR)'/>
      <xsl:variable name='LABEL.count' select='count(/vCard/LABEL)'/>
      <xsl:variable name='TEL.count' select='count(/vCard/TEL)'/>
      <xsl:variable name='EMAIL.count' select='count(/vCard/EMAIL)'/>
      <xsl:variable name='JABBERID.count' select='count(/vCard/JABBERID)'/>
      <xsl:variable name='MAILER.count' select='count(/vCard/MAILER)'/>
      <xsl:variable name='TZ.count' select='count(/vCard/TZ)'/>
      <xsl:variable name='GEO.count' select='count(/vCard/GEO)'/>
      <xsl:variable name='TITLE.count' select='count(/vCard/TITLE)'/>
      <xsl:variable name='ROLE.count' select='count(/vCard/ROLE)'/>
      <xsl:variable name='LOGO.count' select='count(/vCard/LOGO)'/>
      <xsl:variable name='AGENT.count' select='count(/vCard/AGENT)'/>
      <xsl:variable name='ORG.count' select='count(/vCard/ORG)'/>
      <xsl:variable name='CATEGORIES.count' select='count(/vCard/CATEGORIES)'/>
      <xsl:variable name='NOTE.count' select='count(/vCard/NOTE)'/>
      <xsl:variable name='PRODID.count' select='count(/vCard/PRODID)'/>
      <xsl:variable name='REV.count' select='count(/vCard/REV)'/>
      <xsl:variable name='SORT-STRING.count' select='count(/vCard/SORT-STRING)'/>
      <xsl:variable name='SOUND.count' select='count(/vCard/SOUND)'/>
      <xsl:variable name='UID.count' select='count(/vCard/UID)'/>
      <xsl:variable name='URL.count' select='count(/vCard/URL)'/>
      <xsl:variable name='CLASS.count' select='count(/vCard/CLASS)'/>
      <xsl:variable name='KEY.count' select='count(/vCard/KEY)'/>
      <xsl:variable name='DESC.count' select='count(/vCard/DESC)'/>

      <!-- END VARIABLES -->

      <!-- BEGIN VCARD4 OUTPUT -->

      <!-- FN is required -->

      <fn><text><xsl:value-of select='/vCard/FN'/></text></fn>

      <!-- N is required -->

      <xsl:apply-templates select='/vCard/N'/>

      <!-- NICKNAME can be included one or more times -->

      <xsl:for-each select='/vCard/NICKNAME'>
        <nickname><text><xsl:value-of select='.'/></text></nickname>
      </xsl:for-each>

      <!-- PHOTO can be included one or more times -->
      <!-- content is either a pointer to a URL or inline binary,
           which is mapped to a data: URI in vCard4 -->

      <xsl:for-each select='/vCard/PHOTO'>
        <xsl:variable name='PHOTO.ext' select='count(EXTVAL)'/>
        <xsl:variable name='PHOTO.type' select='TYPE'/>
        <xsl:choose>
          <xsl:when test='$PHOTO.ext=1'>
            <photo><uri><xsl:value-of select='EXTVAL'/></uri></photo>
          </xsl:when>
          <xsl:otherwise>
            <photo>
              <uri>
                <xsl:text>data:</xsl:text><xsl:value-of select='TYPE'/><xsl:text>;</xsl:text><xsl:value-of select='BINVAL'/>
              </uri>
            </photo>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>

      <!-- BDAY can be included once -->

      <xsl:if test='$BDAY.count=1'>
        <bday><date><xsl:value-of select='/vCard/BDAY'/></date></bday>
      </xsl:if>

      <!-- ADR can be included one or more times -->

      <xsl:apply-templates select='/vCard/ADR'/>

      <!-- NOTE: vcard-temp allowed a LABEL element,
           but it was removed from vCard4 -->

      <!-- one or more TEL elements can be included -->

      <xsl:apply-templates select='/vCard/TEL'/>

      <!-- one or more EMAIL elements can be included -->

      <xsl:apply-templates select='/vCard/EMAIL'/>

      <!-- JABBERID can be included one or more times -->
      <!-- we map this to the vCard4 IMPP property -->

      <xsl:for-each select='/vCard/JABBERID'>
        <impp><uri><xsl:text>xmpp:</xsl:text><xsl:value-of select='.'/></uri></impp>
      </xsl:for-each>

      <!-- NOTE: vcard-temp allowed a MAILER element,
           but it was removed from vCard4 -->

      <!-- one or more TZ elements can be included -->

      <xsl:for-each select='/vCard/TZ'>
        <tz><text><xsl:value-of select='.'/></text></tz>
      </xsl:for-each>

      <!-- one or more GEO elements can be included -->

      <xsl:for-each select='/vCard/GEO'>
        <geo><uri><xsl:text>geo:</xsl:text><xsl:value-of select='LAT'/><xsl:text>,</xsl:text><xsl:value-of select='LON'/></uri></geo>
      </xsl:for-each>

      <!-- one or more TITLE elements can be included -->

      <xsl:for-each select='/vCard/TITLE'>
        <title><text><xsl:value-of select='.'/></text></title>
      </xsl:for-each>

      <!-- one or more ROLE elements can be included -->

      <xsl:for-each select='/vCard/ROLE'>
        <role><text><xsl:value-of select='.'/></text></role>
      </xsl:for-each>

      <!-- one or more LOGO elements can be included -->
      <!-- content is either a pointer to a URL or inline binary,
           which is mapped to a data: URI in vCard4 -->

      <xsl:for-each select='/vCard/LOGO'>
        <xsl:variable name='LOGO.ext' select='count(EXTVAL)'/>
        <xsl:variable name='LOGO.type' select='TYPE'/>
        <xsl:choose>
          <xsl:when test='$LOGO.ext=1'>
            <logo><uri><xsl:value-of select='EXTVAL'/></uri></logo>
          </xsl:when>
          <xsl:otherwise>
            <logo>
              <uri><xsl:text>data:</xsl:text><xsl:value-of select='TYPE'/><xsl:text>;base64,</xsl:text><xsl:value-of select='BINVAL'/>
              </uri>
            </logo>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>

      <!-- one or more AGENT elements can be included -->
      <!-- however, inline vcards are not supported in vCard4 -->
      <!-- the relevant vCard4 property is RELATED -->
      <!-- only EXTVAL is supported now via URIs -->
      <!-- NOTE: this element was probably unused in vcard-temp -->

      <xsl:for-each select='/vCard/AGENT'>
        <xsl:variable name='AGENT.ext' select='count(EXTVAL)'/>
        <xsl:if test='$AGENT.ext=1'>
          <agent><uri><xsl:value-of select='EXTVAL'/></uri></agent>
        </xsl:if>
      </xsl:for-each>

      <!-- one or more ORG elements can be included -->
      <!-- NOTE: ORGUNIT is no longer used in vcard4 -->

      <xsl:for-each select='/vCard/ORG'>
        <org>
          <xsl:variable name='ORGNAME.count' select='count(ORGNAME)'/>
          <xsl:if test='$ORGNAME.count=1'>
            <text><xsl:value-of select='ORGNAME'/></text>
          </xsl:if>
        </org>
      </xsl:for-each>

      <!-- one or more CATEGORIES elements can be included -->
      <!-- NOTE: this element was probably unused in vcard-temp -->

      <xsl:for-each select='/vCard/CATEGORIES'>
        <categories><text><xsl:value-of select='.'/></text></categories>
      </xsl:for-each>

      <!-- one or more NOTE elements can be included -->
      <!-- NOTE: this element was probably unused in vcard-temp -->

      <xsl:for-each select='/vCard/NOTE'>
        <note><text><xsl:value-of select='.'/></text></note>
      </xsl:for-each>

      <!-- PRODID can be included exactly once -->
      <!-- NOTE: this element was probably unused in vcard-temp -->

      <xsl:if test='$PRODID.count=1'>
        <prodid><text><xsl:value-of select='.'/></text></prodid>
      </xsl:if>

      <!-- REV can be included exactly once -->
      <!-- NOTE: this element was probably unused in vcard-temp -->

      <xsl:if test='$REV.count=1'>
        <rev><timestamp><xsl:value-of select='.'/></timestamp></rev>
      </xsl:if>

      <!-- one or more SORT-STRING elements can be included -->
      <!-- this element maps to SORT-AS in vCard4 -->

      <xsl:for-each select='/vCard/SORT-STRING'>
        <sort-as><xsl:value-of select='.'/></sort-as>
      </xsl:for-each>

      <!-- one or more SOUND elements can be included -->
      <!-- NOTE: for some reason, vcard-temp allowed a <PHONETIC/>
           child element, but that was not documented in the
           original Dawson I-Ds and is not supported in vCard4 -->

      <xsl:for-each select='/vCard/SOUND'>
        <xsl:variable name='SOUND.ext' select='count(EXTVAL)'/>
        <xsl:variable name='SOUND.bin' select='count(BINVAL)'/>
        <xsl:choose>
          <xsl:when test='$SOUND.ext=1'>
            <sound><uri><xsl:value-of select='EXTVAL'/></uri></sound>
          </xsl:when>
          <xsl:when test='$SOUND.ext=1'>
            <sound>
              <uri><xsl:text>data:audio/basic;base64,</xsl:text><xsl:value-of select='BINVAL'/>
              </uri>
            </sound>
          </xsl:when>
          <xsl:otherwise>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>

      <!-- UID can be included exactly once -->

      <xsl:if test='$UID.count=1'>
        <uid><uri><xsl:value-of select='/vCard/UID'/></uri></uid>
      </xsl:if>

      <!-- URL can be included one or more times -->

      <xsl:for-each select='/vCard/URL'>
        <url><uri><xsl:value-of select='.'/></uri></url>
      </xsl:for-each>

      <!-- NOTE: vcard-temp allowed a CLASS element,
           but it was removed from vCard4 -->

      <!-- KEY can be included one or more times -->

      <xsl:for-each select='/vCard/KEY'>
        <key><text><xsl:value-of select='CRED'/></text></key>
      </xsl:for-each>

      <!-- DESC can be included one or more times -->
      <!-- this existed in vcard-temp but not vCard3 -->
      <!-- mapped to the NOTE element -->

      <xsl:for-each select='/vCard/DESC'>
        <note><text><xsl:value-of select='.'/></text></note>
      </xsl:for-each>

    </vcard>

  </xsl:template>

  <xsl:template match='N'>
    <n>
      <xsl:variable name='FAMILY.count' select='count(FAMILY)'/>
      <xsl:variable name='GIVEN.count' select='count(GIVEN)'/>
      <xsl:variable name='MIDDLE.count' select='count(MIDDLE)'/>
      <xsl:variable name='PREFIX.count' select='count(PREFIX)'/>
      <xsl:variable name='SUFFIX.count' select='count(SUFFIX)'/>
      <xsl:if test='$FAMILY.count=1'>
        <surname><xsl:value-of select='FAMILY'/></surname>
      </xsl:if>
      <xsl:if test='$GIVEN.count=1'>
        <given><xsl:value-of select='GIVEN'/></given>
      </xsl:if>
      <xsl:if test='$MIDDLE.count=1'>
        <additional><xsl:value-of select='MIDDLE'/></additional>
      </xsl:if>
      <xsl:if test='$PREFIX.count=1'>
        <prefix><xsl:value-of select='PREFIX'/></prefix>
      </xsl:if>
      <xsl:if test='$SUFFIX.count=1'>
        <suffix><xsl:value-of select='SUFFIX'/></suffix>
      </xsl:if>
    </n>
  </xsl:template>

  <xsl:template match='ADR'>
    <adr>
      <xsl:variable name='HOME.count' select='count(HOME)'/>
      <xsl:variable name='WORK.count' select='count(WORK)'/>

      <!-- NOTE: vcard-temp allowed address types of POSTAL, PARCEL,
           DOM, and INTL, but they were removed from vCard4 -->

      <xsl:variable name='PREF.count' select='count(PREF)'/>
      <xsl:variable name='POBOX.count' select='count(POBOX)'/>
      <xsl:variable name='EXTADD.count' select='count(EXTADD)'/>
      <xsl:variable name='STREET.count' select='count(STREET)'/>
      <xsl:variable name='LOCALITY.count' select='count(LOCALITY)'/>
      <xsl:variable name='REGION.count' select='count(REGION)'/>
      <xsl:variable name='PCODE.count' select='count(PCODE)'/>

      <!-- NOTE: yes, vcard-temp has CTRY, not COUNTRY -->

      <xsl:variable name='CTRY.count' select='count(CTRY)'/>

      <!-- first we count the number of vCard TYPE parameters -->

      <xsl:variable name='TYPE.count' select='$HOME.count + $WORK.count'/>

      <!-- now we output all the parameters -->

      <xsl:if test='$TYPE.count &gt; 0'>
        <parameters>
          <type>
            <xsl:if test='$HOME.count=1'>
              <text>home</text>
            </xsl:if>
            <xsl:if test='$WORK.count=1'>
              <text>work</text>
            </xsl:if>
          </type>
          <xsl:if test='$PREF.count=1'>
            <pref><integer>1</integer></pref>
          </xsl:if>
        </parameters>
      </xsl:if>
      <xsl:if test='$POBOX.count=1'>
        <pobox><xsl:value-of select='POBOX'/></pobox>
      </xsl:if>
      <xsl:if test='$EXTADD.count=1'>
        <ext><xsl:value-of select='EXTADD'/></ext>
      </xsl:if>
      <xsl:if test='$STREET.count=1'>
        <street><xsl:value-of select='STREET'/></street>
      </xsl:if>
      <xsl:if test='$LOCALITY.count=1'>
        <locality><xsl:value-of select='LOCALITY'/></locality>
      </xsl:if>
      <xsl:if test='$REGION.count=1'>
        <region><xsl:value-of select='REGION'/></region>
      </xsl:if>
      <xsl:if test='$PCODE.count=1'>
        <code><xsl:value-of select='PCODE'/></code>
      </xsl:if>
      <xsl:if test='$CTRY.count=1'>
        <country><xsl:value-of select='CTRY'/></country>
      </xsl:if>
    </adr>
  </xsl:template>

  <xsl:template match='TEL'>
    <tel>
      <xsl:variable name='HOME.count' select='count(HOME)'/>
      <xsl:variable name='WORK.count' select='count(WORK)'/>
      <xsl:variable name='TEXT.count' select='count(TEXT)'/>
      <xsl:variable name='VOICE.count' select='count(VOICE)'/>
      <xsl:variable name='FAX.count' select='count(FAX)'/>
      <xsl:variable name='CELL.count' select='count(CELL)'/>
      <xsl:variable name='VIDEO.count' select='count(VIDEO)'/>
      <xsl:variable name='PAGER.count' select='count(PAGER)'/>
      <xsl:variable name='TEXTPHONE.count' select='count(TEXTPHONE)'/>

      <!-- NOTE: vcard-temp allowed telephony types of MSG, BBS,
           MODEM, ISDN, and PCS but they were removed from vCard4 -->

      <xsl:variable name='PREF.count' select='count(PREF)'/>
      <xsl:variable name='NUMBER.count' select='count(NUMBER)'/>
      <!-- first we count the number of vCard TYPE parameters -->
      <xsl:variable name='TYPE.count'
                    select='$HOME.count
                          + $WORK.count
                          + $TEXT.count
                          + $VOICE.count
                          + $FAX.count
                          + $CELL.count
                          + $VIDEO.count
                          + $PAGER.count
                          + $TEXTPHONE.count'/>

      <!-- now we output all the parameters -->

      <xsl:if test='$TYPE.count &gt; 0'>
        <parameters>
          <type>
            <xsl:if test='$HOME.count=1'>
              <text>home</text>
            </xsl:if>
            <xsl:if test='$WORK.count=1'>
              <text>work</text>
            </xsl:if>
            <xsl:if test='$TEXT.count=1'>
              <text>text</text>
            </xsl:if>
            <xsl:if test='$VOICE.count=1'>
              <text>voice</text>
            </xsl:if>
            <xsl:if test='$FAX.count=1'>
              <text>fax</text>
            </xsl:if>
            <xsl:if test='$CELL.count=1'>
              <text>cell</text>
            </xsl:if>
            <xsl:if test='$VIDEO.count=1'>
              <text>video</text>
            </xsl:if>
            <xsl:if test='$PAGER.count=1'>
              <text>pager</text>
            </xsl:if>
            <xsl:if test='$TEXTPHONE.count=1'>
              <text>texphone</text>
            </xsl:if>
          </type>
          <xsl:if test='$PREF.count=1'>
            <pref><integer>1</integer></pref>
          </xsl:if>
        </parameters>
      </xsl:if>
      <xsl:if test='$NUMBER.count=1'>
        <uri><xsl:text>tel:</xsl:text><xsl:value-of select='NUMBER'/></uri>
      </xsl:if>
    </tel>
  </xsl:template>

  <xsl:template match='EMAIL'>
    <email>
      <xsl:variable name='HOME.count' select='count(HOME)'/>
      <xsl:variable name='WORK.count' select='count(WORK)'/>

      <!-- NOTE: vcard-temp allowed email types of INTERNET
           and X400, but they were never in vCard3 -->

      <xsl:variable name='PREF.count' select='count(PREF)'/>
      <xsl:variable name='USERID.count' select='count(USERID)'/>

      <!-- first we count the number of vCard TYPE parameters -->

      <xsl:variable name='TYPE.count' select='$HOME.count + $WORK.count'/>

      <!-- now we output all the parameters -->

      <xsl:if test='$TYPE.count &gt; 0'>
        <parameters>
          <type>
            <xsl:if test='$HOME.count=1'>
              <text>home</text>
            </xsl:if>
            <xsl:if test='$WORK.count=1'>
              <text>work</text>
            </xsl:if>
          </type>
          <xsl:if test='$PREF.count=1'>
            <pref><integer>1</integer></pref>
          </xsl:if>
        </parameters>
      </xsl:if>
      <xsl:if test='$USERID.count=1'>
        <text><xsl:value-of select='USERID'/></text>
      </xsl:if>
    </email>
  </xsl:template>

</xsl:stylesheet>
]]></code>
  </section2>
  <section2 topic='Example of vcard-temp Data' anchor='migration-vcardtemp'>
    <code><![CDATA[
<vCard>
  <FN>Peter Saint-Andre</FN>
  <N>
    <FAMILY>Saint-Andre</FAMILY>
    <GIVEN>Peter</GIVEN>
    <MIDDLE/>
  </N>
  <NICKNAME>stpeter</NICKNAME>
  <NICKNAME>psa</NICKNAME>
  <PHOTO><EXTVAL>http://stpeter.im/images/stpeter_oscon.jpg</EXTVAL></PHOTO>
  <PHOTO><EXTVAL>http://stpeter.im/images/stpeter_hell.jpg</EXTVAL></PHOTO>
  <BDAY>1966-08-06</BDAY>
  <ADR>
    <WORK/>
    <PREF/>
    <EXTADD>Suite 600</EXTADD>
    <STREET>1899 Wynkoop Street</STREET>
    <LOCALITY>Denver</LOCALITY>
    <REGION>CO</REGION>
    <PCODE>80202</PCODE>
    <CTRY>USA</CTRY>
  </ADR>
  <ADR>
    <HOME/>
    <EXTADD/>
    <STREET/>
    <LOCALITY>Parker</LOCALITY>
    <REGION>CO</REGION>
    <PCODE>80138</PCODE>
    <CTRY>USA</CTRY>
  </ADR>
  <TEL><PREF/><WORK/><VOICE/><NUMBER>+1-303-308-3282</NUMBER></TEL>
  <TEL><WORK/><FAX/><NUMBER>+1-303-308-3219</NUMBER></TEL>
  <TEL><CELL/><VOICE/><TEXT/><NUMBER>+1-720-256-6756</NUMBER></TEL>
  <TEL><HOME/><VOICE/><NUMBER>+1-303-555-1212</NUMBER></TEL>
  <EMAIL><INTERNET/><PREF/><USERID>stpeter@jabber.org</USERID></EMAIL>
  <EMAIL><WORK/><USERID>psaintan@cisco.com</USERID></EMAIL>
  <JABBERID>stpeter@jabber.org</JABBERID>
  <TZ>America/Denver</TZ>
  <GEO><LAT>39.59</LAT><LON>-105.01</LON></GEO>
  <TITLE>Executive Director</TITLE>
  <ROLE>Patron Saint</ROLE>
  <LOGO>
    <TYPE>image/jpeg</TYPE>
    <BINVAL>
[encoded data, 5698 characters]
0vx/+oqw7D4D8qysrzcv7jro/9k=
    </BINVAL>
  </LOGO>
  <ORG>
    <ORGNAME>XMPP Standards Foundation</ORGNAME>
    <ORGUNIT/>
  </ORG>
  <URL>https://stpeter.im/</URL>
  <URL>http://www.saint-andre.com/</URL>
  <KEY>
    <CRED>
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.18 (Darwin)

mQINBFETDzsBEAC0FOv1N3ZJzIIxN6cKD475KVS9CHDPeYpegcOIPnL5eY1DCHeh
/IwS1S7RCePtmiybNoV9FsI4PKUknzXQxA6LVEdAR/LUlhgJKjq+gsgp8lqbEILh
g13ecH66HwLS9rarbQkC47T7kL8miIPBFC6E3A4Lq1L+eueO6UcLhKgoYkMxOjdi
WrMgKTnVpch5ydLkPm/z0Zo8zRgqlPuTLeCrXXZYnjHXLVFN2xy04UzOs7P5u5KV
fx5Z7uQisr8pXtyLd6SpTZo6SHgKBv15uz0rqXhsJojiGtOXfWznAjaS5FUOORq9
CklG5cMOUAT8TNftv0ktsxaWDL1ELDV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VLHgGgj79zzL3uhML26
63m7imShvz1QcHTwvyR5i8cZbNOEkotZyERiA1p7YHuruS+QvTi3ZPoQbnMUB3a7
py9d11bw1+w3LiAUGZE/z5hBWOFxYtw+w/U/Vx0BwJGYlwU3M2W20uEXe+qxz7wn
akygKjmLiD2z4njfKjcNCiV3FmXrpmWgADln1c4jfxDh0NrndrsM8FPDf1TMPtOZ
gFDkKripc9xkZ/25P6xn27oTOHWKcAC0QhxSH+HuVBBRk8AgF+zAbDZe4/L6+kan
SrycIXW+wCzwBq61aWsz2QhhuKjozVkhk4dRG+CfjzAFjnyxwYERn3uXVKQAwTwc
dNcTI9RV98IsNrw9Y4lJEAg6CjNPmiD5+EASycqaOuToRSGukr8sOQLWLPyTnez/
aG8Xf7a+fntWzK2HuDYoSDhJJrylWw/lMklOBm4wtMeNA0zcQH6AQV/GzQVQkSGq
rLuMVIV/
=llGw
-----END PGP PUBLIC KEY BLOCK-----
    </CRED>
  </KEY>
  <DESC>
    More information about me is located on my
    personal website: https://stpeter.im/
  </DESC>
</vCard>
]]></code>
  </section2>
  <section2 topic='Example of vCard4 XML Data' anchor='migration-vcard4'>
    <code><![CDATA[
<vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0">
  <fn>
    <text>Peter Saint-Andre</text>
  </fn>
  <n>
    <surname>Saint-Andre</surname>
    <given>Peter</given>
    <additional></additional>
  </n>
  <nickname>
    <text>stpeter</text>
  </nickname>
  <nickname>
    <text>psa</text>
  </nickname>
  <photo>
    <uri>http://stpeter.im/images/stpeter_oscon.jpg</uri>
  </photo>
  <photo>
    <uri>http://stpeter.im/images/stpeter_hell.jpg</uri>
  </photo>
  <bday>
    <date>1966-08-06</date>
  </bday>
  <adr>
    <parameters>
      <type><text>work</text></type>
      <pref><integer>1</integer></pref>
    </parameters>
    <ext>Suite 600</ext>
    <street>1899 Wynkoop Street</street>
    <locality>Denver</locality>
    <region>CO</region>
    <code>80202</code>
    <country>USA</country>
  </adr>
  <adr>
    <parameters><type><text>home</text></type></parameters>
    <ext></ext>
    <street></street>
    <locality>Parker</locality>
    <region>CO</region>
    <code>80138</code>
    <country>USA</country>
  </adr>
  <tel>
    <parameters>
      <type><text>work</text><text>voice</text></type>
      <pref><integer>1</integer></pref>
    </parameters>
    <uri>tel:+1-303-308-3282</uri>
  </tel>
  <tel>
    <parameters>
      <type><text>work</text><text>fax</text></type>
    </parameters>
    <uri>tel:+1-303-308-3219</uri>
  </tel>
  <tel>
    <parameters>
      <type><text>cell</text><text>voice</text><text>text</text></type>
    </parameters>
    <uri>tel:+1-720-256-6756</uri>
  </tel>
  <tel>
    <parameters>
      <type><text>home</text><text>voice</text></type>
    </parameters>
    <uri>tel:+1-303-555-1212</uri>
  </tel>
  <email>
    <text>stpeter@jabber.org</text>
  </email>
  <email>
    <parameters>
      <type><text>work</text></type>
    </parameters>
    <text>psaintan@cisco.com</text>
  </email>
  <impp>
    <uri>xmpp:stpeter@jabber.org</uri>
   </impp>
   <tz>
     <text>America/Denver</text>
   </tz>
   <geo>
     <uri>geo:39.59,-105.01</uri>
   </geo>
   <title>
     <text>Executive Director</text>
   </title>
   <role>
     <text>Patron Saint</text>
   </role>
   <logo>
     <uri>data:image/jpeg;base64,
[encoded data, 5698 characters]
0vx/+oqw7D4D8qysrzcv7jro/9k=
      </uri>
    </logo>
    <org>
      <text>XMPP Standards Foundation</text>
    </org>
    <url>
      <uri>https://stpeter.im/</uri>
    </url>
    <url>
      <uri>http://www.saint-andre.com/</uri>
    </url>
    <key>
      <text>
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.18 (Darwin)

mQINBFETDzsBEAC0FOv1N3ZJzIIxN6cKD475KVS9CHDPeYpegcOIPnL5eY1DCHeh
/IwS1S7RCePtmiybNoV9FsI4PKUknzXQxA6LVEdAR/LUlhgJKjq+gsgp8lqbEILh
g13ecH66HwLS9rarbQkC47T7kL8miIPBFC6E3A4Lq1L+eueO6UcLhKgoYkMxOjdi
WrMgKTnVpch5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2LGlAuQoJNILTZQ318yTP+E5QU7fJH7FVsoh
UyvrMfyt3IMA9jg0Z9MuloLezvIjjMfFeNa0ROgDb/ubOT7JQzi1kwN8Lu3lO80H
wqBHXEeOLoislUSnZajRKvITbKWkZ6PHRjlMw1Wk4oIi6VLHgGgj79zzL3uhML26
63m7imShvz1QcHTwvyR5i8cZbNOEkotZyERiA1p7YHuruS+QvTi3ZPoQbnMUB3a7
py9d11bw1+w3LiAUGZE/z5hBWOFxYtw+w/U/Vx0BwJGYlwU3M2W20uEXe+qxz7wn
akygKjmLiD2z4njfKjcNCiV3FmXrpmWgADln1c4jfxDh0NrndrsM8FPDf1TMPtOZ
gFDkKripc9xkZ/25P6xn27oTOHWKcAC0QhxSH+HuVBBRk8AgF+zAbDZe4/L6+kan
SrycIXW+wCzwBq61aWsz2QhhuKjozVkhk4dRG+CfjzAFjnyxwYERn3uXVKQAwTwc
dNcTI9RV98IsNrw9Y4lJEAg6CjNPmiD5+EASycqaOuToRSGukr8sOQLWLPyTnez/
aG8Xf7a+fntWzK2HuDYoSDhJJrylWw/lMklOBm4wtMeNA0zcQH6AQV/GzQVQkSGq
rLuMVIV/
=llGw
-----END PGP PUBLIC KEY BLOCK-----
      </text>
    </key>
    <note>
      <text>
More information about me is located on my
personal website: https://stpeter.im/
    </text>
  </note>
</vcard>
]]></code>
  </section2>
</section1>

<section1 topic='Acknowledgements' anchor='acks'>
  <p>Thanks to Dave Cridland, Todd Herman, Joe Hildebrand, Waqas Hussain, and Matt Miller for their feedback.</p>
</section1>

</xep>
