<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <!--
    Copyright (c) 2016-2018 The CTAN Team
    Copyright (c) 1999-2004 Graham J. Williams
    
    Change history
    ==============
     
      2018-03-19  Manfred Lotz
        - Add an alias element which provides an alternate name for a package   
      2017-10-09  Manfred Lotz
         - Made xpath in keyref 'XREF-REFID' fully generic, i.e. xref will be validated
           no matter where it is found in the XML document. 
      2017-08-06  Manfred Lotz
        - Add an optional 'pseudonym' attribute to the author element
      2017-08-04  Manfred Lotz
        - Add an optional 'note' attribute to the author element
      2017-07-29  Manfred Lotz
        - Allow to add an optional date and/or note to authorref 
      2017-07-24  Manfred Lotz
        - Adding the same constraint for href in <a href...> element
        - Enforce mailto: to contain a '@'
        - href in <documentation> may have one of:
          ctan:, http://, https://, or ftp://
      2017-07-23  Manfred Lotz
        - Now, in contacts element the attribute href allows
          only valid URLs. Specifically, the following URLs are
          allowed: http://, https://, ftp://, nntp:, mailto:
          or news:.
      2017-06-09  Manfred Lotz
        - added <small> for a sort of small caps
      2017-04-29  Manfred Lotz
        - removed home element which is now obsolete
      2017-04-15  Manfred Lotz
        - added contact types: announce and development
      2017-04-04  Manfred Lotz
        - the CC licenses were still wrong. Should be fixed now.
      2017-04-03  Manfred Lotz
        - mixed up '_' and '-' in license names.
          Now, we have all '-'. 
      2017-04-01  Manfred Lotz
        - added licenses bsd4, gpl1, gpl1+, gpl2+, gpl3+,
          lppl1.3a and lppl1.3b 
      2017-03-30  Manfred Lotz
        - added license lppl1.3c
      2017-03-29  Manfred Lotz
        - corrected a typo: "cc_by_2.0" -> "cc_by_3.0" 
      2017-03-28  Manfred Lotz
        - added more Creative Commons licenses
      2017-03-26  Manfred Lotz
        - added Creative Commons licenses
      2017-01-06  Manfred Lotz
        - nested lists were not possible. Now fixed.
      2016-12-17  Manfred Lotz
        - license MIT added
      2016-12-04  Manfred Lotz
        - added a very poor man's email address validation check in the authors realm
        (finally, decided to accept ascii characters only, as 'international email addresses'
        are not widely accepted by mail servers)
        - removed obsolete emaildomain and emailname
    2016-10-29  Manfred Lotz
      - Now the description text may contain the following html elements
        - em       emphasis
        - i        italic
        - u        underline
        - b        bold
        - a        hypertext link
        - p        paragraph
        - pre      preformatted text
        - code     programming code, commands (usually in fixed fonts)
        - tt       fixed font
        - br       break or line break
        - ul       unordered list 
        - ol       ordered list
        - li       list items, used in ul and ol
        - dl       descriptive or definition list
        - dt       term in definition list
        - dd       definition in definition list
        
    2016-10-08  Manfred Lotz
      - changed author element to be able keep more than a single email address.
        Mostly done to keep additional information for unsual situations.
        For a short while we keep the combination of emailname and emaildomain
        till this XSD schema is distributed.
    2016-07-10  Manfred Lotz
      - added support for <b/>, <i/>, <u/>
    2016-06-12  Manfred Lotz
      - Paragraph element p was defined as simple type which could
        produce an unwanted validation error in certain situations.
    2016-05-15  Manfred Lotz
      - Converted from catalogue.dtd by using the RELAX NG Compact Syntax
        and then using trang to create the XSD.
      - Documentation of the various elements was taken from the DTD
        and in many cases adjusted.
      - Added a new element contacts which will be the successor of
        of the home element
    
  -->
  <xs:attributeGroup name="language">
    <xs:attribute name="language">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="aa"/>
          <xs:enumeration value="ab"/>
          <xs:enumeration value="ae"/>
          <xs:enumeration value="af"/>
          <xs:enumeration value="af-za"/>
          <xs:enumeration value="ak"/>
          <xs:enumeration value="am"/>
          <xs:enumeration value="an"/>
          <xs:enumeration value="ar"/>
          <xs:enumeration value="ar-ae"/>
          <xs:enumeration value="ar-bh"/>
          <xs:enumeration value="ar-dz"/>
          <xs:enumeration value="ar-eg"/>
          <xs:enumeration value="ar-iq"/>
          <xs:enumeration value="ar-jo"/>
          <xs:enumeration value="ar-kw"/>
          <xs:enumeration value="ar-lb"/>
          <xs:enumeration value="ar-ly"/>
          <xs:enumeration value="ar-ma"/>
          <xs:enumeration value="ar-om"/>
          <xs:enumeration value="ar-qa"/>
          <xs:enumeration value="ar-sa"/>
          <xs:enumeration value="ar-sy"/>
          <xs:enumeration value="ar-tn"/>
          <xs:enumeration value="ar-ye"/>
          <xs:enumeration value="as"/>
          <xs:enumeration value="av"/>
          <xs:enumeration value="ay"/>
          <xs:enumeration value="az"/>
          <xs:enumeration value="az-az"/>
          <xs:enumeration value="ba"/>
          <xs:enumeration value="be"/>
          <xs:enumeration value="be-by"/>
          <xs:enumeration value="bg"/>
          <xs:enumeration value="bg-bg"/>
          <xs:enumeration value="bh"/>
          <xs:enumeration value="bi"/>
          <xs:enumeration value="bm"/>
          <xs:enumeration value="bn"/>
          <xs:enumeration value="bo"/>
          <xs:enumeration value="br"/>
          <xs:enumeration value="bs-ba"/>
          <xs:enumeration value="ca"/>
          <xs:enumeration value="ca-es"/>
          <xs:enumeration value="ce"/>
          <xs:enumeration value="co"/>
          <xs:enumeration value="cr"/>
          <xs:enumeration value="cs"/>
          <xs:enumeration value="cs-cz"/>
          <xs:enumeration value="cv"/>
          <xs:enumeration value="cy"/>
          <xs:enumeration value="cy-gb"/>
          <xs:enumeration value="da"/>
          <xs:enumeration value="da-dk"/>
          <xs:enumeration value="de"/>
          <xs:enumeration value="de-at"/>
          <xs:enumeration value="de-ch"/>
          <xs:enumeration value="de-de"/>
          <xs:enumeration value="de-li"/>
          <xs:enumeration value="de-lu"/>
          <xs:enumeration value="dv"/>
          <xs:enumeration value="dv-mv"/>
          <xs:enumeration value="dz"/>
          <xs:enumeration value="ee"/>
          <xs:enumeration value="el"/>
          <xs:enumeration value="el-gr"/>
          <xs:enumeration value="en"/>
          <xs:enumeration value="en-au"/>
          <xs:enumeration value="en-bz"/>
          <xs:enumeration value="en-ca"/>
          <xs:enumeration value="en-cb"/>
          <xs:enumeration value="en-gb"/>
          <xs:enumeration value="en-ie"/>
          <xs:enumeration value="en-jm"/>
          <xs:enumeration value="en-nz"/>
          <xs:enumeration value="en-ph"/>
          <xs:enumeration value="en-tt"/>
          <xs:enumeration value="en-us"/>
          <xs:enumeration value="en-za"/>
          <xs:enumeration value="en-zw"/>
          <xs:enumeration value="eo"/>
          <xs:enumeration value="es"/>
          <xs:enumeration value="es-ar"/>
          <xs:enumeration value="es-bo"/>
          <xs:enumeration value="es-cl"/>
          <xs:enumeration value="es-co"/>
          <xs:enumeration value="es-cr"/>
          <xs:enumeration value="es-do"/>
          <xs:enumeration value="es-ec"/>
          <xs:enumeration value="es-es"/>
          <xs:enumeration value="es-gt"/>
          <xs:enumeration value="es-hn"/>
          <xs:enumeration value="es-mx"/>
          <xs:enumeration value="es-ni"/>
          <xs:enumeration value="es-pa"/>
          <xs:enumeration value="es-pe"/>
          <xs:enumeration value="es-pr"/>
          <xs:enumeration value="es-py"/>
          <xs:enumeration value="es-sv"/>
          <xs:enumeration value="es-uy"/>
          <xs:enumeration value="es-ve"/>
          <xs:enumeration value="et"/>
          <xs:enumeration value="et-ee"/>
          <xs:enumeration value="eu"/>
          <xs:enumeration value="eu-es"/>
          <xs:enumeration value="fa"/>
          <xs:enumeration value="fa-ir"/>
          <xs:enumeration value="ff"/>
          <xs:enumeration value="fi"/>
          <xs:enumeration value="fi-fi"/>
          <xs:enumeration value="fj"/>
          <xs:enumeration value="fo"/>
          <xs:enumeration value="fo-fo"/>
          <xs:enumeration value="fr"/>
          <xs:enumeration value="fr-be"/>
          <xs:enumeration value="fr-ca"/>
          <xs:enumeration value="fr-ch"/>
          <xs:enumeration value="fr-fr"/>
          <xs:enumeration value="fr-lu"/>
          <xs:enumeration value="fr-mc"/>
          <xs:enumeration value="fy"/>
          <xs:enumeration value="ga"/>
          <xs:enumeration value="gd"/>
          <xs:enumeration value="gl"/>
          <xs:enumeration value="gl-es"/>
          <xs:enumeration value="gn"/>
          <xs:enumeration value="gu"/>
          <xs:enumeration value="gu-in"/>
          <xs:enumeration value="gv"/>
          <xs:enumeration value="ha"/>
          <xs:enumeration value="he"/>
          <xs:enumeration value="he-il"/>
          <xs:enumeration value="hi"/>
          <xs:enumeration value="hi-in"/>
          <xs:enumeration value="ho"/>
          <xs:enumeration value="hr"/>
          <xs:enumeration value="hr-ba"/>
          <xs:enumeration value="hr-hr"/>
          <xs:enumeration value="ht"/>
          <xs:enumeration value="hu"/>
          <xs:enumeration value="hu-hu"/>
          <xs:enumeration value="hy"/>
          <xs:enumeration value="hy-am"/>
          <xs:enumeration value="hz"/>
          <xs:enumeration value="ia"/>
          <xs:enumeration value="id"/>
          <xs:enumeration value="id-id"/>
          <xs:enumeration value="ie"/>
          <xs:enumeration value="ig"/>
          <xs:enumeration value="ii"/>
          <xs:enumeration value="ik"/>
          <xs:enumeration value="io"/>
          <xs:enumeration value="is"/>
          <xs:enumeration value="is-is"/>
          <xs:enumeration value="it"/>
          <xs:enumeration value="it-ch"/>
          <xs:enumeration value="it-it"/>
          <xs:enumeration value="iu"/>
          <xs:enumeration value="ja"/>
          <xs:enumeration value="ja-jp"/>
          <xs:enumeration value="jv"/>
          <xs:enumeration value="ka"/>
          <xs:enumeration value="ka-ge"/>
          <xs:enumeration value="kg"/>
          <xs:enumeration value="ki"/>
          <xs:enumeration value="kj"/>
          <xs:enumeration value="kk"/>
          <xs:enumeration value="kk-kz"/>
          <xs:enumeration value="kl"/>
          <xs:enumeration value="km"/>
          <xs:enumeration value="kn"/>
          <xs:enumeration value="kn-in"/>
          <xs:enumeration value="ko"/>
          <xs:enumeration value="ko-kr"/>
          <xs:enumeration value="kok"/>
          <xs:enumeration value="kok-in"/>
          <xs:enumeration value="kr"/>
          <xs:enumeration value="ks"/>
          <xs:enumeration value="ku"/>
          <xs:enumeration value="kv"/>
          <xs:enumeration value="kw"/>
          <xs:enumeration value="ky"/>
          <xs:enumeration value="ky-kg"/>
          <xs:enumeration value="la"/>
          <xs:enumeration value="lb"/>
          <xs:enumeration value="lg"/>
          <xs:enumeration value="li"/>
          <xs:enumeration value="ln"/>
          <xs:enumeration value="lo"/>
          <xs:enumeration value="lt"/>
          <xs:enumeration value="lt-lt"/>
          <xs:enumeration value="lu"/>
          <xs:enumeration value="lv"/>
          <xs:enumeration value="lv-lv"/>
          <xs:enumeration value="mg"/>
          <xs:enumeration value="mh"/>
          <xs:enumeration value="mi"/>
          <xs:enumeration value="mi-nz"/>
          <xs:enumeration value="mk"/>
          <xs:enumeration value="mk-mk"/>
          <xs:enumeration value="ml"/>
          <xs:enumeration value="mn"/>
          <xs:enumeration value="mn-mn"/>
          <xs:enumeration value="mr"/>
          <xs:enumeration value="mr-in"/>
          <xs:enumeration value="ms"/>
          <xs:enumeration value="ms-bn"/>
          <xs:enumeration value="ms-my"/>
          <xs:enumeration value="mt"/>
          <xs:enumeration value="mt-mt"/>
          <xs:enumeration value="my"/>
          <xs:enumeration value="na"/>
          <xs:enumeration value="nb"/>
          <xs:enumeration value="nb-no"/>
          <xs:enumeration value="nd"/>
          <xs:enumeration value="ne"/>
          <xs:enumeration value="ng"/>
          <xs:enumeration value="nl"/>
          <xs:enumeration value="nl-be"/>
          <xs:enumeration value="nl-nl"/>
          <xs:enumeration value="nn-no"/>
          <xs:enumeration value="nn"/>
          <xs:enumeration value="nr"/>
          <xs:enumeration value="ns"/>
          <xs:enumeration value="ns-za"/>
          <xs:enumeration value="nv"/>
          <xs:enumeration value="ny"/>
          <xs:enumeration value="oc"/>
          <xs:enumeration value="oj"/>
          <xs:enumeration value="om"/>
          <xs:enumeration value="or"/>
          <xs:enumeration value="os"/>
          <xs:enumeration value="pa"/>
          <xs:enumeration value="pa-in"/>
          <xs:enumeration value="pi"/>
          <xs:enumeration value="pl"/>
          <xs:enumeration value="pl-pl"/>
          <xs:enumeration value="ps"/>
          <xs:enumeration value="ps-ar"/>
          <xs:enumeration value="pt"/>
          <xs:enumeration value="pt-br"/>
          <xs:enumeration value="pt-pt"/>
          <xs:enumeration value="qu"/>
          <xs:enumeration value="qu-bo"/>
          <xs:enumeration value="qu-ec"/>
          <xs:enumeration value="qu-pe"/>
          <xs:enumeration value="rm"/>
          <xs:enumeration value="rn"/>
          <xs:enumeration value="ro"/>
          <xs:enumeration value="ro-ro"/>
          <xs:enumeration value="ru"/>
          <xs:enumeration value="ru-ru"/>
          <xs:enumeration value="rw"/>
          <xs:enumeration value="sa"/>
          <xs:enumeration value="sa-in"/>
          <xs:enumeration value="sd"/>
          <xs:enumeration value="se"/>
          <xs:enumeration value="se-fi"/>
          <xs:enumeration value="se-no"/>
          <xs:enumeration value="se-se"/>
          <xs:enumeration value="si"/>
          <xs:enumeration value="sk"/>
          <xs:enumeration value="sk-sk"/>
          <xs:enumeration value="sl"/>
          <xs:enumeration value="sl-si"/>
          <xs:enumeration value="sm"/>
          <xs:enumeration value="sn"/>
          <xs:enumeration value="so"/>
          <xs:enumeration value="sq"/>
          <xs:enumeration value="sq-al"/>
          <xs:enumeration value="sr-ba"/>
          <xs:enumeration value="sr-sp"/>
          <xs:enumeration value="ss"/>
          <xs:enumeration value="st"/>
          <xs:enumeration value="su"/>
          <xs:enumeration value="sv"/>
          <xs:enumeration value="sv-fi"/>
          <xs:enumeration value="sv-se"/>
          <xs:enumeration value="sw"/>
          <xs:enumeration value="sw-ke"/>
          <xs:enumeration value="syr"/>
          <xs:enumeration value="syr-sy"/>
          <xs:enumeration value="ta"/>
          <xs:enumeration value="ta-in"/>
          <xs:enumeration value="te"/>
          <xs:enumeration value="te-in"/>
          <xs:enumeration value="tg"/>
          <xs:enumeration value="th"/>
          <xs:enumeration value="th-th"/>
          <xs:enumeration value="ti"/>
          <xs:enumeration value="tk"/>
          <xs:enumeration value="tl"/>
          <xs:enumeration value="tl-ph"/>
          <xs:enumeration value="tn"/>
          <xs:enumeration value="tn-za"/>
          <xs:enumeration value="to"/>
          <xs:enumeration value="tr"/>
          <xs:enumeration value="tr-tr"/>
          <xs:enumeration value="ts"/>
          <xs:enumeration value="tt"/>
          <xs:enumeration value="tt-ru"/>
          <xs:enumeration value="tw"/>
          <xs:enumeration value="ty"/>
          <xs:enumeration value="ug"/>
          <xs:enumeration value="uk"/>
          <xs:enumeration value="uk-ua"/>
          <xs:enumeration value="ur"/>
          <xs:enumeration value="ur-pk"/>
          <xs:enumeration value="uz"/>
          <xs:enumeration value="uz-uz"/>
          <xs:enumeration value="ve"/>
          <xs:enumeration value="vi"/>
          <xs:enumeration value="vi-vn"/>
          <xs:enumeration value="vo"/>
          <xs:enumeration value="wa"/>
          <xs:enumeration value="wo"/>
          <xs:enumeration value="xh"/>
          <xs:enumeration value="xh-za"/>
          <xs:enumeration value="yi"/>
          <xs:enumeration value="yo"/>
          <xs:enumeration value="za"/>
          <xs:enumeration value="zh"/>
          <xs:enumeration value="zh-cn"/>
          <xs:enumeration value="zh-hk"/>
          <xs:enumeration value="zh-mo"/>
          <xs:enumeration value="zh-sg"/>
          <xs:enumeration value="zh-tw"/>
          <xs:enumeration value="zu"/>
          <xs:enumeration value="zu-za"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:attributeGroup>
  <xs:element name="fullcat">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="authors"/>
        <xs:element ref="topics"/>
        <xs:element ref="catalogue"/>
      </xs:sequence>
    </xs:complexType>

