<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc PUBLIC "-//IETF//DTD RFC 2629//EN"
    "http://xml.resource.org/authoring/rfc2629.dtd" [
<!ENTITY RFC1952 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.1952.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC3986 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
<!ENTITY RFC4297 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4287.xml">
<!ENTITY RFC4685 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4685.xml">
<!ENTITY RFC5005 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5005.xml">
<!ENTITY RFC5023 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5023.xml">
<!ENTITY ASCII SYSTEM "http://xml.resource.org/public/rfc/bibxml2/reference.ANSI.X3-4.1986.xml">
<!ENTITY POSIX SYSTEM "reference.IEEE.1003-1.2008.xml">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt"?>
<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc comments="yes"?>
<?rfc strict="yes"?>
<?rfc inline="yes"?>
<rfc ipr="trust200902" category="exp">
<front>
    <title>Atom Export Format</title>
    <author initials="G.M." surname="Sneddon" fullname="Geoffrey Sneddon">
    <!-- I work for no organisation, so no need for this to even be opened. -->
    <organization/>
    <address>
        <email>me@gsnedders.com</email>
        <uri>http://gsnedders.com/</uri>
    </address>
    </author>
    <!-- This is omitted while in draft, else I always forget to change it -->
    <date/>
    <!-- !Abstract -->
    <abstract>

        <t>This document specifies a method of using the Atom Syndication
        Format as an export format.</t>

    </abstract>
</front>
<middle>
    <!-- !Introduction -->
    <section title="Introduction">

        <t><cref>This section is yet to be written.</cref></t>

    </section>

    <!-- !Notational Conventions -->
    <section title="Notational Conventions">

        <t>This specification is defined in terms of the US-ASCII character set
        as defined in <xref target="ANSI.X3-4.1986"/>. Except where explicitly
        specified, all strings are case-sensitive.</t>

        <!-- !Conformance Requirements -->
        <section title="Conformance Requirements">

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

            <t>This document places certain restrictions depending on the
            purpose of the software implementing it. These groups are:
            importers, which process an Atom Export document and make a copy of
            it within their own data store; and, exporters, which create an
            Atom Export document from the contents of their own data store.</t>

            <t>Occasionally, an implementation is required to raise a fatal
            error. When an importer is required to raise a fatal error, it MUST
            abort processing of the Atom Export Document and MUST NOT continue
            processing of any sort. When an exporter is required to raise a
            fatal error, it MUST abort creating of an Atom Export Document, and
            MUST discard what it has thus far produced.</t>

        </section>
    </section>

    <!-- !Atom Export Documents -->
    <section title="Atom Export Documents">

        <t>An Atom Export Document is an archive file containing one or more
        Atom Feed Documents <xref target="RFC4287"/>. (The archive can,
        however, contain arbitrary files of any format.)</t>

        <t>Implementations MUST support ustar <xref target="IEEE.1003-1.2008"/>
        archives, and SHOULD support GZIP <xref target="RFC1952"/> compressed
        ustar archives. Exporters SHOULD create GZIP compressed ustar
        archives.</t>

        <t>The root of the archive, for the purposes of this document, MUST be
          found using the following algorithm:

            <list style="numbers">

                <t>Let "current directory" be the upper-most directory of the
                archive.</t>

                <t>If "current directory" contains, case-sensitively, a file
                called "index.xml", then "current directory" is the root.
                Terminate the algorithm.</t>

                <t>If "current directory" contains no files and one directory,
                then let "current directory" be that directory. Jump to step 2
                of this algorithm.</t>

                <t>Otherwise, this algorithm has failed. Raise a fatal
                error.</t>

            </list>
        </t>

        <t>When creating an Atom Export document, the exporter SHOULD create
        a single outer directory containing the "index.xml" file.</t>

        <t>When importing an Atom Export Document, processing MUST begin at the
        "index.xml" file located at the root of the archive. Importers MUST
        support Feed Paging and Archiving <xref target="RFC5005"/>, and SHOULD
        support Atom Threading Extensions <xref target="RFC4685"/>.</t>

        <t>When used as a link relation of an atom:link element which is a
        child of the root element in an Atom Feed Document, the link relations
        defined by Feed Paging and Archiving <xref target="RFC5005"/> MUST only
        be created by exporters when their "href" attribute's value matches the
        "path-noscheme" production in <xref target="RFC3986"/> and points to
        another Atom Feed Document in the Atom Export Document. Upon
        encountering a atom:link element that does not meet the above
        requirement, an importer SHOULD NOT follow the link if it is an
        absolute IRI, and MUST raise a fatal error if upon attempting to access
        the the document linked to by the "href" it is found not to exist
        (e.g., it is a relative URI and the file does not exist within the Atom
        Export Document, it is a HTTP URI and the status-code returned is 404
        or 410).</t>

        <t>Any file linked (either via atom:link or another linking method,
        such as within an Atom Text Construct or atom:content element) via a
        relative IRI that exists within the Atom Export Document SHOULD be
        copied by an importer to a location at which it will be accessible once
        imported, updating the IRI reference if needed. Equally, the importer
        SHOULD keep track of all alternate links (in the atom:link sense of the
        word link) for all entries and update IRI references that point to
        alternate representations within the Atom Export Document so that they
        are accessible in the imported copy.</t>

    </section>

    <!-- !index.xml -->
    <section title="index.xml">

        <t>The "index.xml" file, located at the root of the archive, MUST be an
        Atom Feed Document <xref target="RFC4287"/>.</t>

        <t>The "index.xml" file represents the main stream of entries of the
        export.</t>

        <t>If "index.xml" makes use of Feed Paging and Archiving <xref
        target="RFC5005"/>, the exporter MUST create "index.xml" as the first
        page if it uses paging, and as the current page if it uses archiving.
        Importers MUST make no assumption about the feed ordering, and MUST
        therefore handle cases where "index.xml" is not the first/current page
        identically to as if it had been.</t>

    </section>

    <!-- !Security Considerations -->
    <section title="Security Considerations">

        <t>As this specification primarily relies upon other specifications to
        define the formats used within this specification, it is subject to the
        same security considerations as they are. Please obtain the documents
        listed under "Normative References" for their security
        considerations.</t>

        <t>If an implementation expands the Atom Export Document into a larger
        filesystem for processing, it must beware of relative IRIs that would
        cause the implementation to operate on files outside of the
        expanded archive.</t>

        <t>Arbitrary files can be contained with the Atom Export Document: any
        implementation must ensure that due care is taken so that these do not
        pose a risk. These can especially become a risk if they are copied (due
        to being linked) to somewhere publicly accessible, or somewhere where
        they could be executed (such as a CGI script on a web-server).</t>

    </section>

    <!-- !IANA Considerations -->
    <section title="IANA Considerations">

        <t><cref>This section is yet to be written, primarily because it is
        pending a decision about archive formats (this has repercussions on
        detecting what archive format is used, and thus on this
        section).</cref></t>

    </section>
</middle>
<back>
    <!-- !Normative References -->
    <references title="Normative References">
        &ASCII;
        &RFC1952;
        &RFC2119;
        &RFC3986;
        &RFC4297;
        &RFC4685;
        &RFC5005;
        &RFC5023;
        &POSIX;
    </references>

    <!-- !Acknowledgments -->
    <section title="Acknowledgments">

        <t><cref>This section is yet to be written.</cref></t>

    </section>

    <!-- Known Issues -->
    <section title="Known Issues">

        <t><cref>Remove this section upon publication.</cref></t>

        <t><list style="symbols">

            <t>Need to register MIME type.</t>

            <t>Need to decide about archive formats (this has an effect on MIME
            type registration).</t>

            <t>Need to review the document v. I-D requirements.</t>

            <t>Need to define processing when parsing enclosed file fails.</t>

            <t>Resolving IRIs (defining / to be the root of the archive).</t>

            <t>Security considerations will have to say more.</t>
            
            <t>Work out why RFC5023 is referenced, or delete reference.</t>

        </list></t>

    </section>
</back>
</rfc>