<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:feed="http://zero-install.sourceforge.net/2004/injector/interface"
            targetNamespace="http://zero-install.sourceforge.net/2004/injector/interface"
            id="feed" elementFormDefault="qualified">
  <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="https://www.w3.org/2009/01/xml.xsd" />

  <!-- Common base type -->
  <xs:complexType name="feed-element" abstract="true">
    <xs:attribute name="if-0install-version" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          To make it possible to use newer features in a feed without breaking older versions of 0install, the if-0install-version attribute may be placed on any element to indicate that the element should only be processed by the specified versions of 0install.
          0install versions before 1.13 ignore this attribute and process all elements.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:anyAttribute namespace="##other" />
  </xs:complexType>

  <!-- Root element -->
  <xs:element name="interface" type="feed:feed" />
  <xs:complexType name="feed">
    <xs:annotation>
      <xs:documentation>
        A feed/interface contains all the information required to download and execute an application.
        It is usually downloaded and updated from a specific URI but may also be a local file.
        Feeds downloaded from remote locations are protected from tampering by a OpenPGP signature.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="name" type="xs:string" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                A short name to identify the feed or program (e.g. "Foo"). Required!
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="summary" type="feed:localizable-string">
            <xs:annotation>
              <xs:documentation>
                Short one-line description; the first word should not be upper-case unless it is a proper noun (e.g. "cures all ills"). Required!
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="description" type="feed:localizable-string">
            <xs:annotation>
              <xs:documentation>
                Full description, which can be several paragraphs long.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="publisher" type="xs:string" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                The publisher (company or organization) of the program.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="homepage" type="xs:string" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                The URL of a web-page describing feed or program in more detail.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element ref="feed:icon">
            <xs:annotation>
              <xs:documentation>
                Zero or more icons representing the application. Used in the Catalog GUI as well as for desktop icons, menu entries, etc..
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="category" type="feed:category" />
          <xs:element name="needs-terminal" type="xs:string" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                If present, this element indicates that the program requires a terminal in order to run. Graphical launchers should therefore run this program in a suitable terminal emulator.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="feed" type="feed:feed-reference">
            <xs:annotation>
              <xs:documentation>
                A linked feed that contains more implementations of this feed's interface. Is treated by the solver as if it were part of the main feed.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="feed-for" type="feed:interface-reference">
            <xs:annotation>
              <xs:documentation>
                The implementations in this feed are implementations of the given interface. This is used when adding a third-party feed.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="replaced-by" type="feed:interface-reference" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                This interface of the feed has been replaced by the given interface. Any references to the old URI should be updated to use the new one.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="implementation" type="feed:implementation" />
          <xs:element name="package-implementation" type="feed:package-implementation" />
          <xs:element name="group" type="feed:group" />
          <xs:element name="entry-point" type="feed:entry-point" />
          <xs:any namespace="##other" />
        </xs:choice>
        <xs:attribute name="min-injector-version" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              This attribute gives the oldest version of the injector that can read this file. Older versions will tell the user to upgrade if they are asked to read the file. Versions prior to 0.20 do not perform this check, however. If the attribute is not present, the file can be read by all versions.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="uri" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              This attribute is only needed for remote feeds (fetched via HTTP). The value must exactly match the expected URL, to prevent an attacker replacing one correctly-signed feed with another (e.g., returning a feed for the shred program when the user asked for the backup program).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!-- Shared data type -->
  <xs:element name="icon" type="feed:icon" />
  <xs:complexType name="icon">
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:attribute name="href" type="xs:anyURI" use="required">
          <xs:annotation>
            <xs:documentation>
              The URL used to locate the icon.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="type" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The MIME type of the icon. This value is case-insensitive.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!-- Application meta data -->
  <xs:complexType name="category" mixed="true">
    <xs:annotation>
      <xs:documentation>
        An application category (e.g. Game or Office). Used for organizing application menus.
      </xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="type" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              If no type is given, then the category is one of the 'Main' categories defined by the freedesktop.org menu specification. Otherwise, it is a URI giving the namespace for the category.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="feed-reference">
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:attribute name="src" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The URL or local path used to locate the feed.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="langs" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The natural language(s) which the implementations in the feed support.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="arch" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              For platform-specific binaries, the platform for which the implementations in the feed were compiled, in the form os-cpu. Either the os or cpu part may be *, which will make it available on any OS or CPU.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="interface-reference">
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:attribute name="interface" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The URI used to locate the interface.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="entry-point">
    <xs:annotation>
      <xs:documentation>
        Associates a command with a user-friendly name and description.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="needs-terminal" type="xs:string" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                If present, this element indicates that the command represented by this entry point requires a terminal in order to run. Graphical launchers should therefore execute this entry point in a suitable terminal emulator.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="suggest-auto-start" type="xs:string" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                If present, this element indicates that this entry point should be offered as an auto-start candidate to the user.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="suggest-send-to" type="xs:string" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                If present, this element indicates that this entry point should be offered as a candidate for the "Send To" context menu to the user.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="name" type="feed:localizable-string">
            <xs:annotation>
              <xs:documentation>
                Localized user-friendly name for the command. If not present, the command attribute is used instead.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="summary" type="feed:localizable-string">
            <xs:annotation>
              <xs:documentation>
                Short one-line description; the first word should not be upper-case unless it is a proper noun (e.g. "cures all ills").
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="description" type="feed:localizable-string">
            <xs:annotation>
              <xs:documentation>
                Full description, which can be several paragraphs long.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="icon" type="feed:icon">
            <xs:annotation>
              <xs:documentation>
                An icon representing the application. Used in the Catalog GUI as well as for desktop icons, menu entries, etc..
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="splash-screen" type="feed:icon">
            <xs:annotation>
              <xs:documentation>
                A splash screens Zero Install can display during downloads, etc. for better branding.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:any namespace="##other" />
        </xs:choice>
        <xs:attribute name="command" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The name of the command this entry point represents.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="binary-name" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The canonical name of the binary supplying the command (without file extensions). This is used to suggest suitable alias names.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="app-id" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The Application User Model ID; used by Windows to associate shortcuts and pinned taskbar entries with running processes.
              May not be longer than 128 characters and may not contain whitespace.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!-- Implementations -->
  <xs:complexType name="element" abstract="true">
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:attribute name="langs" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The natural language(s) which the implementation supports.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="arch" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              For platform-specific binaries, the platform for which the implementation was compiled, in the form os-cpu. Either the os or cpu part may be *, which will make it available on any OS or CPU.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="version" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The version number of the implementation.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="version-modifier" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              A string to be appended to the version. The purpose of this is to allow complex version numbers (such as "1.0-rc2") in older versions of the injector.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="released" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The date this implementation was made available. For development versions checked out from version control this attribute should not be present.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="stability" type="feed:stability">
          <xs:annotation>
            <xs:documentation>
              The default stability rating for this implementation.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="rollout-percentage" type="feed:percent">
          <xs:annotation>
            <xs:documentation>
              The percentage of users that should treat this as stability=stable. May only be set if stability is unset or testing.
               This can be used to perform staged rollouts.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="license" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              License terms (typically a Trove category, as used on freshmeat.net).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="main" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The relative path of an executable inside the implementation that should be executed by default when the interface is run. If an implementation has no main setting, then it cannot be executed without specifying one manually. This typically means that the interface is for a library.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="self-test" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The relative path of an executable inside the implementation that can be executed to test the program. The program must be non-interactive (e.g. it can't open any windows or prompt for input). It should return with an exit status of zero if the tests pass. Any other status indicates failure.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="doc-dir" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The relative path of a directory inside the implementation that contains the package's documentation. This is the directory that would end up inside /usr/share/doc on a traditional Linux system.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="implementation">
    <xs:annotation>
      <xs:documentation>
        An implementation is a specific version of an application that can be downloaded and executed (e.g. Firefox 3.6 for Windows).
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:element">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="binding" type="feed:binding" />
          <xs:element name="environment" type="feed:environment" />
          <xs:element name="overlay" type="feed:overlay" />
          <xs:element name="executable-in-var" type="feed:executable-in-var" />
          <xs:element name="executable-in-path" type="feed:executable-in-path" />
          <xs:element name="command" type="feed:command" />
          <xs:element name="requires" type="feed:dependency" />
          <xs:element name="restricts" type="feed:restriction" />
          <xs:element name="manifest-digest" type="feed:manifest-digest" maxOccurs="1" />
          <xs:element name="recipe" type="feed:recipe" />
          <xs:element name="archive" type="feed:archive" />
          <xs:element name="file" type="feed:file" />
          <xs:any namespace="##other" />
        </xs:choice>
        <xs:attribute name="id" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              A unique identifier for this implementation. Used when storing implementation-specific user preferences.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="local-path" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              If the feed file is a local file (the interface 'uri' starts with /) then the local-path attribute may contain the pathname of a local directory (either an absolute path or a path relative to the directory containing the feed file).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="package-implementation">
    <xs:annotation>
      <xs:documentation>
        An implementation provided by a distribution-specific package manager instead of Zero Install.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:element">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:any namespace="##other" />
        </xs:choice>
        <xs:attribute name="package" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The name of the package in the distribution-specific package manager.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="distributions" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              A space-separated list of distribution names where the package name applies.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="group">
    <xs:annotation>
      <xs:documentation>
        All attributes of a group are inherited by any child groups and implementations as defaults, but can be overridden there.
        All dependencies and bindings are inherited (sub-groups may add more dependencies and bindings to the list, but cannot remove any).
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:element">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="binding" type="feed:binding" />
          <xs:element name="environment" type="feed:environment" />
          <xs:element name="overlay" type="feed:overlay" />
          <xs:element name="executable-in-var" type="feed:executable-in-var" />
          <xs:element name="executable-in-path" type="feed:executable-in-path" />
          <xs:element name="command" type="feed:command" />
          <xs:element name="requires" type="feed:dependency" />
          <xs:element name="restricts" type="feed:restriction" />
          <xs:element name="implementation" type="feed:implementation" />
          <xs:element name="package-implementation" type="feed:package-implementation" />
          <xs:element name="group" type="feed:group" />
          <xs:any namespace="##other" />
        </xs:choice>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!-- Implementation meta data -->
  <xs:complexType name="manifest-digest">
    <xs:annotation>
      <xs:documentation>
        A manifest digest is a means of uniquely identifying an implementation and verifying its contents.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:attribute name="sha1" type="xs:string" />
        <xs:attribute name="sha1new" type="xs:string" />
        <xs:attribute name="sha256" type="xs:string" />
        <xs:attribute name="sha256new" type="xs:string" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="command">
    <xs:annotation>
      <xs:documentation>
        A Command says how to run an implementation as a program.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="arg" type="xs:string">
            <xs:annotation>
              <xs:documentation>
                A single command-line argument to be passed to an implementation executable.
                Will be automatically escaped to allow proper concatenation of multiple arguments containing spaces.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="for-each" type="feed:for-each-arg" />
          <xs:element name="binding" type="feed:binding" />
          <xs:element name="environment" type="feed:environment" />
          <xs:element name="overlay" type="feed:overlay" />
          <xs:element name="executable-in-var" type="feed:executable-in-var" />
          <xs:element name="executable-in-path" type="feed:executable-in-path" />
          <xs:element name="requires" type="feed:dependency" />
          <xs:element name="restricts" type="feed:restriction" />
          <xs:element name="working-dir" type="feed:working-dir" maxOccurs="1" />
          <xs:element name="runner" type="feed:runner" maxOccurs="1" />
          <xs:any namespace="##other" />
        </xs:choice>
        <xs:attribute name="name" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The name of the command.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="path" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The relative path of an executable inside the implementation that should be executed to run this command.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="for-each-arg">
    <xs:complexContent>
      <xs:annotation>
        <xs:documentation>
          Expands an environment variable to multiple arguments.
          The variable specified in the 'item-from' attribute is split using the separator character and the arguments inside the element are added once for each item.
        </xs:documentation>
      </xs:annotation>
      <xs:extension base="feed:feed-element">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="arg" type="xs:string">
            <xs:annotation>
              <xs:documentation>
                A single command-line argument to be passed to an executable. "${item}" will be substituted with each for-each value.
                Will be automatically escaped to allow proper concatenation of multiple arguments containing spaces.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:choice>
        <xs:attribute name="item-from" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The name of the environment variable to be expanded.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="separator" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              Overrides the default separator character (":" on POSIX and ";" on Windows).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!-- Dependencies -->
  <xs:complexType name="restriction-base" abstract="true">
    <xs:annotation>
      <xs:documentation>
        A reference to an interface that is restricted to specific versions when used.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:attribute name="interface" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The URI or local path used to identify the interface.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="os" type="feed:os" default="*">
          <xs:annotation>
            <xs:documentation>
              Determines for which operating systems this dependency is required.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="distribution" type="xs:string" use="optional">
          <xs:annotation>
            <xs:documentation>
              Specifies that the selected implementation must be from the given distribution (e.g. Debian, RPM).
              The special value '0install' may be used to require an implementation provided by Zero Install (i.e. one not provided by a &lt;package-implementation&gt;).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="version" type="xs:string" use="optional">
          <xs:annotation>
            <xs:documentation>
              A more flexible alternative to &lt;version&gt; tags. A list of ranges, separated by "|", any of which may match.
              Each range is in the form "START..!END". The range matches versions where START &lt;= VERSION &lt; END. The start or end may be omitted. A single version number may be used instead of a range to match only that version, or !VERSION to match everything except that version.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="restriction">
    <xs:annotation>
      <xs:documentation>
        A reference to an interface that is restricted to specific versions when used.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:restriction-base">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="version" type="feed:constraint">
            <xs:annotation>
              <xs:documentation>
                Restricts the versions of an implementation that are allowed without creating a dependency on the implementation if its was not already chosen.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:any namespace="##other" />
        </xs:choice>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="dependency">
    <xs:annotation>
      <xs:documentation>
        A reference to an interface that is required as dependency.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:restriction-base">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="version" type="feed:constraint">
            <xs:annotation>
              <xs:documentation>
                Restricts the versions that are allowed.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="binding" type="feed:binding" />
          <xs:element name="environment" type="feed:environment" />
          <xs:element name="overlay" type="feed:overlay" />
          <xs:element name="executable-in-var" type="feed:executable-in-var" />
          <xs:element name="executable-in-path" type="feed:executable-in-path" />
          <xs:any namespace="##other" />
        </xs:choice>
        <xs:attribute name="importance" type="feed:importance" default="essential">
          <xs:annotation>
            <xs:documentation>
              Controls how important this dependency is (i.e. whether ignoring it is an option).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="use" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              This can be used to indicate that this dependency is only needed in some cases. Deprecated; use &lt;command&gt;s instead.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="runner">
    <xs:annotation>
      <xs:documentation>
        A special kind of dependency: the program that is used to run this one. For example, a Python program might specify Python as its runner.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:restriction-base">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="version" type="feed:constraint">
            <xs:annotation>
              <xs:documentation>
                Restricts the versions that are allowed.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="binding" type="feed:binding" />
          <xs:element name="environment" type="feed:environment" />
          <xs:element name="overlay" type="feed:overlay" />
          <xs:element name="executable-in-var" type="feed:executable-in-var" />
          <xs:element name="executable-in-path" type="feed:executable-in-path" />
          <xs:element name="arg" type="xs:string">
            <xs:annotation>
              <xs:documentation>
                A single command-line argument to be passed to the runner before the path of the implementation.
                Will be automatically escaped to allow proper concatenation of multiple arguments containing spaces.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="for-each" type="feed:for-each-arg" />
          <xs:any namespace="##other" />
        </xs:choice>
        <xs:attribute name="command" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The name of the command in the interface to use.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="constraint">
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:attribute name="not-before" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              This is the lowest-numbered version that can be chosen.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="before" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              This version and all later versions are unsuitable.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!-- Bindings -->
  <xs:complexType name="binding-base" abstract="true">
    <xs:annotation>
      <xs:documentation>
        Bindings specify how the chosen implementation is made known to the running program.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:feed-element" />
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="binding">
    <xs:annotation>
      <xs:documentation>
        Zero Install will not know how to run a program using generic bindings itself, but it will include them in any selections documents it creates, which can then be executed by your custom code.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:binding-base">
        <xs:attribute name="path" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              If your binding needs a path within the selected implementation, it is suggested that the path attribute be used for this. Other attributes and child elements should be namespaced to avoid collisions.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="command" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              If set Zero Install will select the given command within the implementation (which may cause additional dependencies and bindings to be selected). Otherwise, no command is selected.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="environment">
    <xs:annotation>
      <xs:documentation>
        Make a chosen implementation available by setting environment variables.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:binding-base">
        <xs:attribute name="name" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The name of the environment variable.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="value" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              A static value to set the variable to. If this is set 'insert' must be empty.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="insert" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The relative path of the item within the implementation to insert into the variable value. Use "." to publish the root directory. If this is set 'value' must be empty.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="mode" type="feed:environment-mode" default="prepend">
          <xs:annotation>
            <xs:documentation>
              Controls how 'insert' or 'value' is added to the variable.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="separator" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              Overrides the default separator character (":" on POSIX and ";" on Windows).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="default" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              If the environment variable is not currently set then this value is used for prepending or appending.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="overlay">
    <xs:annotation>
      <xs:documentation>
        Make a chosen implementation available by overlaying it onto another part of the file-system.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:binding-base">
        <xs:attribute name="src" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The relative path of the directory in the implementation to publish. The default is to publish everything.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="mount-point" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The mount point on which src is to appear in the filesystem. If missing, '/' (on POSIX) or '%systemdrive%' (on Windows) is assumed.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="executable-in-binding" abstract="true">
    <xs:annotation>
      <xs:documentation>
        Make a chosen implementation available as an executable at runtime.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:feed-element">
        <xs:attribute name="command" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The name of the command in the implementation to launch. If missing, 'run' is assumed.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="executable-in-var">
    <xs:annotation>
      <xs:documentation>
        Make a chosen implementation available as an executable path in an environment variable.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:executable-in-binding">
        <xs:attribute name="name" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The name of the environment variable.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="executable-in-path">
    <xs:annotation>
      <xs:documentation>
        Make a chosen implementation available as an executable in the search PATH.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:executable-in-binding">
        <xs:attribute name="name" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The name of the executable (without file extensions).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="working-dir">
    <xs:annotation>
      <xs:documentation>
        Switches the working directory of a process on startup to a location within an implementation.
        Useful for supporting legacy Windows applications which do not properly locate their installation directory.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="src" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The relative path of the directory in the implementation to set as the working directory. Defaults to use the root of the implementation if unset.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <!-- Retrieval methods -->
  <xs:complexType name="retrieval-method" abstract="true">
    <xs:annotation>
      <xs:documentation>
        A retrieval method is a way of getting a copy of an implementation.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:feed-element" />
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="download-retrieval-method" abstract="true">
    <xs:annotation>
      <xs:documentation>
        Represents a retrieval method that downloads data from the net.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:retrieval-method">
        <xs:attribute name="href" type="xs:anyURI" use="required">
          <xs:annotation>
            <xs:documentation>
              The URL used to locate the archive.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="size" type="xs:nonNegativeInteger" use="required">
          <xs:annotation>
            <xs:documentation>
              The size of the file in bytes. The file must have the given size or it will be rejected.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="archive">
    <xs:annotation>
      <xs:documentation>
        Retrieves an implementation by downloading and extracting an archive.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:download-retrieval-method">
        <xs:attribute name="type" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The type of the archive as a MIME type. If missing, the type is guessed from the extension on the 'Location' attribute. This value is case-insensitive.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="start-offset" type="xs:nonNegativeInteger">
          <xs:annotation>
            <xs:documentation>
              The number of bytes at the beginning of the file which should be ignored. The value in the size attribute does not include the skipped bytes.
              This is useful for some self-extracting archives which are made up of a shell script followed by a normal archive in a single file.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="extract" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The subdirectory inside the archive to extract; unset or empty for entire archive.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="dest" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The directory to extract into relative to the implementation root as a Unix-style path; unset or empty for top-level.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="file">
    <xs:annotation>
      <xs:documentation>
        Retrieves an implementation by downloading a single file.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:download-retrieval-method">
        <xs:attribute name="dest" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The file's target path relative to the implementation root as a Unix-style path.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="executable" type="xs:boolean">
          <xs:annotation>
            <xs:appinfo>
              Set this to true to mark the file as executable.
            </xs:appinfo>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="recipe">
    <xs:annotation>
      <xs:documentation>
        Retrieves an implementation by applying a list of recipe steps, such as downloading and combining multiple archives.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:retrieval-method">
        <xs:choice minOccurs="1" maxOccurs="unbounded">
          <xs:element name="archive" type="feed:archive" />
          <xs:element name="file" type="feed:file" />
          <xs:element name="rename" type="feed:rename" />
          <xs:element name="remove" type="feed:remove" />
          <xs:element name="copy-from" type="feed:rename" />
        </xs:choice>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="recipe-step" abstract="true">
    <xs:complexContent>
      <xs:extension base="feed:feed-element" />
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="rename">
    <xs:annotation>
      <xs:documentation>
        Renames or moves a file or directory. It is an error if the source or destination are outside the implementation.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:recipe-step">
        <xs:attribute name="source" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The source file or directory relative to the implementation root as a Unix-style path.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="dest" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The destination file or directory relative to the implementation root as a Unix-style path.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="remove">
    <xs:annotation>
      <xs:documentation>
        Removes or moves a file or directory. It is an error if the path is outside the implementation.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:recipe-step">
        <xs:attribute name="path" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The file or directory to be removed relative to the implementation root as a Unix-style path.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="copy-from">
    <xs:annotation>
      <xs:documentation>
        Copies files or directories from another implementation specified elsewhere in the same feed.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="feed:recipe-step">
        <xs:attribute name="id" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>
              The ID of the implementation to copy from.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="source" type="xs:string" use="optional">
          <xs:annotation>
            <xs:documentation>
              The source file or directory relative to the source implementation root as a Unix-style path; unset or empty for entire implementation.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="dest" type="xs:string" use="optional">
          <xs:annotation>
            <xs:documentation>
              The destination file or directory relative to the implementation root as a Unix-style path; unset or empty for top-level. Must be set if 'source' points to a file.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!-- Numbers -->
  <xs:simpleType name="percent">
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="0" />
      <xs:maxInclusive value="100" />
    </xs:restriction>
  </xs:simpleType>

  <!-- Enumerations -->
  <xs:simpleType name="importance">
    <xs:restriction base="xs:string">
      <xs:enumeration value="essential">
        <xs:annotation>
          <xs:documentation>
            A version of the dependency must be selected.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="recommended">
        <xs:annotation>
          <xs:documentation>
            No version of the dependency is also an option, although selecting a version is preferable to not selecting one.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="os">
    <xs:restriction base="xs:string">
      <xs:enumeration value="*">
        <xs:annotation>
          <xs:documentation>
            Any operating system
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="Linux" />
      <xs:enumeration value="Solaris" />
      <xs:enumeration value="MacOSX">
        <xs:annotation>
          <xs:documentation>
            MacOS X
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="Darwin">
        <xs:annotation>
          <xs:documentation>
            non-graphical core of MacOS X
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="Cygwin">
        <xs:annotation>
          <xs:documentation>
            POSIX compatibility layer on Windows
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="POSIX">
        <xs:annotation>
          <xs:documentation>
            any POSIX-compatible system (Linux, Solaris, MacOS X, Cygwin, ...=
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="Windows">
        <xs:annotation>
          <xs:documentation>
            Windows 2000 or newer
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="environment-mode">
    <xs:restriction base="xs:string">
      <xs:enumeration value="prepend">
        <xs:annotation>
          <xs:documentation>
            The absolute path of the item is prepended to the current value of the variable.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="append">
        <xs:annotation>
          <xs:documentation>
            The absolute path of the item is append to the end of the current value of the variable.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="replace">
        <xs:annotation>
          <xs:documentation>
            The old value is overwritten, and the 'default' attribute is ignored.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="stability">
    <xs:restriction base="xs:string">
      <xs:enumeration value="preferred">
        <xs:annotation>
          <xs:documentation>
            Set by user as a personal preference overriding other stability criteria.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="packaged">
        <xs:annotation>
          <xs:documentation>
            Indicates that an implementation is provided as a package-implementation.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="stable">
        <xs:annotation>
          <xs:documentation>No serious problems.</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="testing">
        <xs:annotation>
          <xs:documentation>Any new release.</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="developer">
        <xs:annotation>
          <xs:documentation>
            More extreme version of "testing", expected to have bugs.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="buggy">
        <xs:annotation>
          <xs:documentation>
            Known bugs, none security-related.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="insecure">
        <xs:annotation>
          <xs:documentation>
            Known bugs, some or all security-related.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <!-- Localizable string -->
  <xs:complexType name="localizable-string" mixed="true">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute ref="xml:lang" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:schema>