<!-- Constraints come here
     Constraints must be defined at the top level

- -->


<!-- TOPIC-ID and TOPIC-IDREF

Defines a relationship between the 'value' attribute in
element 'keyval' and the 'name' attribute in the element
'topic'
- -->
    <xs:key name="TOPIC-ID">
      <xs:selector xpath="./topics/topic"/>
      <xs:field xpath="@name"/>
    </xs:key>
    <xs:keyref name="KEYVAL-VALUE" refer="TOPIC-ID">
      <xs:selector xpath="./catalogue/entry/keyval"/>
      <xs:field xpath="@value"/>
    </xs:keyref>

<!-- AUTHOR-ID and AUTHOR-IDREF resp. UPLOADER-IDREF

Defines a relationship between the 'id' attribute in
both 'authorref' and 'uploaderref' element and the 'id'
attribute of the 'author' element.
- -->
    <xs:key name="AUTHOR-ID">
      <xs:selector xpath="./authors/author"/>
      <xs:field xpath="@id"/>
    </xs:key>
    <xs:keyref name="AUTHORREF-ID" refer="AUTHOR-ID">
      <xs:selector xpath="./catalogue/entry/authorref"/>
      <xs:field xpath="@id"/>
    </xs:keyref>
    <xs:keyref name="UPLOADERREF-ID" refer="AUTHOR-ID">
      <xs:selector xpath="./catalogue/entry/uploaderref"/>
      <xs:field xpath="@id"/>
    </xs:keyref>


