<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="http://linux.duke.edu/metadata/common" xmlns:rpm="http://linux.duke.edu/metadata/rpm" xmlns:suse="http://novell.com/package/metadata/suse/common" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <include href="rpm-inc.rng"/>
  <define name="yum.name">
    <element name="name">
      <text/>
    </element>
  </define>
  <define name="yum.arch">
    <element name="arch">
      <ref name="private.archenum"/>
    </element>
  </define>
  <define name="yum.version">
    <element name="version">
      <ref name="private.evr"/>
    </element>
  </define>
  <define name="group.deps">
    <optional>
      <ref name="rpm.provides"/>
    </optional>
    <optional>
      <ref name="rpm.requires"/>
    </optional>
    <optional>
      <ref name="rpm.conflicts"/>
    </optional>
    <optional>
      <ref name="rpm.obsoletes"/>
    </optional>
    <optional>
      <ref name="rpm.suggests"/>
    </optional>
    <optional>
      <ref name="rpm.recommends"/>
    </optional>
    <optional>
      <ref name="rpm.supplements"/>
    </optional>
    <optional>
      <ref name="rpm.enhances"/>
    </optional>
  </define>
  <define name="group.deps1">
    <optional>
      <ref name="rpm.provides"/>
    </optional>
    <optional>
      <ref name="rpm.requires"/>
    </optional>
    <optional>
      <ref name="rpm.conflicts"/>
    </optional>
    <optional>
      <ref name="rpm.obsoletes"/>
    </optional>
    <optional>
      <ref name="rpm.suggests"/>
    </optional>
    <optional>
      <ref name="rpm.enhances"/>
    </optional>
    <optional>
      <ref name="rpm.recommends"/>
    </optional>
    <optional>
      <ref name="rpm.supplements"/>
    </optional>
  </define>
  <define name="group.deps2">
    <optional>
      <ref name="rpm.provides"/>
    </optional>
    <optional>
      <ref name="rpm.conflicts"/>
    </optional>
    <optional>
      <ref name="rpm.obsoletes"/>
    </optional>
    <optional>
      <ref name="rpm.enhances"/>
    </optional>
    <optional>
      <ref name="rpm.supplements"/>
    </optional>
    <optional>
      <ref name="rpm.suggests"/>
    </optional>
    <optional>
      <ref name="rpm.recommends"/>
    </optional>
    <optional>
      <ref name="rpm.requires"/>
    </optional>
  </define>
  <define name="yum.location">
    <element name="location">
      <attribute name="href">
        <data type="anyURI"/>
      </attribute>
    </element>
  </define>
  <define name="yum.checksum">
    <element name="checksum">
      <attribute name="pkgid">
        <value>YES</value>
      </attribute>
      <ref name="private.checksum"/>
    </element>
  </define>
  <define name="yum.time">
    <element name="time">
      <attribute name="file">
        <ref name="private.unixts"/>
      </attribute>
      <attribute name="build">
        <ref name="private.unixts"/>
      </attribute>
    </element>
  </define>
  <define name="yum.size">
    <element name="size">
      <attribute name="package">
        <ref name="private.size"/>
      </attribute>
      <!-- Found this blank in the wild -->
      <attribute name="archive">
        <choice>
          <ref name="private.size"/>
          <value/>
        </choice>
      </attribute>
      <attribute name="installed">
        <ref name="private.size"/>
      </attribute>
    </element>
  </define>
  <start>
    <element name="metadata">
      <attribute name="packages">
        <ref name="private.nonnegative"/>
      </attribute>
      <zeroOrMore>
        <element name="package">
          <attribute name="type">
            <value>rpm</value>
          </attribute>
          <ref name="yum.name"/>
          <ref name="yum.arch"/>
          <ref name="yum.version"/>
          <ref name="yum.checksum"/>
          <!-- Found unlocalized in the wild -->
          <element name="summary">
            <choice>
              <ref name="private.localizedtext"/>
              <text/>
            </choice>
          </element>
          <element name="description">
            <choice>
              <ref name="private.localizedtext"/>
              <text/>
            </choice>
          </element>
          <element name="packager">
            <text/>
          </element>
          <!-- 10-SP1 stuff has a broken URL in the wild -->
          <element name="url">
            <choice>
              <data type="anyURI"/>
              <text/>
            </choice>
          </element>
          <ref name="yum.time"/>
          <ref name="yum.size"/>
          <ref name="yum.location"/>
          <element name="format">
            <element name="rpm:license">
              <text/>
            </element>
            <element name="rpm:vendor">
              <text/>
            </element>
            <element name="rpm:group">
              <text/>
            </element>
            <element name="rpm:buildhost">
              <text/>
            </element>
            <optional>
              <!--
                Two different options seen in the wild
                one omits the element, the other leaves the value empty
              -->
              <element name="rpm:sourcerpm">
                <choice>
                  <text/>
                  <empty/>
                </choice>
              </element>
            </optional>
            <element name="rpm:header-range">
              <attribute name="start">
                <ref name="private.positive"/>
              </attribute>
              <attribute name="end">
                <ref name="private.positive"/>
              </attribute>
            </element>
            <!-- any of these orders is valid, all are in use -->
            <choice>
              <ref name="group.deps"/>
              <ref name="group.deps1"/>
              <ref name="group.deps2"/>
            </choice>
            <zeroOrMore>
              <element name="file">
                <optional>
                  <attribute name="type">
                    <choice>
                      <value>dir</value>
                      <value>ghost</value>
                    </choice>
                  </attribute>
                </optional>
                <text/>
              </element>
            </zeroOrMore>
          </element>
          <optional>
            <element name="suse:license-to-confirm">
              <text/>
            </element>
          </optional>
        </element>
      </zeroOrMore>
    </element>
  </start>
</grammar>
