<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xs:schema
  PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN"
  "XMLSchema.dtd">

<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://zbar.sourceforge.net/2008/barcode"
  elementFormDefault="qualified"
  xmlns="http://zbar.sourceforge.net/2008/barcode">

  <xs:element name="barcodes">
    <xs:annotation>
      <xs:documentation>
        Document container for list of barcode sources.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element ref="source" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="source">
    <xs:annotation>
      <xs:documentation>
        Container for symbols read from a source.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:choice>
        <xs:element ref="index" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="symbol" minOccurs="0" maxOccurs="unbounded"/>
      </xs:choice>

      <xs:attribute name="device" type="xs:string">
        <xs:annotation>
          <xs:documentation>
            free form name of a "device" source.
          </xs:documentation>
        </xs:annotation>
      </xs:attribute>

      <xs:attribute name="href" type="xs:anyURI">
        <xs:annotation>
          <xs:documentation>
            URI ref to a file.
          </xs:documentation>
        </xs:annotation>
      </xs:attribute>
    </xs:complexType>
  </xs:element>

  <xs:element name="index">
    <xs:annotation>
      <xs:documentation>
        Container for all symbols read from a source at a specific
        sequence index (page/frame).
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element ref="symbol" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>

      <xs:attribute name="num" type="xs:nonNegativeInteger" default="0"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="symbol">
    <xs:annotation>
      <xs:documentation>
        An instance of a barcode symbol.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="location" type="locationType" minOccurs="0"/>
        <xs:element name="data" type="xs:string"/>
      </xs:sequence>

      <xs:attribute name="type" type="symbology"/>
      <xs:attribute name="quality" type="xs:integer" default="0"/>
      <xs:attribute name="count" type="xs:integer" default="0"/>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name="symbology">
    <xs:restriction base="xs:string">
      <xs:enumeration value="CODE-39"/>
      <xs:enumeration value="CODE-128"/>
      <xs:enumeration value="EAN-8"/>
      <xs:enumeration value="EAN-13"/>
      <xs:enumeration value="I2/5"/>
      <xs:enumeration value="ISBN-10"/>
      <xs:enumeration value="ISBN-13"/>
      <xs:enumeration value="PDF417"/>
      <xs:enumeration value="UPC-A"/>
      <xs:enumeration value="UPC-E"/>
      <xs:enumeration value="PDF417"/>
      <xs:enumeration value="QR-Code"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="locationType">
    <xs:attribute name="cx" type="xs:decimal"/>
    <xs:attribute name="cy" type="xs:decimal"/>
    <xs:attribute name="dx" type="xs:decimal"/>
    <xs:attribute name="dy" type="xs:decimal"/>
    <xs:attribute name="points">
      <xs:simpleType>
        <xs:list itemType="pointType"/>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>

  <xs:simpleType name="pointType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[+-]?\d+(\.\d+)?,[+-]?\d+(\.\d+)?"/>
    </xs:restriction>
  </xs:simpleType>
            
</xs:schema>