<!-- PKG-ID and ALSO-IDREF resp. XREF-IDREF

Defines a relationship between the 'refid' attribute in
element 'also' and the 'id' attribute of the element
'entry'
- -->
    <xs:key name="PKG-ID">
      <xs:selector xpath="./catalogue/entry"/>
      <xs:field xpath="@id"/>
    </xs:key>
    <xs:keyref name="ALSO-REFID" refer="PKG-ID">
      <xs:selector xpath="./catalogue/entry/also"/>
      <xs:field xpath="@refid"/>
    </xs:keyref>

    <xs:keyref name="XREF-REFID" refer="PKG-ID">
      <xs:selector xpath=".//xref"/>
      <xs:field xpath="@refid"/>
    </xs:keyref>

  </xs:element>
  <!--
      <xs:selector xpath="./catalogue/entry/description/*/xref"/>
    Here is the place, i.e. before the </xs:element> line above
    where the key, keyref constraints have to be inserted manually.
    Reason is that Relax NG Compact format doesn't allow specifying
    key,keyref relationship.
    
  -->
  <xs:element name="authors">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="author"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!--
    author element
    We keep only one entry for each author, as a sanity measure.
    
    The 'id' attribute values were prefixed 'auth:'. This has
    historical reasons as in a DTD an ID resp. IDREFS has a single
    namespace. Now when using an XSD schema this is no longer a
    restriction. So we decided to get rid of the auth prefix.
    
    Authors names had been broken into family name and given name
    but the problems with different cultures, with what to do with the names
    of organizations, etc., proved to be too much.  The next choice was
    to have a author display name as a string and then add a string by which
    the names could be alphabetized.  (For instance, the 'auth:hefferon-j'
    may have a displayname of 'Jim Hefferon' and a collatename of
    'Hefferon Jim'.  The first letter of the collate name may be used to
    subdivide author's names into groups.)
    
    Initially email name and domain were separated to discourage spammers.
    Actually, we decided to reunite email name and domain into a single name
    as the authors XML file isn't visible at a web site anyway.
    
    pseudonym (Optional) If an author wants a pseudonym to be used for public visibility
    
    died  Default=false. If true indicates that an author has passed away.
    
    female Default=false. If true indicates the author is female.

    note  (Optional) Could be used for additional notes pertaining to the author.
  -->
  <xs:element name="author">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="email">
          <xs:complexType>
            <xs:simpleContent>
              <xs:restriction base="xs:anyType">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:pattern value="[a-zA-Z0-9+\-._]+@[a-zA-Z0-9+\-._]+"/>
                  </xs:restriction>
                </xs:simpleType>
                <xs:attribute name="inactive" type="xs:date"/>
                <xs:attribute name="note" type="xs:string"/>
              </xs:restriction>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:string"/>
      <xs:attribute name="pseudonym" type="xs:string"/>
      <xs:attribute name="familyname" type="xs:string"/>
      <xs:attribute name="givenname" type="xs:string"/>
      <xs:attribute name="female" default="false">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="true"/>
            <xs:enumeration value="false"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="died" default="false">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="true"/>
            <xs:enumeration value="false"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="note" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="topics">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="topic"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="topic">
    <xs:complexType>
      <xs:attribute name="name" use="required" type="xs:string"/>
      <xs:attribute name="details" use="required" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="catalogue">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entry"/>
      </xs:sequence>
      <xs:attribute name="maintainer" use="required" type="xs:string"/>
      <xs:attribute name="datestamp" use="required" type="xs:string"/>
      <xs:attribute name="license" use="required" type="xs:string"/>
    </xs:complexType>
    <!--
        An alias has to be unique.
    -->
    <xs:unique name="ALIAS-REFID">
      <xs:selector xpath="./entry/alias"/>
      <xs:field xpath="@id"/>
    </xs:unique>
  </xs:element>
  <xs:element name="entry">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="name"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="alias"/>
        <xs:element ref="caption"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="authorref"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="uploaderref"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="copyright"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="contact"/>
        <xs:element maxOccurs="unbounded" ref="license"/>
        <xs:element minOccurs="0" ref="version"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="also"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="description"/>
        <xs:element minOccurs="0" ref="installation_notes"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="documentation"/>
        <xs:element minOccurs="0" ref="ctan"/>
        <xs:element minOccurs="0" ref="miktex"/>
        <xs:element minOccurs="0" ref="texlive"/>
        <xs:element minOccurs="0" ref="install"/>
        <xs:element maxOccurs="unbounded" ref="keyval"/>
      </xs:sequence>
      <xs:attributeGroup ref="attlist.entry"/>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="attlist.entry">
    <xs:attribute name="id" use="required" type="xs:string"/>
    <xs:attribute name="datestamp" use="required" type="xs:string"/>
    <xs:attribute name="modifier" type="xs:string"/>
    <xs:attribute name="obsolete" default="false">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="true"/>
          <xs:enumeration value="false"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="withdrawn" default="false">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="true"/>
          <xs:enumeration value="false"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:attributeGroup>
  <!--
    alias element
    An alias is an alternate name for a package

      id     an alias has an id which cannot used more than once
             Uniqueness is guaranteed by ALIAS-REFID in the catalogue
             element
      name   the display name of the alias
  -->
  <xs:element name="alias">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="id" use="required" type="xs:string"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <!--
    authorref element
    This indicates a CTAN author of a package.
    
      id     points to an author, who may upload on behalf of the original author(s),
             e.g. auth:wright
      date   (optional) is the date when the author was added. Date format is: yyyy-mm-dd,
             e.g. 2014-01-31
      note   (optional) 
      active Specifies if an author maintains a package. False if not. Default is "true".
  -->
  <xs:element name="authorref">
    <xs:complexType>
      <xs:attribute name="id" use="required" type="xs:string"/>
      <xs:attribute name="date" type="xs:date"/>
      <xs:attribute name="note" type="xs:string"/>
      <xs:attribute name="active" default="true">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="true"/>
            <xs:enumeration value="false"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <!--
    uploaderref element
    This indicates a CTAN author who is allowed to upload a package
    on behalf of the original author(s) of the package.
    
    Note: The original author (or one of the original authors) must confirm this
          in an email to ctan@dante.de
    
      id     points to an author, who may upload on behalf of the original author(s),
             e.g. auth:wright
      date   is the date when the original author's confirmation email arrived at
             ctan@dante.de. Date format is: yyyy-mm-dd, e.g. 2014-01-31
      note   (optional) 
      active Currently not used, set to "true" by default.
    
  -->
  <xs:element name="uploaderref">
    <xs:complexType>
      <xs:attribute name="id" use="required" type="xs:string"/>
      <xs:attribute name="date" use="required" type="xs:date"/>
      <xs:attribute name="note" type="xs:string"/>
      <xs:attribute name="active" default="true">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="true"/>
            <xs:enumeration value="false"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <xs:element name="contact">
    <xs:complexType>
      <xs:attribute name="type" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="home"/>
            <xs:enumeration value="repository"/>
            <xs:enumeration value="support"/>
            <xs:enumeration value="bugs"/>
            <xs:enumeration value="announce"/>
            <xs:enumeration value="development"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="href" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:pattern value="http://.*|https://.*|ftp://.*|nntp:.*|mailto:.+@.+|news:.*"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <!--
    copyright element:
    The owner and year attributes are both unstructured strings; for instance,
    year may be "1996-2005".
    
  -->
  <xs:element name="copyright">
    <xs:complexType>
      <xs:attribute name="owner" use="required" type="xs:string"/>
      <xs:attribute name="year" use="required" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <!--
    LICENSE
    
    An empty LICENSE element consists of the TYPE attribute which
    indicates the type of license under which the package is available.
    In general, UNKNOWN and OTHER licenses are specifically excluded from
    free distributions. Please refer to
    CTAN:/help/Catalogue/licenses.html, or
    http://texcatalogue.ctan.org/licenses.html, for details.
    
    The other attributes record details of the last time the license was
    checked, including the date (checked="2015-06-19"), the version of the
    package when the license was checked, and who checked it
    (username="manfred").
    
    If the TYPE is "other" then the PCDATA of the otherwise empty licence
    element might provide further explanation.
    
    The optional file attribute contains the name of the file where the license
    statement has been found, like "Copyright" or "doc/README", and thus
    makes checking again much easier.  The pseudo-file "header" would
    indicate that there is no separate license file, but that all included
    files state their license in their header comments. There is no
    defined syntax for that field - you like, put anything there that
    would indicate where to find the license information.
    
  -->
  <xs:element name="license">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attributeGroup ref="attlist.license"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="attlist.license">
    <xs:attribute name="type" default="unknown">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="apache2"/>
          <xs:enumeration value="artistic"/>
          <xs:enumeration value="artistic2"/>
          <xs:enumeration value="bsd"/>
          <xs:enumeration value="bsd2"/>
          <xs:enumeration value="bsd3"/>
          <xs:enumeration value="bsd4"/>
          <xs:enumeration value="collection"/>
          <xs:enumeration value="cc-by-1"/>
          <xs:enumeration value="cc-by-2"/>
          <xs:enumeration value="cc-by-3"/>
          <xs:enumeration value="cc-by-4"/>
          <xs:enumeration value="cc-by-nc-1"/>
          <xs:enumeration value="cc-by-nc-2"/>
          <xs:enumeration value="cc-by-nc-3"/>
          <xs:enumeration value="cc-by-nc-4"/>
          <xs:enumeration value="cc-by-nc-nd-1"/>
          <xs:enumeration value="cc-by-nc-nd-2"/>
          <xs:enumeration value="cc-by-nc-nd-2.5"/>
          <xs:enumeration value="cc-by-nc-nd-3"/>
          <xs:enumeration value="cc-by-nc-nd-4"/>
          <xs:enumeration value="cc-by-nc-sa4"/>
          <xs:enumeration value="cc-by-nd-1"/>
          <xs:enumeration value="cc-by-nd-2"/>
          <xs:enumeration value="cc-by-nd-3"/>
          <xs:enumeration value="cc-by-nd-4"/>
          <xs:enumeration value="cc-by-sa-1"/>
          <xs:enumeration value="cc-by-sa-2"/>
          <xs:enumeration value="cc-by-sa-3"/>
          <xs:enumeration value="cc-by-sa-4"/>
          <xs:enumeration value="digest"/>
          <xs:enumeration value="fdl"/>
          <xs:enumeration value="gfl"/>
          <xs:enumeration value="gfsl"/>
          <xs:enumeration value="gpl"/>
          <xs:enumeration value="gpl1"/>
          <xs:enumeration value="gpl1+"/>
          <xs:enumeration value="gpl2"/>
          <xs:enumeration value="gpl2+"/>
          <xs:enumeration value="gpl3"/>
          <xs:enumeration value="gpl3+"/>
          <xs:enumeration value="knuth"/>
          <xs:enumeration value="lgpl"/>
          <xs:enumeration value="lgpl2.1"/>
          <xs:enumeration value="lgpl3"/>
          <xs:enumeration value="lppl"/>
          <xs:enumeration value="lppl1"/>
          <xs:enumeration value="lppl1.2"/>
          <xs:enumeration value="lppl1.3"/>
          <xs:enumeration value="lppl1.3a"/>
          <xs:enumeration value="lppl1.3b"/>
          <xs:enumeration value="lppl1.3c"/>
          <xs:enumeration value="mit"/>
          <xs:enumeration value="nocommercial"/>
          <xs:enumeration value="noinfo"/>
          <xs:enumeration value="nosell"/>
          <xs:enumeration value="nosource"/>
          <xs:enumeration value="ofl"/>
          <xs:enumeration value="opl"/>
          <xs:enumeration value="other-free"/>
          <xs:enumeration value="other-nonfree"/>
          <xs:enumeration value="pd"/>
          <xs:enumeration value="shareware"/>
          <xs:enumeration value="unknown"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="checked" type="xs:date"/>
    <xs:attribute name="username" type="xs:string"/>
    <xs:attribute name="version" type="xs:string"/>
    <xs:attribute name="file" type="xs:string"/>
    <xs:attribute name="note" type="xs:string"/>
  </xs:attributeGroup>
  <!--
    version element
        This is the version of the package as assigned by the author.
        number   is a string
        date     if set must be a valid date
  -->
  <xs:element name="version">
    <xs:complexType>
      <xs:attribute name="number" type="xs:string"/>
      <xs:attribute name="date" type="xs:date"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="also">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attributeGroup ref="attlist.also"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="attlist.also">
    <xs:attribute name="refid" type="xs:string"/>
  </xs:attributeGroup>
  <xs:group name="text">
    <xs:sequence>
      <xs:choice minOccurs="0">
        <xs:element ref="xref"/>
        <xs:element ref="em"/>
        <xs:element ref="i"/>
        <xs:element ref="u"/>
        <xs:element ref="b"/>
        <xs:element ref="small"/>
        <xs:element ref="a"/>
        <xs:element ref="p"/>
        <xs:element ref="pre"/>
        <xs:element ref="code"/>
        <xs:element ref="tt"/>
        <xs:element ref="br"/>
      </xs:choice>
    </xs:sequence>
  </xs:group>
  <xs:element name="xref">
    <xs:complexType mixed="true">
      <xs:group minOccurs="0" maxOccurs="unbounded" ref="text"/>
      <xs:attributeGroup ref="attlist.xref"/>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="attlist.xref">
    <xs:attribute name="refid" use="required" type="xs:string"/>
  </xs:attributeGroup>
  <xs:element name="description">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="text"/>
        <xs:element ref="ul"/>
        <xs:element ref="ol"/>
        <xs:element ref="dl"/>
      </xs:choice>
      <xs:attributeGroup ref="attlist.description"/>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="attlist.description">
    <xs:attributeGroup ref="language"/>
  </xs:attributeGroup>
  <xs:element name="em" type="xs:string"/>
  <xs:element name="b" type="xs:string"/>
  <xs:element name="i" type="xs:string"/>
  <xs:element name="u" type="xs:string"/>
  <xs:element name="small" type="xs:string"/>
  <xs:element name="p">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="text"/>
        <xs:element ref="ul"/>
        <xs:element ref="ol"/>
        <xs:element ref="dl"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:element name="pre" type="xs:string"/>
  <xs:element name="code" type="xs:string"/>
  <xs:element name="tt">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="br"/>
        <xs:element ref="em"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:element name="br">
    <xs:complexType/>
  </xs:element>
  <xs:element name="ul">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="li"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="ol">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="li"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="dl">
    <xs:complexType>
      <xs:sequence maxOccurs="unbounded">
        <xs:element ref="dt"/>
        <xs:element ref="dd"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="li">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="text"/>
        <xs:element ref="ul"/>
        <xs:element ref="ol"/>
        <xs:element ref="dl"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:element name="dt">
    <xs:complexType mixed="true">
      <xs:group minOccurs="0" maxOccurs="unbounded" ref="text"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="dd">
    <xs:complexType mixed="true">
      <xs:group minOccurs="0" maxOccurs="unbounded" ref="text"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="email" type="xs:string"/>
  <xs:element name="name" type="xs:string"/>
  <xs:element name="number" type="xs:string"/>
  <xs:element name="released" type="xs:string"/>
  <xs:element name="caption">
    <xs:simpleType>
      <xs:union memberTypes="xs:string">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:length value="0"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:union>
    </xs:simpleType>
  </xs:element>
  <xs:element name="a">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attributeGroup ref="attlist.a"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="attlist.a">
    <xs:attribute name="href" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="http://.*|https://.*|ftp://.*|nntp:.*|mailto:.+@.+|news:.*"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:attributeGroup>
  <xs:element name="documentation">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attributeGroup ref="attlist.documentation"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="attlist.documentation">
    <xs:attribute name="href" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="http://.*|https://.*|ftp://.*|ctan:/.*"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="details" type="xs:string"/>
    <xs:attributeGroup ref="language"/>
  </xs:attributeGroup>
  <!--
    installation_notes
    
    Optional element which may contain internal notes for the
    CTAN upload managers.
    
  -->
  <xs:element name="installation_notes" type="xs:string"/>
  <!--
    CTAN
    
    The path attribute can point to either a directory or an actual
    file. By default it is assumed to be a directory
    (i.e. file=false). The attribute zip indicates whether additionally
    to the package's directory there is a zip archive of that directory.
    By default, zip=true
    
  -->
  <xs:element name="ctan">
    <xs:complexType>
      <xs:attributeGroup ref="attlist.ctan"/>
    </xs:complexType>
  </xs:element>
  <xs:attributeGroup name="attlist.ctan">
    <xs:attribute name="path" use="required" type="xs:string"/>
    <xs:attributeGroup ref="language"/>
    <xs:attribute name="zip" default="true">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="true"/>
          <xs:enumeration value="false"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="file" default="false">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="true"/>
          <xs:enumeration value="false"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:attributeGroup>
  <!--
    miktex
    
    If the package is part of the MiKTeX distribution then
    the MiKTeX package name is registered in attribute 'location'
    
  -->
  <xs:element name="miktex">
    <xs:complexType>
      <xs:attribute name="location" use="required" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <!--
    texlive
    
    If the package is part of the TeX Live distribution then
    the TeX Live package name is registered in attribute 'location'
    
  -->
  <xs:element name="texlive">
    <xs:complexType>
      <xs:attribute name="location" use="required" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <!--
    install element:
    Present if we hold a TDS-packaged version of the material.
    
    The 'path' attribute gives the CTAN path of the file.
    It begins with a '/', for instance, "/macros/latex/contrib/shadethm.zip".
    
  -->
  <xs:element name="install">
    <xs:complexType>
      <xs:attribute name="path" use="required" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <!--
    keyval
    
    For a history of the keyval element see the comment in catalogue.dtd.
    
    Currently, keyval will be used solely to assign topics, i.e attribute
    key may have value "topic" only.
    
  -->
  <xs:element name="keyval">
    <xs:complexType>
      <xs:attribute name="key" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="topic"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="value" use="required" type="xs:string"/>
    </xs:complexType>
  </xs:element>
</xs:schema>
