<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="htx" xmlns="http://www.jpeg.org/hiddentext/htx" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xhtml="http://www.w3.org/1999/xhtml" targetNamespace="http://www.jpeg.org/hiddentext/htx" elementFormDefault="qualified">
  <xs:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd">
  </xs:import>
  <xs:simpleType name="Shape">
    <xs:annotation>
      <xs:documentation>Enumeration of shapes.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="rect" />
      <xs:enumeration value="poly" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Coords">
    <xs:annotation>
      <xs:documentation>
        Comma separated list of integer values.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="\d+,\s*\d+(,\s*\d+,\s*\d+)+" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Percentage">
    <xs:annotation>
      <xs:documentation>Percentage value.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="\d+(\.\d+)?%?" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Angle">
    <xs:annotation>
      <xs:documentation>nn for radian measure or nn° for degree</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[\-\+]?\d+(\.\d+)?°?" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Resolution">
    <xs:annotation>
      <xs:documentation>
        Resolution value in dots per inch (dpi). A single number stands for horizontal and vertical resolution having the same values. Two numbers can be used to define different resolutions for horizontal (first number) and vertical (second number).
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="\d+(\.\d+)?(,\*s\d+(\.\d+)?)?" />
    </xs:restriction>
  </xs:simpleType>
  <xs:attributeGroup name="coreattrs">
    <xs:annotation>
      <xs:documentation>
        core attributes common to most elements
        id          document-wide unique id
        class       space separated list of classes
        lang        language code (backwards compatible)
        xml:lang    language code (as per XML 1.0 spec)
        dir         direction for weak/neutral text
        iref        URI of the image corresponding to the region
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="id" type="xs:ID" />
    <xs:attribute name="class" type="xs:NMTOKENS" />
    <xs:attribute name="iref" type="xs:anyURI" />
    <xs:attributeGroup ref="xhtml:i18n" />
  </xs:attributeGroup>
  <xs:attributeGroup name="posattrs">
    <xs:annotation>
      <xs:documentation>
        positioning attributes common to most elements
        shape        shape of an element
        coords       coordinates of an element
        angle        angle of text direction
        0 is horizontal to the right, positive values
        mean counter-clockwise rotation
        baseline    angle of the characters in a line of text
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="shape" type="Shape" default="rect" />
    <xs:attribute name="coords" type="Coords" />
    <xs:attribute name="angle" type="Angle" default="0" />
    <xs:attribute name="baseline" type="Angle" default="0" />
  </xs:attributeGroup>
  <xs:element name="htx">
    <xs:annotation>
      <xs:documentation>
        Global container for hidden text and annotations. Contains language attributes, an optional xhtml head and a mandatory body.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="xhtml:head" minOccurs="0" />
        <xs:element ref="annotations" minOccurs="0" />
        <xs:element ref="hiddentext" minOccurs="0" />
      </xs:sequence>
      <xs:attribute name="res" type="Resolution" />
      <xs:attribute name="width" type="xs:integer" />
      <xs:attribute name="height" type="xs:integer" />
      <xs:attributeGroup ref="coreattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="param">
    <xs:annotation>
      <xs:documentation>
        User defined properties for a hidden text and annotations object.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:attribute name="name" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>
  <xs:element name="hiddentext">
    <xs:annotation>
      <xs:documentation>
        A hiddentext element contains hidden text for a page.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="region" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="region">
    <xs:annotation>
      <xs:documentation>
        A region element contains hidden text for a page region.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:sequence maxOccurs="unbounded">
        <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="paragraph" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="word" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="char" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="snippet" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="paragraph">
    <xs:annotation>
      <xs:documentation>
        A paragraph element contains hidden text for a paragraph.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:sequence maxOccurs="unbounded">
        <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="line" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="word" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="char" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="snippet" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="line">
    <xs:annotation>
      <xs:documentation>
        A line element contains hidden text for a line.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:sequence maxOccurs="unbounded">
        <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="word" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="char" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="snippet" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="word">
    <xs:annotation>
      <xs:documentation>
        A word element contains hidden text for a word.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:sequence maxOccurs="unbounded">
        <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="char" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="snippet" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="altword" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="conf" type="Percentage" />
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="altword">
    <xs:annotation>
      <xs:documentation>
        A altword element contains hidden text for a alternative word.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:sequence maxOccurs="unbounded">
        <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="char" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="snippet" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="conf" type="Percentage" />
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="char">
    <xs:annotation>
      <xs:documentation>
        A char element contains a hidden text character.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:sequence maxOccurs="unbounded">
        <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="altchar" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="conf" type="Percentage" />
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="altchar">
    <xs:annotation>
      <xs:documentation>
        A altchar element contains a hidden text alternative character.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="conf" type="Percentage" />
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="snippet">
    <xs:annotation>
      <xs:documentation>
        A snippet element identifies an unrecognised portion of the image.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="param" />
      </xs:sequence>
      <xs:attributeGroup ref="coreattrs" />
      <xs:attributeGroup ref="posattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="annotations">
    <xs:annotation>
      <xs:documentation>
        The annotations element represents annotated, clickable and highlighted areas on a page.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence maxOccurs="unbounded">
        <xs:element ref="area" />
      </xs:sequence>
      <xs:attributeGroup ref="coreattrs" />
    </xs:complexType>
  </xs:element>
  <xs:element name="area">
    <xs:annotation>
      <xs:documentation>
        An area element represents a clickable and/or highlighted area on a page.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:attribute name="href" type="xhtml:URI" />
      <xs:attribute name="alt" type="xhtml:Text" />
      <xs:attribute name="target" type="xhtml:URI" default="_self" />
      <xs:attribute name="shape" type="Shape" default="rect" />
      <xs:attribute name="coords" type="Coords" />
      <xs:attributeGroup ref="coreattrs" />
    </xs:complexType>
  </xs:element>
</xs:schema>