<?xml version="1.0"?>
<rfc category="std" ipr="full3978" docName="draft-neutron-protocol-0.txt">
  <front>
    <title>The Neutron 1.0 Protocol</title>


    <author initials="M.W." surname="Wechner" fullname="Michael Wechner" role="editor">
      <organization>Wyona</organization>

      <address>
        <postal>
          <street>Hardstrasse 219</street>

          <city>Zurich</city>

          <region>Zurich</region>

          <code>8005</code>

          <country>CH</country>

        </postal>

        <phone>+41 44 272 91 61</phone>

        <email>michael.wechner@wyona.com</email>

        <uri>http://www.wyona.com</uri>

      </address>

    </author>


    <author initials="A.W." surname="Wuest" fullname="Andreas Wuest" role="editor">
      <organization>Wyona</organization>

      <address>
        <postal>
          <street>Hardstrasse 219</street>

          <city>Zurich</city>

          <region>Zurich</region>

          <code>8005</code>

          <country>CH</country>

        </postal>

        <phone>+41 44 272 91 61</phone>

        <email>awuest@student.ethz.ch</email>

        <uri>http://www.wyona.com</uri>

      </address>

    </author>


    <author initials="T.C." surname="Comiotto" fullname="Thomas Comiotto" role="editor">
      <organization>Unicom (University of Zurich)</organization>

      <address>
        <phone>+41 44 634 51 31</phone>

        <email>thomas.comiotto@unicom.unizh.ch</email>

      </address>

    </author>


    <date day="13" month="July" year="2007"/>


    <abstract>
      <t>The Neutron Protocol is an XML-based application-level protocol for remote content authoring. Neutron provides a generic API to what common Content Management Systems (CMS) support with respect to content authoring.</t>

    </abstract>


    <note title="Editorial Note">
      <t>To provide feedback on this Internet-Draft, join the <eref target="http://wyona.com/cgi-bin/mailman/listinfo/osr-101/">OSR-101 mailing list (http://wyona.com/cgi-bin/mailman/listinfo/osr-101/)</eref>
.</t>

    </note>

  </front>


  <middle>
    <section title="Introduction">
      <t>Neutron 1.0 is an xml-based application level protocol for remote content authoring. Neutron provides a set of methods and configuration directives that allow for:</t>

      <t>
        <list style="symbols">
          <t>concurrent access to resources</t>

          <t>creating resources based on templates</t>

          <t>providing styling information for resources</t>

          <t>metadata handling</t>

          <t>accessing revisions</t>

          <t>custom authentication schemes</t>

          <t>and more</t>

        </list>

      </t>

      <t>Neutron has been been started as an effort to provide a generic API to what common Content Management Systems (CMS) support with respect to content authoring. CMS vendors usually implement their own frontend components for content authoring and/or implement a public API for third party component integration. Neutron is ment to be an open standard that leverages integration and reuse of third party components such as editing applications or standalone clients targeted at offline operation. While targeted at large scale content management systems, Neutron can also be used for accessing lightweight content repositories, datastores or remote file systems.</t>

      <t>Neutron is typically used over HTTP. However, Neutron can be run on top of any other transport protocol if feasable.</t>

      <t>Neutron provides a comprehensive set of instructions for dealing with XML-based resources. Usage of XML-based resources is not required though. Neutron also covers transactions of binary, SGML or other custom formatted data while being extensible enough for integrators to deal with the data formats of their choice.</t>

      <t>Compared to other open content authoring standards Neutron is higher-level than WebDAV and lower-level than Atom, to name two prominent examples in that field. While WebDAV operates on Web resources Neutron operates on content servers that might expose their resources to the web. While Atom is targeted at content syndication Neutron provides a generic API to content authoring.</t>

      <t>For examples and usage patterns see <xref target="examples"/>
.</t>

    </section>


    <section title="Introspection Object">
      <t>
        The core of the Neutron Protocol consists of the introspection object. The introspection object contains information about one or more resources, in terms of what operations can be performed on those resources, and how.
      </t>

      <t>
        The same introspection object can be bound to one or multiple resources (i.e. it can be auto-discovered through these resources), and can in turn contain information about one or multiple resources. The introspection object is not required to contain information about the object to which it was bound, but it is recommended to do so.
      </t>

      <t>
        Note that it might not be possible to bind an introspection object to a specific resource. Namely, it may not be possible to bind it to e.g. an ODT document, and therefore it is not possible to discover the introspection object when processing the ODT document. In such cases, the introspection object should either be bound to a nearby object, or the contents of the introspection object should be merged with the contents of a nearby introspection object.
      </t>

    <section title="Auto-Discovery of Introspection">
      <t>
        A client supporting HTML/XHTML (like e.g. <eref target="http://www.yulup.org">Yulup</eref>
) can discover the introspection object through a Neutron specific "&lt;link>" within the HTML head.
      </t>

      <t>
        The "&lt;link>" element MUST contain the following attributes:
      </t>

      <t>
        <list style="hanging">
          <t hangText="rel">The "rel" attribute of the "&lt;link>" element MUST be set to "neutron-introspection".</t>

          <t hangText="type">The "type" attribute of the "&lt;link>" element MUST be set to "application/neutron+xml".</t>

          <t hangText="href">The "href" attribute MUST contain the URI pointing to the introspection object. If this URI is relative, a client MUST resolve the URI relative to the URI of the document in which the "&lt;link>" element is contained.</t>

        </list>

      </t>

      <section title="Example">
        <figure title="Introspection Auto-Discovery Example">
          <artwork>
&lt;html>
  &lt;head>
    &lt;link rel="neutron-introspection" type="application/neutron+xml" href="introspection-hello-world.xml"/>
    &lt;title>Hello World&lt;/title>
    ...
  &lt;/head>
  ...
&lt;/html>
          </artwork>

        </figure>

      </section>


      <section title="Mime Type">
        <t>The mime type of an introspection document which is being returned by the server to the client is "application/xml". Please note that the mime type refered to within this section is independent of the type declaration within the introspection link.</t>

      </section>

    </section>

    </section>


   <section title="Neutron HTTP Headers">
      <t>WWW-Authenticate: Neutron-Auth</t>

      <t>Neutron: 1.0, 2.0-dev / en</t>

    </section>


    <section title="Editing Resources">
      <section title="Opening and Saving without Locking">
        <t>URLs are being resolved relative to the introspection URL. Empty URLs refer to the introspection URL itself.</t>

        <section title="Introspection Example">
          <figure title="Example: Opening and Saving of an XHTML document without Locking">
            <artwork>
&lt;?xml version="1.0"?>

&lt;introspection xmlns="http://www.wyona.org/neutron/1.0">
  &lt;edit mime-type="application/xhtml+xml" name="Homepage">
    &lt;open url="index.xhtml" method="GET"/>
    &lt;save url="index.xhtml?yanel.resource.usecase=save" method="POST"/>
  &lt;/edit>
&lt;/introspection>
            </artwork>

          </figure>


          <figure title="Example: Opening and Saving of an XML document with an XSLT associated without Locking">
            <artwork>
&lt;?xml version="1.0"?>

&lt;introspection xmlns="http://www.wyona.org/neutron/1.0">
  &lt;edit mime-type="application/xml" name="Calendar">
    &lt;open url="calendar.xml" method="GET"/>
    &lt;save url="calendar.xml?yanel.resource.usecase=save" method="POST"/>
    &lt;styles>
      &lt;style href="calendar2xhtml.xsl"/>
    &lt;/styles>
  &lt;/edit>
&lt;/introspection>
            </artwork>

          </figure>

        </section>


        <section title="Opening a Resource">
          <t>To open a resource, clients use the URL and METHOD specified within the introspection.</t>

        </section>


        <section title="Saving a Resource">
          <t>
            To save a resource, clients use the URL and METHOD specified within the introspection.
          </t>

          <t>
            The server responds with a status code of 200 and the content which has been saved as a response. Please note that server might change the received content (e.g. last modified date) and hence the client is able to become aware of such changes.
          </t>

        </section>

      </section>


      <section title="Opening and Saving with Locking">
        <section title="Introspection Example">
          <figure title="Opening and Saving with Locking Example">
            <artwork>
&lt;?xml version="1.0"?>

&lt;introspection xmlns="http://www.wyona.org/neutron/1.0">
  &lt;edit mime-type="application/xhtml+xml" name="Homepage">
    &lt;checkout url="index.xhtml?yanel.resource.usecase=checkout" method="GET"/>
    &lt;checkin url="index.xhtml?yanel.resource.usecase=checkin" method="PUT"/>
  &lt;/edit>
&lt;/introspection>
            </artwork>

          </figure>

        </section>


        <section title="Opening a Resource">
          <t>
            To open a resource, clients use the URL and METHOD specified within the introspection.
          </t>

          <t>
            The server acquires a lock and responds with the data of the resource.
          </t>

        </section>


        <section title="Saving a Resource">
          <t>
            To save a resource, clients use the URL and METHOD specified within the introspection.
          </t>

          <t>
            The server releases the previously acquired lock and responds with a status code of 200.
          </t>

        </section>

      </section>

    </section>


    <section title="Creating Resources">
      <t>In order to create a resource the server needs to provide a resource navigation, e.g. a sitetree</t>

      <section title="Introspection Example">
        <figure>
          <artwork>
&lt;?xml version="1.0"?>

&lt;introspection xmlns="http://www.wyona.org/neutron/1.0">
  &lt;navigation>
    &lt;sitetree href="sitetree.xml" method="GET"/>
    &lt;--
    &lt;sitetree href="/" method="PROPFIND"/>
    -->
    &lt;--
    &lt;topicmap href="topicmap.xtm" method="GET"/>
    -->
  &lt;/navigation>
&lt;/introspection>
          </artwork>

        </figure>

      </section>


      <section title="Response">
<t>Also see <eref target="http://www.webdav.org/specs/rfc2518.html">http://www.webdav.org/specs/rfc2518.html</eref>
</t>

<figure>
<artwork>
&lt;multistatus xmlns="DAV:">
  &lt;response>
    &lt;href>/yanel/osr-101/amendments/index.html?yanel.webdav=propfind1&lt;/href>
    &lt;propstat>
      &lt;prop>
        &lt;displayname>index.html&lt;/displayname>
        &lt;resourcetype/>
        &lt;getcontenttype>application/xhtml+xml&lt;/getcontenttype>
        &lt;source>
          &lt;link>
            &lt;src>/yanel/osr-101/amendments/index.html&lt;/src>
            &lt;dst>/yanel/osr-101/amendments/index.html?yanel.resource.modifiable.source&lt;/dst>
          &lt;/link>
        &lt;/source>
      &lt;/prop>
      &lt;status>HTTP/1.1 200 OK&lt;/status>
    &lt;/propstat>
  &lt;/respons>

  &lt;response>
    &lt;href>/yanel/osr-101/amendments/.svn/&lt;/href>
    &lt;propstat>
      &lt;prop>
        &lt;displayname>.svn&lt;/displayname>
        &lt;resourcetype>&lt;collection/>&lt;/resourcetype>
        &lt;getcontenttype>httpd/unix-directory&lt;/getcontenttype>
      &lt;/prop>
      &lt;status>HTTP/1.1 200 OK&lt;/status>
    &lt;/propstat>
  &lt;/response>
&lt;/multistatus>
</artwork>

</figure>

      </section>

    </section>


    <section title="Deleting Resources">
      <t>TBD</t>

    </section>


    <section title="NAR - Neutron Archive">
      <t>TBD</t>

    </section>


    <section title="Exceptions">
      <t>If a Neutron-capable client issues a request, the server can respond with exceptions. The following exceptions are defined by the Neutron protocol.</t>

      <t>Neutron exceptions have a root element "&lt;exception>" with a "type" attribute, specifying the kind of exception. This element then contains a "&lt;message>" element which can contain a human-readable representation of the exception.</t>

      <t>The second element is defined by the exception type (for details, see the various exception types below).</t>

      <section title="Authentication">
        <t>Note that this section is basically the specification of Neutron-Auth, a separate protocol which allows the authentication of clients using arbitrary inputs.</t>


        <t>A client supporting Neutron-Auth should always add "WWW-Authenticate: Neutron-Auth" to the HTTP header (beside the version of Neutron, e.g. Neutron: 1.0-dev) such that a server can respond accordingly.</t>
 

        <t>An example of a client-server coversation is as follows:</t>


        <t>Client Request: GET http://foo.bar/protected.xhtml HTTP/1.1..WWW-Authenticate: Neutron-Auth..Neutron: 1.0-dev..</t>


        <t>Server Response: HTTP/1.1 301 (or 307) https://foo.bar/protected.xhtml</t>


        <t>Client Request: GET https://foo.bar/protected.xhtml HTTP/1.1..WWW-Authenticate: Neutron-Auth..Neutron: 1.0-dev..</t>


        <t>Server Response: HTTP/1.1 401 Unauthorized..</t>

        <figure>
          <artwork>
&lt;?xml version="1.0"?>

&lt;exception xmlns="http://www.wyona.org/neutron/1.0" type="authorization">
  &lt;message>Authorization denied for https://foo.bar/protected.xhtml ...&lt;/message>

  &lt;authentication>
    &lt;login url="https://foo.bar/protected.xhtml?action=login-neutron">
      &lt;message>Login for realm 'Foo Bar' ...&lt;/message>
      &lt;form>
        &lt;param description="Username" name="username"/>
        &lt;param description="Password" name="passwd"/>
      &lt;/form>
    &lt;/login>
    &lt;logout url="http://foo.bar/?action=logout"/>
  &lt;/authentication>
&lt;/exception>
          </artwork>

        </figure>


        <t>Client Request: POST https://foo.bar/protected.xhtml?action=login-neutron</t>

        <figure>
          <artwork>
&lt;?xml version="1.0"?>

&lt;authentication xmlns="http://www.wyona.org/neutron/1.0">
  &lt;param name="username">lenya&lt;/param>
  &lt;param name="passwd">levi&lt;/param>
  &lt;original-request url="https://foo.bar/protected.xhtml"/>
&lt;/authentication>
          </artwork>

        </figure>

      </section>


      <t>(Please note that the above POST request by the client would actually be encrypted since https/SSL is being used, but for illustration plain text is displayed)</t>


      <t>Server Response: HTTP/1.1 200 OK.. or Server Response: HTTP/1.1 401 Unauthorized which gives a response body like</t>

      <figure>
        <artwork>
&lt;?xml version="1.0"?>

&lt;exception xmlns="http://www.wyona.org/neutron/1.0" type="authentication">
  &lt;message>Authentication failed!&lt;/message>
  &lt;authentication>
    &lt;original-request url="http://demo.yulup.org:80/editable-page-with-locking.xhtml?yanel.resource.usecase=checkout"/>
    &lt;login url="http://demo.yulup.org:80/editable-page-with-locking.xhtml?yanel.resource.usecase=checkout&amp;yanel.usecase=neutron-auth" method="POST">
      &lt;form>
        &lt;message>Enter username and password for "Yulup Demo" at "/demo/"&lt;/message>
        &lt;param description="Username" name="username"/>
        &lt;param description="Password" name="password"/>
      &lt;/form>
    &lt;/login>
    &lt;logout url="http://demo.yulup.org:80/editable-page-with-locking.xhtml?yanel.resource.usecase=checkout&amp;yanel.usecase=logout" realm="Yulup Demo"/>
  &lt;/authentication>
&lt;/exception>
        </artwork>

      </figure>


      <t>Client Request: GET https://foo.bar/protected.xhtml</t>


      <section title="Checkout">
        <figure>
          <artwork>
&lt;?xml version="1.0"?>

&lt;exception xmlns="http://www.wyona.org/neutron/1.0" type="checkout">
  &lt;message>Document has already been checked-out by ...&lt;/message>

  &lt;checkout url="/hello/world.html">
    &lt;locked-by>Jimi Hendrix&lt;/locked-by>
    &lt;lock-date format="standard">1969.10.03T15:34:26&lt;/lock-date>
    &lt;!-- Optional. Depending on server implementation -->
    &lt;break-lock url="/hello/world.html?yanel.resource.usecase=break-lock"/>
  &lt;/checkout>
&lt;/exception>
          </artwork>

        </figure>

        <t>How does the server respond to the "break-lock" request?</t>

        <t>
          <list style="symbols">
            <t>Server breaks lock, check-out for new user and returns content.</t>

            <t>Server breaks lock and returns lock broken successfully, please retry opening again ...</t>

            <t>Server responds breaking the lock failed for whatever reason.</t>

          </list>

        </t>

      </section>


      <section title="Checkin">
        <t>If the server cannot save the data, then it should return HTTP Status Code 500 and a message.</t>

        <figure>
          <artwork>
&lt;?xml version="1.0"?>

&lt;exception xmlns="http://www.wyona.org/neutron/1.0" type="checkin">
  &lt;message>Checkin failed, because document has been checked-out by ...&lt;/message>

  &lt;checkin url="/hello/world.html">
    &lt;locked-by>Jimi Hendrix&lt;/locked-by>
    &lt;lock-date format="standard">1969.10.03T15:34:26&lt;/lock-date>
    &lt;!-- Optional. Depending on server implementation -->
    &lt;break-lock url="/hello/world.html?yanel.resource.usecase=break-lock"/>
  &lt;/checkin>
&lt;/exception>
          </artwork>

        </figure>

      </section>


      <section title="Data Not Well-Formed">
        <t>If the server cannot save the data, then it should return HTTP Status Code 500 and a message.</t>

        <figure>
          <artwork>
&lt;?xml version="1.0"?>

&lt;exception xmlns="http://www.wyona.org/neutron/1.0" type="data-not-well-formed">
  &lt;message>Received data is not well-formed XML ...&lt;/message>

  &lt;data-not-well-formed url="/hello/world.html">
    &lt;line number="45" message="element not closed"/>
  &lt;/data-not-well-formed>
&lt;/exception>
          </artwork>

        </figure>

      </section>

    </section>


    <section title="Notational Conventions">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <xref target="RFC2119"/>
.</t>


      <section title="XML-related Conventions" anchor="xml-conv">
        <section title="Referring to Information Items" anchor="i-items">
          <t>Neutron Protocol Document formats are specified in terms of the XML Information Set <xref target="W3C.REC-xml-infoset-20040204"/>
, serialized as XML 1.0 <xref target="W3C.REC-xml-20060816"/>
.</t>

          <t>The Infoset terms "Element Information Item" and "Attribute Information Item" are shortened to "element" and "attribute" respectively. Therefore, when this specification uses the term "element", it is referring to an Element Information Item, and when it uses the term "attribute", it is referring to an Attribute Information Item.</t>

        </section>


        <section title="RELAX NG Schema">
          <t>Some sections of this specification are illustrated with fragments of a non-normative RELAX NG Compact schema <xref target="RNC"/>
. However, the text of this specification provides the definition of conformance. Complete schemas appear in <xref target="schema"/>
.  </t>

        </section>


        <section title="Use of xml:base and xml:lang" anchor="baselang">
          <t>XML elements defined by this specification MAY have an xml:base attribute <xref target="W3C.REC-xmlbase-20010627"/>
. When xml:base is used, it serves the function described in Section 5.1.1 of URI Generic Syntax <xref target="RFC3986"/>
, by establishing the base URI (or IRI) for resolving relative references found within the scope of the xml:base attribute.</t>


          <t>Any element defined by this specification MAY have an xml:lang attribute, whose content indicates the natural language for the element and its descendents. The language context is only significant for elements and attributes declared to be "Language-Sensitive" by this specification. Requirements regarding the content and interpretation of xml:lang are specified in Section 2.12 of XML 1.0 <xref target="W3C.REC-xml-20060816"/>
.</t>

        </section>

      </section>

    </section>


    <section title="Terminology" anchor="terminology">
      <t>For convenience, this protocol can be referred to as the "Neutron".</t>


      <t>URI/IRI - A Uniform Resource Identifier and Internationalized Resource Identifier.  These terms and the distinction between them are defined in <xref target="RFC3986"/>
 and <xref target="RFC3987"/>
. Before an IRI found in a document is used by HTTP, the IRI is first converted to a URI (see <xref target="model"/>
)</t>


      <t>The phrase "the URI of a document" in this specification is shorthand for "a URI which, when dereferenced, is expected to produce that document as a representation".</t>


      <t>Resource - A network-accessible data object or service identified by an IRI, as defined in <xref target="RFC2616"/>
. See <xref target="W3C.REC-webarch-20041215"/>
 for further discussion on resources.</t>


      <t>Representation - An entity included with a request or response as defined in <xref target="RFC2616"/>
.</t>


      <t>Collection - A resource that contains a set of Member Entries. See <xref target="collection_resource"/>
.</t>


      <t>Member - A resource whose IRI is listed in a Collection by a link element with a relation of "edit" or "edit-media".  See <xref target="memuri"/>
.</t>


      <t>Workspace - A group of collections. See <xref target="appdocs"/>
.</t>


      <t>Service Document - A document that describes the location and capabilities of one or more Collections.  See <xref target="appdocs"/>
.</t>


      <t>Category Document - A document that describes the categories allowed in a Collection.  See <xref target="catdocs"/>
.</t>

    </section>

  </middle>


  <back>
  

    <references title="Informative References">
    
      <reference anchor="RNC">
        <front>
          <title>RELAX NG Compact Syntax</title>

          <author initials="J." surname="Clark" fullname="James Clark">
            <organization/>

          </author>

          <date month="December" year="2001"/>

        </front>

      </reference>

    </references>


    <section title="Contributors">
      <t>The content and concepts within are a product of the Neutron Working Group.</t>

    </section>


    <section title="Examples" anchor="examples">
      <t/>

    </section>

  </back>

</rfc>
