<?xml version="1.0" encoding="UTF-8"?>
<!--
  CabCodeXF — CabCode eXchange Format, 0.5.3 (pre-release; 0.5.3 adds Part@hand (left / right), 0.5.2 adds what a Route is for (purpose, and follows / inset on a decorative route that is the part's outline moved in), 0.5.1 adds an Item's Cut pieces (a fitting bought by length and cut, a hanging rail), 0.5 adds profiled (V-groove) Routes, Route Patterns, operation Groups and boarded / V-groove Fronts, 0.4.2 adds GrainMatches, 0.4.1 adds Part@code, 0.4 makes Design@template optional, 0.3 adds assembly Steps and Part@label, 0.2 added Arc and Cutout to Outline; every 0.1 to 0.5.2 file validates)
  Machine-neutral panel machining-intent interchange. See ../cabcodexf-spec.md for the
  prose spec, conventions and rationale. This XSD is the validatable contract a
  producer's post-processor is certified against.

  Readers ignore what they do not know; extensions go in another namespace, at
  the xs:any / xs:anyAttribute points below (see "Versions and extensions").

  Conventions enforced here structurally; semantic conventions (datum, faces,
  depth-into-face, grain-explicit) are documented in the spec.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="https://cabcode.uk/cabcodexf"
           xmlns:cx="https://cabcode.uk/cabcodexf"
           targetNamespace="https://cabcode.uk/cabcodexf"
           elementFormDefault="qualified">

  <!-- ============================================================= root -->
  <xs:element name="CabCodeXF">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Header" type="Header"/>
        <xs:element name="Materials" type="Materials" minOccurs="0"/>
        <xs:element name="EdgeMaterials" type="EdgeMaterials" minOccurs="0"/>
        <xs:element name="Hardware" type="Hardware" minOccurs="0"/>
        <xs:element name="Designs" type="Designs" minOccurs="0"/>
        <!-- A file holds Parts, Designs or both. A file with no Part must have a
             Designs block (the spec's rule; XSD 1.0 cannot express it). -->
        <xs:element name="Part" type="Part" minOccurs="0" maxOccurs="unbounded"/>
        <!-- 0.4.2: parts cut from one board, arranged as given, so the grain runs on across them. -->
        <xs:element name="GrainMatches" type="GrainMatches" minOccurs="0"/>
        <!-- One per design (design=: that cabinet in its own frame), or one already in the job's frame. -->
        <xs:element name="Assembly" type="Assembly" minOccurs="0" maxOccurs="unbounded"/>
        <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="version" type="xs:string" use="required"/>
      <xs:anyAttribute namespace="##other" processContents="lax"/>
    </xs:complexType>
    <!-- 0.4.1: no two Parts share a code (part.code.duplicate). -->
    <xs:unique name="PartCode">
      <xs:selector xpath="cx:Part"/>
      <xs:field xpath="@code"/>
    </xs:unique>
  </xs:element>

  <!-- ============================================================= header -->
  <xs:complexType name="Header">
    <xs:sequence>
      <!-- Each system that contributed work (see "Provenance" in the spec). -->
      <xs:element name="Originator" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
          <xs:attribute name="id" type="OriginatorId" use="required"/>
          <xs:attribute name="name" type="xs:string"/>
          <xs:attribute name="url" type="xs:anyURI"/>
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="Order" minOccurs="0">
        <xs:complexType>
          <xs:attribute name="ref" type="xs:string"/>
          <xs:attribute name="customer" type="xs:string"/>
          <xs:attribute name="job" type="xs:string"/>          <!-- job number in the originator's system -->
          <xs:attribute name="originator" type="OriginatorId"/>
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:complexType>
      </xs:element>
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="units" type="xs:string" use="required"/>      <!-- "mm" -->
    <xs:attribute name="angleUnit" type="xs:string" default="deg"/>
    <xs:attribute name="producer" type="xs:string"/>
    <xs:attribute name="created" type="xs:dateTime"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:simpleType name="OriginatorId">
    <xs:restriction base="xs:string"><xs:pattern value="[a-z0-9\-]+"/></xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="DesignUid">
    <xs:restriction base="xs:string"><xs:pattern value="[A-Za-z0-9._:\-]{1,64}"/></xs:restriction>
  </xs:simpleType>

  <!-- ====================================================== materials lib -->
  <xs:complexType name="Materials">
    <xs:sequence>
      <xs:element name="Material" type="Material" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- Neutral, resolvable descriptors + the producer's own shorthand token.
       No factory-internal code is authoritative (optional factoryCode hint only). -->
  <xs:complexType name="Material">
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:attribute name="token" type="xs:string"/>          <!-- producer shorthand -->
    <xs:attribute name="manufacturer" type="xs:string"/>
    <xs:attribute name="decor" type="xs:string"/>
    <xs:attribute name="finish" type="xs:string"/>
    <xs:attribute name="type" type="xs:string"/>           <!-- MFC, MDF, ply, … -->
    <xs:attribute name="thickness" type="xs:decimal"/>
    <xs:attribute name="description" type="xs:string"/>
    <xs:attribute name="factoryCode" type="xs:string"/>    <!-- non-authoritative hint -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="EdgeMaterials">
    <xs:sequence>
      <xs:element name="EdgeMaterial" type="EdgeMaterial" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="EdgeMaterial">
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:attribute name="token" type="xs:string"/>
    <xs:attribute name="kind" type="xs:string"/>           <!-- ABS, PVC, veneer, … -->
    <xs:attribute name="thickness" type="xs:decimal"/>
    <xs:attribute name="description" type="xs:string"/>
    <xs:attribute name="factoryCode" type="xs:string"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- ============================================================ hardware -->
  <!-- Optional: the fittings the parts are machined for (hinges, legs, handles,
       dowels, …). An operation names the fitting it is for with hardware="H1";
       the fitting sits where that operation is, so an Item carries no position.
       kind: hinge, leg, handle, dowel, shelf, … (open list; a hinge plate is
       kind hinge, ref hingeplate). ref: the producer's
       own part code (e.g. CabCode "plinthfoot150"). style: for a hinge, how the
       door sits on the carcass (INSET, OVERLAY, HALF_OVERLAY). variant: the
       fitting's own model or fixing (e.g. a hinge's THIN for thin doors).
       quantity: how many the order uses, where known. -->
  <xs:complexType name="Hardware">
    <xs:sequence>
      <xs:element name="Item" type="HardwareItem" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="HardwareItem">
    <xs:sequence>
      <!-- 0.5.1: the pieces a fitting bought by length is cut into (a hanging rail) -->
      <xs:element name="Cut" type="HardwareCut" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:attribute name="kind" type="xs:string"/>
    <xs:attribute name="ref" type="xs:string"/>
    <xs:attribute name="style" type="xs:string"/>
    <xs:attribute name="variant" type="xs:string"/>
    <xs:attribute name="quantity" type="xs:positiveInteger"/>
    <xs:attribute name="manufacturer" type="xs:string"/>
    <xs:attribute name="description" type="xs:string"/>
    <xs:attribute name="factoryCode" type="xs:string"/>    <!-- non-authoritative hint -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- 0.5.1: one length a fitting is cut to, `quantity` pieces of it -->
  <xs:complexType name="HardwareCut">
    <xs:attribute name="length" use="required"><xs:simpleType><xs:restriction base="xs:decimal"><xs:minExclusive value="0"/></xs:restriction></xs:simpleType></xs:attribute>
    <xs:attribute name="quantity" type="xs:positiveInteger"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- ============================================================= designs -->
  <!-- Optional: whole parametric cabinets as their producing system designed
       them (a template plus sizes, materials and settings), so that system can
       reopen, resize and re-price them. Consumers that do not know the system
       ignore this block and machine the Parts. parts="omitted" means the file
       carries no Parts for that design: only a resolver for its `system`
       (e.g. CabCode) can turn it into parts. -->
  <xs:complexType name="Designs">
    <xs:sequence>
      <xs:element name="Design" type="Design" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="Design">
    <xs:sequence>
      <!-- One per copy, in order: where that copy sits. Overrides the Design's own x/y/z/rotation. -->
      <xs:element name="Place" type="DesignPlace" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Use" type="DesignUse" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Param" type="DesignParam" minOccurs="0" maxOccurs="unbounded"/>
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:attribute name="system" type="xs:string" use="required"/>   <!-- owner of the template ids, e.g. "cabcode" -->
    <xs:attribute name="originator" type="OriginatorId"/>          <!-- who issued the design -->
    <xs:attribute name="uid" type="DesignUid"/>                    <!-- issued by the originator; (originator, uid) is globally unique -->
    <xs:attribute name="template" type="xs:string"/> <!-- e.g. "C101". 0.4: optional; a Design without one carries its full settings as Params (CabCode: key="genus") -->
    <xs:attribute name="name" type="xs:string"/>
    <xs:attribute name="quantity" type="xs:positiveInteger" default="1"/>
    <xs:attribute name="height" type="xs:decimal" use="required"/>
    <xs:attribute name="width" type="xs:decimal" use="required"/>
    <xs:attribute name="depth" type="xs:decimal" use="required"/>
    <!-- Where the first copy sits (see DesignPlace). Unplaced copies follow the one before. -->
    <xs:attributeGroup ref="DesignPlacement"/>
    <xs:attribute name="code" type="xs:string"/>        <!-- the system's own saved-design code -->
    <xs:attribute name="catalogue" type="xs:string"/>   <!-- template catalogue version, if known -->
    <xs:attribute name="parts" type="DesignParts" default="included"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:simpleType name="DesignParts">
    <xs:restriction base="xs:string">
      <xs:enumeration value="included"/>
      <xs:enumeration value="omitted"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- Placement in the job, as a CabCode job places its cabinets (mm, degrees):
       x along the wall, y up, z out from the wall; (x, y, z) is the cabinet's
       left, bottom, back corner; rotation turns it about the vertical. A value
       left out carries on from the copy before (x: that copy's x plus its width). -->
  <xs:attributeGroup name="DesignPlacement">
    <xs:attribute name="x" type="xs:decimal"/>
    <xs:attribute name="y" type="xs:decimal"/>
    <xs:attribute name="z" type="xs:decimal"/>
    <xs:attribute name="rotation" type="xs:decimal"/>
  </xs:attributeGroup>

  <xs:complexType name="DesignPlace">
    <xs:attributeGroup ref="DesignPlacement"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- A board or edging the design uses, by role (carcass, front, back, edging, …). -->
  <xs:complexType name="DesignUse">
    <xs:attribute name="role" type="xs:string" use="required"/>
    <xs:attribute name="material" type="xs:IDREF"/>      <!-- -> Material -->
    <xs:attribute name="edgeMaterial" type="xs:IDREF"/>  <!-- -> EdgeMaterial -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- One of the system's own design settings, opaque to other consumers. The
       setting is the `value` attribute, or else the element's text: a json
       setting is written as text, so its quotes need no escaping
       (<Param key="sp" type="json">[{"id":"MAIN"}]</Param>). -->
  <xs:complexType name="DesignParam">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="key" type="xs:string" use="required"/>
        <xs:attribute name="value" type="xs:string"/>
        <xs:attribute name="type" type="ParamType" default="string"/>
        <xs:anyAttribute namespace="##other" processContents="lax"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:simpleType name="ParamType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="string"/>
      <xs:enumeration value="number"/>
      <xs:enumeration value="boolean"/>
      <xs:enumeration value="json"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- ================================================================ part -->
  <xs:complexType name="Part">
    <xs:sequence>
      <xs:element name="Edging" type="Edging" minOccurs="0"/>
      <!-- The finished footprint when it is not the full length x width rectangle. -->
      <xs:element name="Outline" type="Outline" minOccurs="0"/>
      <!-- Edges cut at an angle through the thickness. -->
      <xs:element name="Bevel" type="Bevel" minOccurs="0" maxOccurs="unbounded"/>
      <!-- Coats applied after the part is cut, one element per coat, in order. -->
      <xs:element name="Finish" type="Finish" minOccurs="0" maxOccurs="unbounded"/>
      <!-- A door or drawer front that is not a plain slab, and who supplies a bought-in part. -->
      <xs:element name="Front" type="Front" minOccurs="0"/>
      <xs:element name="Supply" type="Supply" minOccurs="0"/>
      <xs:element name="Operations" type="Operations" minOccurs="0"/>
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:attribute name="name" type="xs:string"/>
    <!-- 0.3: the text printed on the part's label, when it differs from name. -->
    <xs:attribute name="label" type="xs:string"/>
    <!-- 0.4.1: the producer's identifier for this part's machining (CABcad: its drill code); parts
         with the same code are machined identically. Unique within the file. -->
    <xs:attribute name="code" type="xs:string"/>
    <!-- What the part is in the cabinet (optional; for routing, labels, edging rules). -->
    <xs:attribute name="role" type="PartRole"/>
    <!-- 0.5.3: which hand the part is, as you face the cabinet's front (a side: the side it stands on; a door or
         drawer front: its hinge side). Optional; a reader may ignore it. -->
    <xs:attribute name="hand" type="PartHand"/>
    <xs:attribute name="quantity" type="xs:positiveInteger" default="1"/>
    <xs:attribute name="length" type="xs:decimal" use="required"/>   <!-- X -->
    <xs:attribute name="width" type="xs:decimal" use="required"/>    <!-- Y -->
    <xs:attribute name="thickness" type="xs:decimal" use="required"/><!-- Z -->
    <xs:attribute name="grain" type="GrainDir"/>   <!-- left out: unknown (the factory decides) -->
    <xs:attribute name="material" type="xs:IDREF"/>                  <!-- -> Material -->
    <xs:attribute name="design" type="xs:IDREF"/>                    <!-- -> Design it came from -->
    <xs:attribute name="supply" type="PartSupply" default="made"/>   <!-- bought-in: not cut from board -->
    <xs:attribute name="partOf" type="xs:IDREF"/>                    <!-- -> the front this is a piece of -->
    <xs:attribute name="origin" type="OriginatorId"/>   <!-- who added it; default: inherited -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- A door or drawer front that is not a plain slab (see "Fronts" in the spec). -->
  <xs:complexType name="Front">
    <xs:attribute name="style" type="FrontStyle" use="required"/>
    <xs:attribute name="build" type="FrontBuild"/>
    <xs:attribute name="profile" type="FrontProfile" default="square"/>
    <xs:attribute name="radius" type="xs:decimal"/>
    <xs:attribute name="stile" type="xs:decimal"/>
    <xs:attribute name="rail" type="xs:decimal"/>
    <xs:attribute name="midRails" type="DecimalList"/>
    <xs:attribute name="backLip" type="xs:decimal"/>
    <xs:attribute name="groove" type="xs:decimal"/>
    <xs:attribute name="grooveDepth" type="xs:decimal"/>
    <xs:attribute name="panelThickness" type="xs:decimal"/>
    <!-- 0.5: a shaker's centre panel (plain or boarded), and the boards' pitch (boarded front or panel), mm -->
    <xs:attribute name="panel" type="FrontPanel"/>
    <xs:attribute name="pitch" type="xs:decimal"/>
    <xs:attribute name="note" type="xs:string"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>
  <xs:simpleType name="FrontStyle"><xs:restriction base="xs:string">
    <xs:enumeration value="slab"/><xs:enumeration value="shaker"/><xs:enumeration value="boarded"/><xs:enumeration value="other"/>
  </xs:restriction></xs:simpleType>
  <xs:simpleType name="FrontPanel"><xs:restriction base="xs:string">
    <xs:enumeration value="plain"/><xs:enumeration value="boarded"/>
  </xs:restriction></xs:simpleType>
  <xs:simpleType name="FrontBuild"><xs:restriction base="xs:string">
    <xs:enumeration value="routed"/><xs:enumeration value="five-piece"/>
  </xs:restriction></xs:simpleType>
  <xs:simpleType name="FrontProfile"><xs:restriction base="xs:string">
    <xs:enumeration value="square"/><xs:enumeration value="ovolo"/><xs:enumeration value="chamfer"/><xs:enumeration value="v"/><xs:enumeration value="other"/>
  </xs:restriction></xs:simpleType>
  <xs:simpleType name="DecimalList"><xs:list itemType="xs:decimal"/></xs:simpleType>
  <xs:simpleType name="PartSupply"><xs:restriction base="xs:string">
    <xs:enumeration value="made"/><xs:enumeration value="bought-in"/>
  </xs:restriction></xs:simpleType>
  <!-- A bought-in part: who supplies it, and who drills it. -->
  <xs:complexType name="Supply">
    <xs:attribute name="supplier" type="xs:string"/>
    <xs:attribute name="ref" type="xs:string"/>
    <xs:attribute name="finish" type="xs:string"/>
    <xs:attribute name="drilled" type="SupplyDrilled" default="factory"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>
  <xs:simpleType name="SupplyDrilled"><xs:restriction base="xs:string">
    <xs:enumeration value="supplier"/><xs:enumeration value="factory"/>
  </xs:restriction></xs:simpleType>

  <xs:simpleType name="PartRole">
    <xs:restriction base="xs:string">
      <xs:enumeration value="side"/>
      <xs:enumeration value="top"/>
      <xs:enumeration value="bottom"/>
      <xs:enumeration value="back"/>
      <xs:enumeration value="shelf"/>
      <xs:enumeration value="divider"/>
      <xs:enumeration value="rail"/>
      <xs:enumeration value="door"/>
      <xs:enumeration value="drawer-face"/>
      <xs:enumeration value="drawer-box-side"/>
      <xs:enumeration value="drawer-box-front"/>
      <xs:enumeration value="drawer-box-back"/>
      <xs:enumeration value="drawer-box-bottom"/>
      <xs:enumeration value="plinth"/>
      <xs:enumeration value="filler"/>
      <xs:enumeration value="end-panel"/>
      <xs:enumeration value="door-stile"/>
      <xs:enumeration value="door-rail"/>
      <xs:enumeration value="door-midrail"/>
      <xs:enumeration value="door-panel"/>
      <xs:enumeration value="other"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="PartHand">
    <xs:restriction base="xs:string">
      <xs:enumeration value="left"/>
      <xs:enumeration value="right"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="GrainDir">
    <xs:restriction base="xs:string">
      <xs:enumeration value="length"/>
      <xs:enumeration value="width"/>
      <xs:enumeration value="none"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- ============================================================== edging -->
  <xs:complexType name="Edging">
    <xs:sequence>
      <xs:element name="Edge" maxOccurs="4">
        <xs:complexType>
          <xs:attribute name="edge" type="EdgeId" use="required"/>   <!-- geometric -->
          <xs:attribute name="as" type="xs:string"/>                 <!-- L1/L2/W1/W2 -->
          <xs:attribute name="edgeMaterial" type="xs:IDREF" use="required"/>
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:simpleType name="EdgeId">
    <xs:restriction base="xs:string">
      <xs:enumeration value="X0"/><xs:enumeration value="Xmax"/>
      <xs:enumeration value="Y0"/><xs:enumeration value="Ymax"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- ======================================================= angled panels -->
  <!-- Outline: the part's finished footprint as a closed polygon in the part
       frame, wound counter-clockwise in the part's x/y coordinates (positive
       signed area; the spec's "Turning sense"); the inside is the part.
       Each Seg runs from the previous point to its (x, y); the last closes to
       the first. A segment that is not along X or Y is an angle cut. length x
       width stay the polygon's bounding rectangle. as = the edge label the
       segment belongs to (L1/L2/W1/W2; a diagonal names the edge it replaces);
       edgeMaterial overrides that edge's band for this segment. -->
  <xs:complexType name="Outline">
    <xs:sequence>
      <!-- 3 or more Seg/Arc elements; 2 are enough when one is an Arc (the validator checks the count). -->
      <xs:choice minOccurs="2" maxOccurs="unbounded">
        <xs:element name="Seg" type="OutlineSeg"/>
        <xs:element name="Arc" type="OutlineArc"/>
      </xs:choice>
      <!-- 0.2: holes through the part. -->
      <xs:element name="Cutout" type="Cutout" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="closed" type="xs:boolean" default="true"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="OutlineSeg">
    <xs:attribute name="x" type="xs:decimal" use="required"/>
    <xs:attribute name="y" type="xs:decimal" use="required"/>
    <xs:attribute name="as" type="EdgeLabel"/>
    <xs:attribute name="edgeMaterial" type="xs:IDREF"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- 0.2. Arc: a circular arc from the previous point to (x, y) about the centre
       (cx, cy), travelled cw or ccw in the part's x/y coordinates. as and
       edgeMaterial are as for a Seg. A full circle is two arcs. -->
  <xs:complexType name="OutlineArc">
    <xs:attribute name="x" type="xs:decimal" use="required"/>
    <xs:attribute name="y" type="xs:decimal" use="required"/>
    <xs:attribute name="cx" type="xs:decimal" use="required"/>
    <xs:attribute name="cy" type="xs:decimal" use="required"/>
    <xs:attribute name="dir" use="required">
      <xs:simpleType><xs:restriction base="xs:string"><xs:enumeration value="cw"/><xs:enumeration value="ccw"/></xs:restriction></xs:simpleType>
    </xs:attribute>
    <xs:attribute name="as" type="EdgeLabel"/>
    <xs:attribute name="edgeMaterial" type="xs:IDREF"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- 0.2. Cutout: a hole through the part, written like an outline but wound
       clockwise, wholly inside the Outline, apart from every other Cutout. No
       edge label or band. -->
  <xs:complexType name="Cutout">
    <xs:choice minOccurs="2" maxOccurs="unbounded">
      <xs:element name="Seg">
        <xs:complexType>
          <xs:attribute name="x" type="xs:decimal" use="required"/>
          <xs:attribute name="y" type="xs:decimal" use="required"/>
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="Arc">
        <xs:complexType>
          <xs:attribute name="x" type="xs:decimal" use="required"/>
          <xs:attribute name="y" type="xs:decimal" use="required"/>
          <xs:attribute name="cx" type="xs:decimal" use="required"/>
          <xs:attribute name="cy" type="xs:decimal" use="required"/>
          <xs:attribute name="dir" use="required">
            <xs:simpleType><xs:restriction base="xs:string"><xs:enumeration value="cw"/><xs:enumeration value="ccw"/></xs:restriction></xs:simpleType>
          </xs:attribute>
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:complexType>
      </xs:element>
    </xs:choice>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- Bevel: an edge cut at an angle through the thickness. edge = a rectangle
       edge label, or seg = the 0-based index of an Outline Seg (exactly one;
       Seg and Arc are numbered together, and an Arc is not a valid target).
       angle = degrees from square, more than 0 and less than 90. refFace = the
       face that keeps the full outline size; the other face is undercut. -->
  <xs:complexType name="Bevel">
    <xs:attribute name="edge" type="EdgeLabel"/>
    <xs:attribute name="seg" type="xs:nonNegativeInteger"/>
    <xs:attribute name="angle" type="BevelAngle" use="required"/>
    <xs:attribute name="refFace" type="RefFace" use="required"/>
    <xs:attribute name="origin" type="OriginatorId"/>   <!-- who added it; default: inherited -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- Finish: one coat sprayed or rolled on after cutting (not the board's own
       surface, which is its Material). type: primer, lacquer, paint, … (open
       list). faces: A, B or AB (both). edges: "none" (default), "all", or a
       space-separated list of edge labels (e.g. "L1 L2"). sheen: matt, satin,
       gloss, … colour: e.g. a RAL / NCS reference. coats: how many. -->
  <xs:complexType name="Finish">
    <xs:attribute name="type" type="xs:string" use="required"/>
    <xs:attribute name="faces" type="FinishFaces" use="required"/>
    <xs:attribute name="edges" type="xs:string" default="none"/>
    <xs:attribute name="sheen" type="xs:string"/>
    <xs:attribute name="colour" type="xs:string"/>
    <xs:attribute name="coats" type="xs:positiveInteger"/>
    <xs:attribute name="description" type="xs:string"/>
    <xs:attribute name="factoryCode" type="xs:string"/>    <!-- non-authoritative hint -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:simpleType name="FinishFaces">
    <xs:restriction base="xs:string">
      <xs:enumeration value="A"/><xs:enumeration value="B"/><xs:enumeration value="AB"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="EdgeLabel">
    <xs:restriction base="xs:string">
      <xs:enumeration value="L1"/><xs:enumeration value="L2"/>
      <xs:enumeration value="W1"/><xs:enumeration value="W2"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="BevelAngle">
    <xs:restriction base="xs:decimal">
      <xs:minExclusive value="0"/><xs:maxExclusive value="90"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="RefFace">
    <xs:restriction base="xs:string">
      <xs:enumeration value="A"/><xs:enumeration value="B"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- ========================================================== operations -->
  <xs:complexType name="Operations">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="Bore" type="Bore"/>
      <xs:element name="Route" type="Route"/>
      <xs:element name="Pocket" type="Pocket"/>
      <xs:element name="Group" type="Group"/>   <!-- 0.5 -->
      <xs:any namespace="##other" processContents="lax"/>   <!-- a factory's own operation -->
    </xs:choice>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- Face id: the two faces (A/B) or an edge (for horizontal/edge boring).
       A = the show face, z = 0, on the bed when machined (rare work: the
       turned-over panel-B.mpr program). B = the back, z = thickness, the face
       usually machined: hinges, shelf holes, connectors (the main panel.mpr). -->
  <xs:simpleType name="FaceId">
    <xs:restriction base="xs:string">
      <xs:enumeration value="A"/><xs:enumeration value="B"/>
      <xs:enumeration value="X0"/><xs:enumeration value="Xmax"/>
      <xs:enumeration value="Y0"/><xs:enumeration value="Ymax"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- OpLabel: optional, on every operation. name = a short label (shown to the
       operator, or used as the machine program's operation name); note = free
       text for the operator. Neither changes what is machined: an importer
       must never read meaning from them. hardware = the Hardware Item this
       operation is machined for (a hinge's cup, a leg's fixing holes); it
       does not change what is machined either. -->
  <xs:attributeGroup name="OpLabel">
    <xs:attribute name="name" type="xs:string"/>
    <xs:attribute name="note" type="xs:string"/>
    <xs:attribute name="hardware" type="xs:IDREF"/>   <!-- -> Hardware Item -->
  </xs:attributeGroup>

  <!-- Bore: one or more holes of the same diameter/depth on one face.
       Face bore (A/B): positions use <At x= y=>. Edge bore: <At u=> + @z. -->
  <xs:complexType name="Bore">
    <xs:sequence>
      <xs:element name="At" type="At" maxOccurs="unbounded"/>
      <xs:element name="Pattern" type="Pattern" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="face" type="FaceId" use="required"/>
    <xs:attribute name="diameter" type="xs:decimal" use="required"/>
    <xs:attribute name="depth" type="xs:decimal"/>
    <xs:attribute name="through" type="xs:boolean" default="false"/>
    <xs:attribute name="z" type="xs:decimal"/>   <!-- edge bores: height from face A -->
    <xs:attributeGroup ref="OpLabel"/>
    <xs:attribute name="origin" type="OriginatorId"/>   <!-- who added it; default: inherited -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- Group (0.5): face operations defined once about the group's own origin, placed by each <At x y turn>:
       turned turn degrees counter-clockwise about the origin, then moved to (x, y). Readers expand it to the
       plain operations (a cup hinge's cup and dowels, placed down a door). Bores on face A or B, Routes,
       Pockets; no edge bores (the validator checks it), no group in a group. hardware and origin are
       inherited by an operation that does not say its own; name and note label the group. -->
  <xs:complexType name="Group">
    <xs:sequence>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="Bore" type="Bore"/>
        <xs:element name="Route" type="Route"/>
        <xs:element name="Pocket" type="Pocket"/>
      </xs:choice>
      <xs:element name="At" type="GroupAt" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attributeGroup ref="OpLabel"/>
    <xs:attribute name="origin" type="OriginatorId"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>
  <xs:complexType name="GroupAt">
    <xs:attribute name="x" type="xs:decimal" use="required"/>
    <xs:attribute name="y" type="xs:decimal" use="required"/>
    <xs:attribute name="turn" type="GroupTurn" default="0"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>
  <xs:simpleType name="GroupTurn"><xs:restriction base="xs:integer">
    <xs:enumeration value="0"/><xs:enumeration value="90"/><xs:enumeration value="180"/><xs:enumeration value="270"/>
  </xs:restriction></xs:simpleType>

  <xs:complexType name="At">
    <xs:attribute name="x" type="xs:decimal"/>   <!-- face bores -->
    <xs:attribute name="y" type="xs:decimal"/>   <!-- face bores -->
    <xs:attribute name="u" type="xs:decimal"/>   <!-- edge bores: along-edge distance -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- Pattern: on a Bore, count = holes per At, the At's own included; on a Route (0.5), count = copies of the path, its own included; each dx / dy on from the one before. -->
  <xs:complexType name="Pattern">
    <xs:attribute name="count" type="xs:positiveInteger" use="required"/>
    <xs:attribute name="dx" type="xs:decimal" default="0"/>
    <xs:attribute name="dy" type="xs:decimal" default="0"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- Route: a routed path on a face, as connected Line / Arc segments in the
       part frame (X along length, Y along width; turning sense as the spec's
       "Turning sense").
       toolWidth = cutter diameter. toolSide says where the cutter runs relative
       to the direction of travel: left / right put the path on the finished
       edge (the cutter is offset to that side), centre runs the cutter centre
       on the path (a groove of toolWidth).
       0.5: profile="v" with angle (the included angle, degrees) is a V-groove of that
       angle to depth, cut on the path (toolSide centre), 2 x depth x tan(angle / 2)
       wide at the face; toolWidth is then optional, the largest cutter the factory may
       use. A route without a profile still needs toolWidth (the validator checks it).
       An optional Pattern repeats the whole path, count copies, each dx / dy on. -->
  <xs:complexType name="Route">
    <xs:sequence>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="Line">
          <xs:complexType>
            <xs:attribute name="x1" type="xs:decimal" use="required"/>
            <xs:attribute name="y1" type="xs:decimal" use="required"/>
            <xs:attribute name="x2" type="xs:decimal" use="required"/>
            <xs:attribute name="y2" type="xs:decimal" use="required"/>
            <xs:anyAttribute namespace="##other" processContents="lax"/>
          </xs:complexType>
        </xs:element>
        <!-- circular arc from (x1,y1) to (x2,y2) about centre (cx,cy); dir is
             clockwise / counter-clockwise in the part's x/y coordinates
             (the spec's "Turning sense") -->
        <xs:element name="Arc">
          <xs:complexType>
            <xs:attribute name="x1" type="xs:decimal" use="required"/>
            <xs:attribute name="y1" type="xs:decimal" use="required"/>
            <xs:attribute name="x2" type="xs:decimal" use="required"/>
            <xs:attribute name="y2" type="xs:decimal" use="required"/>
            <xs:attribute name="cx" type="xs:decimal" use="required"/>
            <xs:attribute name="cy" type="xs:decimal" use="required"/>
            <xs:attribute name="dir" type="ArcDir" use="required"/>
            <xs:anyAttribute namespace="##other" processContents="lax"/>
          </xs:complexType>
        </xs:element>
      </xs:choice>
      <xs:element name="Pattern" type="Pattern" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="face" type="FaceId" use="required"/>
    <xs:attribute name="toolWidth" type="xs:decimal"/>
    <xs:attribute name="toolSide" type="ToolSide" default="centre"/>
    <xs:attribute name="profile" type="RouteProfile"/>
    <xs:attribute name="angle" type="xs:decimal"/>
    <xs:attribute name="depth" type="xs:decimal"/>
    <xs:attribute name="through" type="xs:boolean" default="false"/>
    <xs:attribute name="closed" type="xs:boolean" default="false"/>  <!-- path returns to its start -->
    <!-- 0.5.2: what the route is for; follows / inset on a decorative route whose path is the part's outline
         (its Outline, else its rectangle) moved in by inset mm. The path is still what is cut. -->
    <xs:attribute name="purpose" type="RoutePurpose" default="machining"/>
    <xs:attribute name="follows" type="RouteFollows"/>
    <xs:attribute name="inset" type="PositiveMm"/>
    <xs:attributeGroup ref="OpLabel"/>
    <xs:attribute name="origin" type="OriginatorId"/>   <!-- who added it; default: inherited -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:simpleType name="RouteProfile"><xs:restriction base="xs:string">
    <xs:enumeration value="v"/>
  </xs:restriction></xs:simpleType>

  <!-- 0.5.2 -->
  <xs:simpleType name="PositiveMm"><xs:restriction base="xs:decimal">
    <xs:minExclusive value="0"/>
  </xs:restriction></xs:simpleType>
  <xs:simpleType name="RoutePurpose"><xs:restriction base="xs:string">
    <xs:enumeration value="machining"/>
    <xs:enumeration value="decorative"/>
  </xs:restriction></xs:simpleType>
  <xs:simpleType name="RouteFollows"><xs:restriction base="xs:string">
    <xs:enumeration value="outline"/>
  </xs:restriction></xs:simpleType>

  <!-- Pocket: a rectangular recess cleared to depth (a pocketing cycle, e.g.
       WoodWOP Tasche on a BHX). x,y = its centre in the part frame; sizeX /
       sizeY = its extent along part X / Y before rotation; cornerRadius = the
       radius of its corners (0 = square, a factory may leave a cutter radius);
       angle = rotation about its centre, degrees, counter-clockwise in the
       part's x/y coordinates (the spec's "Turning sense"). A pocket may run past the part's edges (an open-ended groove). -->
  <xs:complexType name="Pocket">
    <xs:attribute name="face" type="FaceId" use="required"/>
    <xs:attribute name="x" type="xs:decimal" use="required"/>
    <xs:attribute name="y" type="xs:decimal" use="required"/>
    <xs:attribute name="sizeX" type="xs:decimal" use="required"/>
    <xs:attribute name="sizeY" type="xs:decimal" use="required"/>
    <xs:attribute name="cornerRadius" type="xs:decimal" default="0"/>
    <xs:attribute name="angle" type="xs:decimal" default="0"/>
    <xs:attribute name="depth" type="xs:decimal"/>
    <xs:attribute name="through" type="xs:boolean" default="false"/>
    <xs:attributeGroup ref="OpLabel"/>
    <xs:attribute name="origin" type="OriginatorId"/>   <!-- who added it; default: inherited -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:simpleType name="ArcDir">
    <xs:restriction base="xs:string">
      <xs:enumeration value="cw"/><xs:enumeration value="ccw"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="ToolSide">
    <xs:restriction base="xs:string">
      <xs:enumeration value="left"/><xs:enumeration value="right"/><xs:enumeration value="centre"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- ========================================================= grain match -->
  <!-- 0.4.2. A match's frame is the parts' own (x, y as a part's, seen from face B). Each member is a
       part's rectangle, its lowest corner at x, y, turned 0, 90, 180 or 270 in its plane. The
       checks the XSD cannot make (at least two members, no overlap, every grain along one axis, one board, no part
       more often than its quantity) are the validator's grainmatch.* codes. -->
  <xs:complexType name="GrainMatches">
    <xs:sequence>
      <xs:element name="GrainMatch" type="GrainMatch" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="GrainMatch">
    <xs:sequence>
      <xs:element name="Member" type="GrainMatchMember" minOccurs="2" maxOccurs="unbounded"/>
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:attribute name="name" type="xs:string"/>
    <!-- true: cut as arranged from one board, or not at all; false (default): preferred -->
    <xs:attribute name="required" type="xs:boolean" default="false"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="GrainMatchMember">
    <xs:attribute name="part" type="xs:IDREF" use="required"/>
    <xs:attribute name="x" type="xs:decimal" use="required"/>
    <xs:attribute name="y" type="xs:decimal" use="required"/>
    <xs:attribute name="turn" default="0">
      <xs:simpleType>
        <xs:restriction base="xs:integer">
          <xs:enumeration value="0"/>
          <xs:enumeration value="90"/>
          <xs:enumeration value="180"/>
          <xs:enumeration value="270"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- ============================================================ assembly -->
  <xs:complexType name="Assembly">
    <xs:sequence>
      <xs:element name="Instance" type="Instance" maxOccurs="unbounded"/>
      <!-- 0.3: end-user assembly instructions for this Assembly's instances. -->
      <xs:element name="Steps" type="Steps" minOccurs="0"/>
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:attribute name="name" type="xs:string"/>
    <xs:attribute name="units" type="xs:string" default="mm"/>
    <xs:attribute name="design" type="xs:IDREF"/>   <!-- -> Design it places -->
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- 0.3. Steps: ordered build steps for the Assembly's instances. Sub-assemblies (a
       drawer box) are built first and added to a main step as one move. Every part of a
       step but its order and what it adds is optional. The checks the XSD cannot make
       (Add names an Instance of this Assembly, once; AddSubAssembly a SubAssembly here;
       Fit a Hardware Item; n runs 1..k) are the validator's: steps.* codes. -->
  <xs:complexType name="Steps">
    <xs:sequence>
      <xs:element name="Tools" type="xs:string" minOccurs="0"/>
      <xs:element name="Safety" type="xs:string" minOccurs="0"/>
      <xs:element name="SubAssembly" type="SubAssembly" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Step" type="Step" minOccurs="0" maxOccurs="unbounded"/>
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="SubAssembly">
    <xs:sequence>
      <xs:element name="Step" type="Step" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:attribute name="name" type="xs:string"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="Step">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="Add" type="StepAdd"/>
      <xs:element name="AddSubAssembly" type="StepAddSubAssembly"/>
      <xs:element name="Fit" type="StepFit"/>
      <xs:any namespace="##other" processContents="lax"/>
    </xs:choice>
    <xs:attribute name="n" type="xs:positiveInteger" use="required"/>
    <xs:attribute name="text" type="xs:string"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <!-- instance: an Instance of this Assembly put on in this step. face/faceTo: which face
       (A or B) faces which way in the cabinet; edge/edgeTo: which edge label faces which
       way. All four optional; a reader may work them out from the placement. -->
  <xs:complexType name="StepAdd">
    <xs:attribute name="instance" type="xs:IDREF" use="required"/>
    <xs:attribute name="face" type="StepFace"/>
    <xs:attribute name="faceTo" type="CabinetDirection"/>
    <xs:attribute name="edge" type="EdgeLabel"/>
    <xs:attribute name="edgeTo" type="CabinetDirection"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="StepAddSubAssembly">
    <xs:attribute name="ref" type="xs:IDREF" use="required"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:complexType name="StepFit">
    <xs:attribute name="hardware" type="xs:IDREF" use="required"/>   <!-- -> Hardware Item -->
    <xs:attribute name="quantity" type="xs:positiveInteger" default="1"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:simpleType name="StepFace">
    <xs:restriction base="xs:string"><xs:enumeration value="A"/><xs:enumeration value="B"/></xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="CabinetDirection">
    <xs:restriction base="xs:string">
      <xs:enumeration value="outside"/><xs:enumeration value="inside"/>
      <xs:enumeration value="front"/><xs:enumeration value="back"/>
      <xs:enumeration value="up"/><xs:enumeration value="down"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="Instance">
    <xs:sequence>
      <xs:element name="Position">
        <xs:complexType>
          <xs:attribute name="x" type="xs:decimal" use="required"/>
          <xs:attribute name="y" type="xs:decimal" use="required"/>
          <xs:attribute name="z" type="xs:decimal" use="required"/>
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:complexType>
      </xs:element>
      <!-- Orientation: matrix (canonical) OR axis-map. matrix: 9 space-separated
           values, a row-major 3x3 local->product rotation (proper: orthonormal,
           det +1); 16 (4x4, no translation) accepted. Axis-map: localX and localY
           (+X, -Z, ...); localZ optional and, when given, localX x localY. -->
      <xs:element name="Orientation">
        <xs:complexType>
          <xs:attribute name="localX" type="AxisMap"/>
          <xs:attribute name="localY" type="AxisMap"/>
          <xs:attribute name="localZ" type="AxisMap"/>
          <xs:attribute name="matrix" type="xs:string"/>   <!-- 9 values, row-major 3x3 rotation -->
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:complexType>
      </xs:element>
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="part" type="xs:IDREF" use="required"/>
    <xs:attribute name="id" type="xs:ID" use="required"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>

  <xs:simpleType name="AxisMap">
    <xs:restriction base="xs:string">
      <xs:pattern value="[+-](X|Y|Z)"/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
