Network Working Group                                           E. Wilde
Internet-Draft                                             June 27, 2016
Intended status: Informational
Expires: December 29, 2016

                Home Documents for HTTP APIs: XML Syntax


   The specification for HTTP API Home Documents provides a JSON syntax
   only.  This specification provides an XML syntax for the same data
   model, so that the concept of Home Documents can be consistently
   exposed in both JSON- and XML-based HTTP APIs.  It also defines the
   link relation type "home" so that applications can identify links to
   home documents.

Note to Readers

   Please discuss this draft on the apps-discuss mailing list

   Online access to all versions and files is available on GitHub

Status of This Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on December 29, 2016.

Copyright Notice

   Copyright (c) 2016 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

Wilde                   Expires December 29, 2016               [Page 1]

Internet-Draft             Home Documents XML                  June 2016

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   ( in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

1.  Introduction

   "Home Documents for HTTP APIs" [I-D.nottingham-json-home] proposes
   the concept of "Home Documents" and describes them as follows:

   "This document proposes a 'home document' format for non-browser HTTP
   clients. [...] The goal of home documents is to serve as a starting
   point for hypermedia APIs, where clients need to have an entry point,
   and then can use the API by following links.  Home documents thus
   serve the same purpose as home pages on web sites: They are stable
   entry points that provide starting points for clients with some
   knowledge of the services linked from them."

   While this general concept of a home document is independent of the
   representation format, the specification only defines a JSON syntax.
   In order to make this concept available across representations, this
   specification defines an XML syntax for the concepts defined in

   One notable difference is the handling of links found in "href" or
   "href-template" attributes of "resource" elements: In the JSON
   syntax, these are (if they are relative URIs) resolved against the
   URI of the home document itself.  The XML syntax adds support for an
   optional "xml:base" attribute [W3C.REC-xmlbase-20090128] on the
   "resources" document element.  If this attribute is present, it has
   to be used according to its specification, and thus becomes part of a
   possible resolution chain of relative URIs.

2.  XML Example

   The following Home Document in XML syntax uses the same data as the
   Home Document shown in Section 2 [1] of [I-D.nottingham-json-home]
   (but adding xml:base="" to demonstrate the

Wilde                   Expires December 29, 2016               [Page 2]

Internet-Draft             Home Documents XML                  June 2016

<?xml-stylesheet type="text/xsl" href="home-xml-02.xslt"?>
<resources xmlns:xsi=""
 xsi:schemaLocation="urn:ietf:params:xml:ns:homedoc home-xml.xsd"
 xmlns="urn:ietf:params:xml:ns:homedoc" xml:base=",2016:">
 <resource rel="">
  <link href="/widgets"/>
 <resource rel="widgets">
  <template href-template="/widgets/{widget_id}">
   <var name="widget_id" URI="widget"/>
    <format mediatype="application/json"/>

   The mapping between JSON arrays and XML uses "item" elements <i/>,
   where each of those elements represents one array item.  For
   properties that have a single values (i.e., they are not defined as
   an array of values), this value is directly contained as content in
   the corresponding element.

   Currently, the draft does not specify an extension model (how to
   represents hints that are not specified in the draft itself), and
   therefore the extension model for XML is currently undefined as well.
   The XML syntax will be updated to reflect the extension model once it
   has been specified for the JSON syntax.

Wilde                   Expires December 29, 2016               [Page 3]

Internet-Draft             Home Documents XML                  June 2016

3.  XML Schema

   The following XML Schema is describing the XML shown in Section 2.
   Since there currently is no extension model, the XML Schema does
   currently not contain any extension points.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="" xmlns:xml="" targetNamespace="urn:ietf:params:xml:ns:homedoc" elementFormDefault="qualified" xmlns:home="urn:ietf:params:xml:ns:homedoc">
 <xs:import namespace="" schemaLocation=""/>
 <xs:element name="resources">
   <xs:sequence maxOccurs="unbounded" minOccurs="0">
    <xs:element name="resource">
        <xs:element name="link">
          <xs:attribute name="href" type="xs:anyURI" use="required"/>
        <xs:element name="template">
          <xs:sequence maxOccurs="unbounded" minOccurs="0">
           <xs:element name="var">
             <xs:attribute name="name" use="required"/>
             <xs:attribute name="URI" type="xs:anyURI" use="required"/>
          <xs:attribute name="href-template" use="required"/>
       <xs:element minOccurs="0" name="hints">
         <xs:choice maxOccurs="unbounded" minOccurs="0">
          <xs:element name="allow" type="home:arrayType"/>
          <xs:element name="formats">
             <xs:element name="format">
               <xs:attribute name="mediatype" type="home:mediaTypeType"/>

Wilde                   Expires December 29, 2016               [Page 4]

Internet-Draft             Home Documents XML                  June 2016

          <xs:element name="accept-patch" type="home:mediaTypeArrayType"/>
          <xs:element name="accept-post" type="home:mediaTypeArrayType"/>
          <xs:element name="accept-ranges" type="home:arrayType"/>
          <xs:element name="accept-prefer" type="home:arrayType"/>
          <xs:element name="docs" type="xs:anyURI"/>
          <xs:element name="precondition-req" type="home:arrayType"/>
          <xs:element name="auth-req">
            <xs:sequence maxOccurs="unbounded" minOccurs="0">
             <xs:element name="scheme">
               <xs:sequence maxOccurs="unbounded" minOccurs="0">
                <xs:element name="realm"/>
               <xs:attribute name="name" type="xs:token"/>
          <xs:element name="status">
            <xs:restriction base="xs:token">
             <xs:enumeration value="deprecated"/>
             <xs:enumeration value="gone"/>
      <xs:attribute name="rel" type="xs:anyURI" use="required"/>
   <xs:attribute ref="xml:base" use="optional"/>
 <xs:simpleType name="mediaTypeType">
  <xs:restriction base="xs:string"/>
 <xs:complexType name="arrayType">
  <xs:sequence maxOccurs="unbounded" minOccurs="0">
   <xs:element name="i"/>

Wilde                   Expires December 29, 2016               [Page 5]

Internet-Draft             Home Documents XML                  June 2016

 <xs:complexType name="mediaTypeArrayType">
  <xs:sequence maxOccurs="unbounded" minOccurs="0">
   <xs:element name="i" type="home:mediaTypeType"/>

4.  IANA Considerations

   This specification registers a media type and an XML namespace URI
   for the XML syntax of Home Documents (as defined in

4.1.  Media Type application/home+xml

   The Internet media type [RFC6838] for a Home Document in XML syntax
   is application/home+xml.

   Type name: application

   Subtype name: home+xml

   Required parameters: none

   Optional parameters: Same as charset parameter for the media type
   "application/xml" as specified in RFC 3023 [RFC3023].

   Encoding considerations: Same as encoding considerations of media
   type "application/xml" as specified in RFC 3023 [RFC3023].

   Security considerations: This media type has all of the security
   considerations described in RFC 3023 [RFC3023] and

   Interoperability considerations: N/A

   Published specification: RFC XXXX

   Applications that use this media type: Applications that publish Home
   Documents for HTTP services using XML syntax.

   Additional information:

      Magic number(s): N/A

      File extension(s): XML documents should use ".xml" as the file

Wilde                   Expires December 29, 2016               [Page 6]

Internet-Draft             Home Documents XML                  June 2016

      Macintosh file type code(s): TEXT

   Person & email address to contact for further information: Erik Wilde

   Intended usage: COMMON

   Restrictions on usage: none

   Author: Erik Wilde <>

   Change controller: IETF

4.2.  XML Namespace Registration

   This document registers the following XML namespaces in the IETF XML
   registry defined in [RFC3688].

   URI: urn:ietf:params:xml:ns:homedoc

   Registrant: The IESG.

   XML: N/A, the requested URI is an XML namespace defined by an RFC.

4.3.  Link Relation Type

   The link relation type below has been registered by IANA per
   Section 6.2.1 of RFC 5988 [RFC5988]:

4.3.1.  Link Relation Type: home

      Relation Name: home

      Description: Identifies a resource that provides a "home" document
      for the context resource.  Home documents often serve as starting
      points for a certain resource context, such as for Web APIs where
      the home resource provides access to a number of "entry points" to
      the Web API.

      Reference: RFC XXXX

5.  Implementation Status

   Note to RFC Editor: Please remove this section before publication.

   This section records the status of known implementations of the
   protocol defined by this specification at the time of posting of this
   Internet-Draft, and is based on a proposal described in RFC 6982

Wilde                   Expires December 29, 2016               [Page 7]

Internet-Draft             Home Documents XML                  June 2016

   [RFC6982].  The description of implementations in this section is
   intended to assist the IETF in its decision processes in progressing
   drafts to RFCs.  Please note that the listing of any individual
   implementation here does not imply endorsement by the IETF.
   Furthermore, no effort has been spent to verify the information
   presented here that was supplied by IETF contributors.  This is not
   intended as, and must not be construed to be, a catalog of available
   implementations or their features.  Readers are advised to note that
   other implementations may exist.

   According to RFC 6982, "this will allow reviewers and working groups
   to assign due consideration to documents that have the benefit of
   running code, which may serve as evidence of valuable experimentation
   and feedback that have made the implemented protocols more mature.
   It is up to the individual working groups to use this information as
   they see fit".

   For a list of implementations, please refer to the wiki that tracks
   implementations for the Home Document specification in general:


6.  Security Considerations

   The general security considerations for XML home documents are the
   same as those for JSON home documents, as described in the "Security
   Considerations" of [I-D.nottingham-json-home].  The specific security
   considerations introduced by XML as a representation format are
   described in the "Security Considerations" of [RFC3023].

7.  Open Issues

   o  The move from a predefined list of hints to a hint registry is not
      yet reflected in the XML; in particular because the draft defines
      the hint data model to be JSON-specific.

   o  What is the extension model for the XML syntax?  Should processing
      of other namespaces be defined as "should ignore", so that same-
      namespace extensions are encouraged?

   o  Should the XML syntax provide support for embedded human-readable
      documentation?  This would probably not be supported in the JSON
      syntax, but could be marked as strictly optional and XML-specific.

Wilde                   Expires December 29, 2016               [Page 8]

Internet-Draft             Home Documents XML                  June 2016

8.  References

8.1.  Normative References

              Nottingham, M., "Home Documents for HTTP APIs", draft-
              nottingham-json-home-04 (work in progress), May 2016.

   [RFC3023]  Murata, M., St. Laurent, S., and D. Kohn, "XML Media
              Types", RFC 3023, January 2001.

   [RFC3688]  Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688,
              DOI 10.17487/RFC3688, January 2004,

   [RFC5988]  Nottingham, M., "Web Linking", RFC 5988, October 2010.

   [RFC6838]  Freed, N., Klensin, J., and T. Hansen, "Media Type
              Specifications and Registration Procedures", BCP 13,
              RFC 6838, January 2013.

              Sperberg-McQueen, C., Yergeau, F., Paoli, J., Maler, E.,
              and T. Bray, "Extensible Markup Language (XML) 1.0 (Fifth
              Edition)", World Wide Web Consortium Recommendation REC-
              xml-20081126, November 2008,

              Marsh, J. and R. Tobin, "XML Base (Second Edition)", World
              Wide Web Consortium Recommendation REC-xmlbase-20090128,
              January 2009,

8.2.  Informative References

              Clark, J., "XSL Transformations (XSLT) Version 1.0", World
              Wide Web Consortium Recommendation REC-xslt-19991116,
              November 1999,

              Pieters, S., Clark, J., and H. Thompson, "Associating
              Style Sheets with XML documents 1.0 (Second Edition)",
              World Wide Web Consortium Recommendation REC-xml-
              stylesheet-20101028, October 2010,

Wilde                   Expires December 29, 2016               [Page 9]

Internet-Draft             Home Documents XML                  June 2016

   [RFC6982]  Sheffer, Y. and A. Farrel, "Improving Awareness of Running
              Code: The Implementation Status Section", RFC 6982, July

8.3.  URIs


Appendix A.  XML-to-HTML for Home Documents

   The following XSLT 1.0 stylesheet [W3C.REC-xslt-19991116] transforms
   XML Home Documents to very simple HTML renditions.  By associating
   this stylesheet [W3C.REC-xml-stylesheet-20101028] with an XML Home
   Document, it is possible to serve XML Home Documents that will be
   rendered in a human-friendly way when viewed in a browser.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="" xmlns:xml="" version="1.0" xmlns:home="urn:ietf:params:xml:ns:homedoc" exclude-result-prefixes="home">
 <xsl:output method="html"/>
 <xsl:template match="home:resources">
    <title>Home Document</title>
    <h1>Home Document</h1>
     <xsl:for-each select="home:resource">
       <xsl:text>Link Relation </xsl:text>
       <code><xsl:value-of select="@rel"/></code>
       <xsl:text>: Link </xsl:text>
         <xsl:when test="home:link">
          <xsl:variable name="link-URI">
           <xsl:call-template name="resolve-URI">
            <xsl:with-param name="URI" select="home:link/@href"/>
          <a href="{$link-URI}" title="URI"><xsl:value-of select="$link-URI"/></a>
          <xsl:variable name="template-URI">
           <xsl:call-template name="resolve-URI">
            <xsl:with-param name="URI" select="home:template/@href-template"/>

Wilde                   Expires December 29, 2016              [Page 10]

Internet-Draft             Home Documents XML                  June 2016

          <a href="{$template-URI}" title="URI template"><xsl:value-of select="$template-URI"/></a>
        <xsl:if test="home:template/home:var">
         <dt>Variables: </dt>
           <xsl:for-each select="home:template/home:var">
            <xsl:sort select="@name"/>
             <span title="Variable Name"><xsl:value-of select="@name"/></span>
             <xsl:text>: </xsl:text>
             <span title="Associated URI"><xsl:value-of select="@URI"/></span>
        <xsl:if test="home:hints">
         <dt>Hints: </dt>
           <xsl:for-each select="home:hints/home:*">
            <xsl:sort select="local-name()"/>
             <span title="Hint Name"><xsl:value-of select="local-name()"/></span>
             <xsl:text>: </xsl:text>
              <xsl:when test="home:i">
               <xsl:for-each select="home:i">
                <xsl:value-of select="."/>
                <xsl:if test="position() != last()">
                 <xsl:text>, </xsl:text>
               <xsl:value-of select="."/>

Wilde                   Expires December 29, 2016              [Page 11]

Internet-Draft             Home Documents XML                  June 2016

 <xsl:template name="resolve-URI">
  <xsl:param name="URI"/>
  <!-- This is not how URI resolution should be done; describes the correct process. -->
  <xsl:value-of select="concat(/home:resources/@xml:base, $URI)"/>

Author's Address

   Erik Wilde


Wilde                   Expires December 29, 2016              [Page 12]