<?xml version="1.0" encoding="utf-8"?>
<!-- ====================================================================== -->
<!-- Copyright © 2024 Typefi Systems. All rights reserved.                  -->
<!--                                                                        -->
<!-- Schema Version: 3.3                                                    -->
<!-- Schema Location: https://www.typefi.com/TPS/content/3_3/ContentXML.xsd -->
<!--                                                                        -->
<!-- ====================================================================== -->
<xsd:schema xmlns="http://www.typefi.com/ContentXML"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.typefi.com/ContentXML"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified"
  xml:lang="en"
  xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
  vc:minVersion="1.1">

  <!-- ==================================================================== -->
  <!-- Import for xml:lang and xml:space                                    -->
  <!-- ==================================================================== -->
  <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>

  <!-- ==================================================================== -->
  <!-- Content is composed of paras, contexts, conditions, images and lists -->
  <!-- ==================================================================== -->
  <xsd:group name="ContentGroup">
    <xsd:choice>
      <xsd:group ref="Headings"/>
      <xsd:element name="p" type="InlineType"/>
      <xsd:element name="context" type="ContextType"/>
      <xsd:element name="condition" type="ConditionType"/>
      <xsd:element name="image" type="ImageType"/>
      <xsd:element name="video" type="VideoType"/>
      <xsd:element name="audio" type="AudioType"/>
      <xsd:element name="ol" type="OrderedListType"/>
      <xsd:element name="ul" type="UnorderedListType"/>
      <xsd:element name="table" type="TableType"/>
      <xsd:element name="break" type="BreakType"/>
      <xsd:element name="toc" type="TocType"/>
      <xsd:element name="meta" type="MetadataType"/>
    </xsd:choice>
  </xsd:group>

  <!-- ==================================================================== -->
  <!-- Valid values for the table valign attribute.                         -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="TableValignEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="top"/>
      <xsd:enumeration value="middle"/>
      <xsd:enumeration value="bottom"/>
      <xsd:enumeration value="justify"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Valid values for the table halign attribute.                         -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="TableHalignEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="left"/>
      <xsd:enumeration value="center"/>
      <xsd:enumeration value="right"/>
      <xsd:enumeration value="justify"/>
      <xsd:enumeration value="justifyLeft"/>
      <xsd:enumeration value="justifyCenter"/>
      <xsd:enumeration value="justifyRight"/>
      <xsd:enumeration value="justifyFull"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Valid values for the table rotate attribute.                         -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="TableRotateEnumeration">
    <xsd:restriction base="xsd:integer">
      <xsd:enumeration value="0"/>
      <xsd:enumeration value="90"/>
      <xsd:enumeration value="180"/>
      <xsd:enumeration value="270"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Valid values for the attribute type of a soft-style (tps:style).     -->
  <!-- These values can be combined using '|' as delimiter.                 -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="StyleType">
    <xsd:restriction base="xsd:string">
      <xsd:pattern
        value="(bold|italic|underline|strikethrough|superscript|subscript|allCaps|smallCaps|nobreak)(\|(bold|italic|underline|strikethrough|superscript|subscript|allCaps|smallCaps|nobreak))*"/>
    </xsd:restriction>
  </xsd:simpleType>
  

<!-- ==================================================================== -->
  <!-- Valid values for the attribute style of ordered lists.               -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="OrderedListStyleEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="none"/>
      <xsd:enumeration value="1"/>
      <xsd:enumeration value="I"/>
      <xsd:enumeration value="i"/>
      <xsd:enumeration value="A"/>
      <xsd:enumeration value="a"/>
      <xsd:enumeration value="01"/>
      <xsd:enumeration value="001"/>
      <xsd:enumeration value="0001"/>
      <!--  Arabic letters  -->
      <xsd:enumeration value="abjad"/>
      <xsd:enumeration value="alif ba tah"/>
      <!-- CJK letters -->
      <xsd:enumeration value="kanji"/>
      <xsd:enumeration value="katakana modern"/>
      <xsd:enumeration value="katakana traditional"/>
      <!-- Hebrew letters -->
      <xsd:enumeration value="hebrew biblical"/>
      <xsd:enumeration value="hebrew non-standard"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- The schema change is a new attribute on <content> and <section>      -->
  <!-- called whiteSpaceMode. Like strictSpace it will be optional (to      -->
  <!-- maintain backwards compatibility). If both are present               -->
  <!-- whiteSpaceMode overrides strictSpace.                                -->
  <!--                                                                      -->
  <!-- The strictSpace attribute is now deprecated. Still supported, but    -->
  <!-- deprecated. From V6 our documentation should talk only about         -->
  <!-- whiteSpaceMode.                                                      -->
  <!--                                                                      -->
  <!-- Like strictSpace:                                                    -->
  <!--                                                                      -->
  <!-- 1. whiteSpaceMode applies to all content within the relevant content -->
  <!--    or section, and                                                   -->
  <!-- 2. single jobs can mix up whiteSpaceModes on a section by section    -->
  <!--    basis                                                             -->
  <!--                                                                      -->
  <!-- The 3 valid values for whiteSpaceMode are:                           -->
  <!--                                                                      -->
  <!-- 1. "classic" This is the behaviour of early versions of Typefi       -->
  <!--    Publish:                                                          -->
  <!--    a. All occurrences of #x9 (tab), #xA (line feed) and #xD          -->
  <!--       (carriage return)                                              -->
  <!--       are replaced with #x20 (space).                                -->
  <!--    b. Contiguous sequences of #x20’s are collapsed to a single #x20. -->
  <!--    c. Leading #x20’s are trimmed from the beginning of <p> elements. -->
  <!-- 2. "strict"  This is the only mode that guarantees immunity from     -->
  <!--    pretty printing                                                   -->
  <!--    (as long as you’ve setup all your <s/> tags correctly).           -->
  <!--    a. All occurrences of #x9 (tab), #xA (line feed) and #xD          -->
  <!--       (carriage return)                                              -->
  <!--       are replaced with #x20 (space).                                -->
  <!--    b. Contiguous sequences of #x20’s are collapsed to a single #x20. -->
  <!--    c. Leading and trailing #x20’s are removed from all text nodes.   -->
  <!-- 3. "preserve" No normalization is done, the value is not changed.    -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="WhiteSpaceModeEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="classic"/>
      <xsd:enumeration value="strict"/>
      <xsd:enumeration value="preserve"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Table cells are composed of the normal content group.                -->
  <!-- ==================================================================== -->
  <xsd:complexType name="TableCellType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="Headings"/>
      <xsd:element name="p" type="ParaType"/>
      <xsd:element name="context" type="ContextType"/>
      <xsd:element name="condition" type="ConditionType"/>
      <xsd:element name="image" type="ImageType"/>
      <xsd:element name="video" type="VideoType"/>
      <xsd:element name="audio" type="AudioType"/>
      <xsd:element name="ol" type="OrderedListType"/>
      <xsd:element name="ul" type="UnorderedListType"/>
      <xsd:element name="break" type="BreakType"/>
      <xsd:element name="toc" type="TocType"/>
      <xsd:element name="meta" type="MetadataType"/>
    </xsd:choice>
    <xsd:attribute name="namest" type="xsd:string" use="optional"/>
    <xsd:attribute name="nameend" type="xsd:string" use="optional"/>
    <xsd:attribute name="valign" type="TableValignEnumeration" use="optional"/>
    <xsd:attribute name="align" type="TableHalignEnumeration" use="optional"/>
    <xsd:attribute name="rotate" type="TableRotateEnumeration" use="optional"/>
    <xsd:attribute name="morerows" type="xsd:integer" use="optional"/>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="style" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Table rows are composed of table cells.                              -->
  <!-- ==================================================================== -->
  <xsd:complexType name="TableRowType">
    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="entry" type="TableCellType"/>
    </xsd:sequence>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Table Body Sections are composed of table rows.                      -->
  <!-- ==================================================================== -->
  <xsd:complexType name="TableBodySectionType">
    <xsd:sequence minOccurs="1" maxOccurs="unbounded">
      <xsd:element name="row" type="TableRowType"/>
    </xsd:sequence>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Table Sections are composed of table rows.                           -->
  <!-- ==================================================================== -->
  <xsd:complexType name="TableSectionType">
    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="row" type="TableRowType"/>
    </xsd:sequence>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A table col spec defines column information for a table.             -->
  <!-- ==================================================================== -->
  <xsd:complexType name="TableColSpecType">
    <xsd:attribute name="colname" type="xsd:string" use="required"/>
    <xsd:attribute name="align" type="TableHalignEnumeration" use="optional"/>
    <xsd:attribute name="rotate" type="TableRotateEnumeration" use="optional"/>
    <xsd:attribute name="colwidth" type="FixedOrRelativeWidthType" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- http://www.oasis-open.org/specs/tm9901.html#AEN530                   -->
  <!--                                                                      -->
  <!-- Either proportional measure of the form number*, e.g., “5*” for 5    -->
  <!-- times the proportion, or “*” (which is equivalent to “1*”); fixed    -->
  <!-- measure, e.g., 2pt for 2 point, 3pi for 3 pica. (Mixed measure,      -->
  <!-- e.g., 2*+3pt, while allowed in the full CALS table model, is not     -->
  <!-- supported in this Exchange model.) Coefficients are positive         -->
  <!-- integers or fixed point numbers; for fixed point numbers, a leading  -->
  <!-- (possibly 0) integer part is required, and implementations should    -->
  <!-- support at least 2 decimal places. A value of "" [the null string]   -->
  <!-- is treated as a proportional measure of “1*”.                        -->
  <!--                                                                      -->
  <!-- The fixed unit values are case insensitive. The standard list of     -->
  <!-- allowed unit values is “pt” (points), “cm” (centimeters), “mm”       -->
  <!-- (millimeters), “pi” (picas), and “in” (inches). The default fixed    -->
  <!-- unit should be interpreted as “pt” if neither a proportion nor a     -->
  <!-- fixed unit is specified.                                             -->
  <!--                                                                      -->
  <!-- NOTE: Typefi Publish also allows % as a valid unit.                  -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="FixedOrRelativeWidthType">
    <xsd:restriction base="xsd:string">
      <!-- XML-15: CXML 3.1: Added support for ".9862%" (no leading 0). -->
      <xsd:pattern
        value="(\d+|\d+\.\d+|\.\d+)\s*([Pp][Tt]|[Cc][Mm]|[Mm][Mm]|[Pp][Ii]|[Ii][Nn]|%|\*)?"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- A table group is a sequence of header, body and footer regions.      -->
  <!-- ==================================================================== -->
  <xsd:complexType name="TableGroupType">
    <xsd:sequence>
      <!-- each column in the table must have a colspec -->
      <xsd:element name="colspec" minOccurs="1" maxOccurs="unbounded" type="TableColSpecType"/>
      <xsd:element name="thead" minOccurs="0" maxOccurs="1" type="TableSectionType"/>
      <xsd:element name="tbody" minOccurs="1" maxOccurs="1" type="TableBodySectionType"/>
      <xsd:element name="tfoot" minOccurs="0" maxOccurs="1" type="TableSectionType"/>
    </xsd:sequence>
    <xsd:attribute name="cols" type="xsd:integer" use="required"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Tables are composed of table groups.                                 -->
  <!-- ==================================================================== -->
  <xsd:complexType name="TableType">
    <xsd:sequence minOccurs="0" maxOccurs="1">
      <xsd:element name="tgroup" type="TableGroupType"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="width" type="FixedOrRelativeWidthType" use="optional"/>
    <xsd:attribute name="condition" type="xsd:string" use="optional"/>
    <xsd:attribute name="style" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Ordered List type.                                                   -->
  <!-- ==================================================================== -->
  <xsd:complexType name="OrderedListType">
    <xsd:sequence>
      <xsd:element name="liFormat" minOccurs="0" maxOccurs="1" type="ListItemFormatType"/>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:element name="li" type="ListItemType"/>
        <xsd:element name="condition" type="ConditionalListItems"/>
        <xsd:element name="meta" type="MetadataType"/>
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="style" type="OrderedListStyleEnumeration" use="optional"/>
    <xsd:attribute name="start" type="xsd:integer" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Unordered List type.                                                 -->
  <!-- ==================================================================== -->
  <xsd:complexType name="UnorderedListType">
    <xsd:sequence>
      <xsd:element name="liFormat" minOccurs="0" maxOccurs="1" type="ListItemFormatType"/>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:element name="li" type="ListItemType"/>
        <xsd:element name="condition" type="ConditionalListItems"/>
        <xsd:element name="meta" type="MetadataType"/>
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="style" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Conditional List Items Type.                                         -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ConditionalListItems">
    <xsd:sequence>
      <xsd:element name="li" minOccurs="0" maxOccurs="unbounded" type="ListItemType"/>
    </xsd:sequence>
    <xsd:attribute name="type" type="xsd:string" use="required"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- List Item Format Type.                                               -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ListItemFormatType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="t" type="WhitespaceType"/>
      <xsd:element name="s" type="WhitespaceType"/>
      <xsd:element name="l" type="WhitespaceType"/>
      <xsd:element name="liRef" type="ListItemReferenceType"/>
      <xsd:element name="style" type="SoftStyleListItemType"/>
    </xsd:choice>
    <xsd:attribute name="align" type="TableHalignEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Paras are composed of inline elements.                               -->
  <!-- ==================================================================== -->
  <xsd:complexType name="SoftStyleListItemType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="t" type="WhitespaceType"/>
      <xsd:element name="s" type="WhitespaceType"/>
      <xsd:element name="l" type="WhitespaceType"/>
      <xsd:element name="liRef" type="ListItemReferenceType"/>
      <xsd:element name="style" type="SoftStyleListItemType"/>
    </xsd:choice>
    <xsd:attribute name="type" type="StyleType" use="required"/>
   
    <xsd:assert test="not(contains(@type, 'subscript') and contains(@type, 'superscript'))"/>
    <xsd:assert test="not(matches(@type, '(^|\|)allCaps') and matches(@type, '(^|\|)smallCaps'))"/>
    
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- List Item Reference Type.                                            -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ListItemReferenceType">
    <xsd:attribute name="level" type="xsd:integer" use="optional" default="0"/>
    <xsd:attribute name="style" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- List Item Type.                                                      -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ListItemType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="ContentGroup"/>
    </xsd:choice>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Images contain ref and comment attributes.                           -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ImageType">
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="ref" type="xsd:string" use="optional"/>
    <xsd:attribute name="comment" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Video.                                                               -->
  <!-- Added in CXML 3.0 / Typefi 8.2.0.                                    -->
  <!-- ==================================================================== -->
  <xsd:complexType name="VideoType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="poster" type="VideoPosterType"/>
      <xsd:element name="altRef" type="AltRefType"/>
    </xsd:choice>
    <xsd:attribute name="ref" type="xsd:string" use="required"/>
    <xsd:attribute name="comment" type="xsd:string" use="optional"/>
    <xsd:attribute name="autoplay" type="xsd:boolean" use="optional"/>
    <xsd:attribute name="controls" type="xsd:boolean" use="optional"/>
    <xsd:attribute name="loop" type="xsd:boolean" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Audio.                                                               -->
  <!-- Added in CXML 3.0 / Typefi 8.2.0.                                    -->
  <!-- ==================================================================== -->
  <xsd:complexType name="AudioType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="poster" type="AudioPosterType"/>
      <xsd:element name="altRef" type="AltRefType"/>
    </xsd:choice>
    <xsd:attribute name="ref" type="xsd:string" use="required"/>
    <xsd:attribute name="comment" type="xsd:string" use="optional"/>
    <xsd:attribute name="autoplay" type="xsd:boolean" use="optional"/>
    <xsd:attribute name="controls" type="xsd:boolean" use="optional"/>
    <xsd:attribute name="loop" type="xsd:boolean" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Video Poster Image.                                                  -->
  <!-- Added in CXML 3.0 / Typefi 8.2.0.                                    -->
  <!-- ==================================================================== -->
  <xsd:complexType name="VideoPosterType">
    <xsd:attribute name="type" type="VideoPosterTypeEnumeration" use="required"/>
    <xsd:attribute name="ref" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Audio Poster Image.                                                  -->
  <!-- Added in CXML 3.0 / Typefi 8.2.0.                                    -->
  <!-- ==================================================================== -->
  <xsd:complexType name="AudioPosterType">
    <xsd:attribute name="type" type="AudioPosterTypeEnumeration" use="required"/>
    <xsd:attribute name="ref" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Alt Ref (alternative media file for video or audio).                 -->
  <!-- Added in CXML 3.0 / Typefi 8.2.0.                                    -->
  <!-- ==================================================================== -->
  <xsd:complexType name="AltRefType">
    <xsd:attribute name="ref" type="xsd:string" use="required"/>
    <xsd:attribute name="target" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Valid values for the video poster type attribute.                    -->
  <!-- Added in CXML 3.0 / Typefi 8.2.0.                                    -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="VideoPosterTypeEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="none"/>
      <xsd:enumeration value="default"/>
      <xsd:enumeration value="image"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Valid values for the audio poster type attribute.                    -->
  <!-- Added in CXML 3.0 / Typefi 8.2.0.                                    -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="AudioPosterTypeEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="none"/>
      <xsd:enumeration value="default"/>
      <xsd:enumeration value="image"/>
    </xsd:restriction>
  </xsd:simpleType>


  <!-- ==================================================================== -->
  <!-- Valid values for the status attribute.                               -->
  <!-- Added in CXML 3.3                                                    -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="StatusTypeEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="changed"/>
      <xsd:enumeration value="added"/>
      <xsd:enumeration value="deleted"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Conditions are composed of sections or standard content.             -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ConditionType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="ContentGroup"/>
    </xsd:choice>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="type" type="xsd:string" use="required"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>


  <!-- ==================================================================== -->
  <!-- Contexts are composed of standard content.                           -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ContextType">
    <xsd:sequence>
      <xsd:element name="fieldSet" minOccurs="0" maxOccurs="unbounded" type="FieldSetType"/>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:group ref="ContentGroup"/>
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="type" type="xsd:string" use="required"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="variant" type="xsd:string" use="optional"/>
    <xsd:attribute name="condition" type="xsd:string" use="optional"/>
    <xsd:attribute ref="xml:lang" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Footnotes and endnotes are composed of standard content.             -->
  <!-- ==================================================================== -->
  <xsd:complexType name="FootnoteType">
    <xsd:sequence>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:group ref="ContentGroup"/>
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="value" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Anchors are InlineTypes with a couple of extra attributes.           -->
  <!-- ==================================================================== -->
  <xsd:complexType name="AnchorType">
    <xsd:attribute name="id" type="xsd:string" use="required"/>
    <xsd:attribute name="name" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- New in Typefi Publish 6                                              -->
  <!-- A cross-reference.                                                   -->
  <!-- ==================================================================== -->
  <xsd:complexType name="RefType">
    <xsd:attribute name="refType" type="RefTypeEnumeration" use="required"/>
    <xsd:attribute name="refId" type="xsd:string" use="required"/>
    <xsd:attribute name="format" type="xsd:string" use="required"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- New in Typefi Publish 6                                              -->
  <!-- Valid values for the <ref> refType attribute.                        -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="RefTypeEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="anchor"/>
      <xsd:enumeration value="paragraph"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Whitespace is an empty element with a single attribute.              -->
  <!-- ==================================================================== -->
  <xsd:complexType name="WhitespaceType">
    <xsd:attribute name="c" type="xsd:integer" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- The common group of heading elements.                                -->
  <!-- ==================================================================== -->
  <xsd:group name="Headings">
    <xsd:choice>
      <xsd:element name="h1" type="InlineType"/>
      <xsd:element name="h2" type="InlineType"/>
      <xsd:element name="h3" type="InlineType"/>
      <xsd:element name="h4" type="InlineType"/>
      <xsd:element name="h5" type="InlineType"/>
      <xsd:element name="h6" type="InlineType"/>
    </xsd:choice>
  </xsd:group>

  <!-- ==================================================================== -->
  <!-- The common group of inline elements available anywhere inline.       -->
  <!-- ==================================================================== -->
  <xsd:group name="CommonInlineElements">
    <xsd:choice>
      <xsd:element name="context" type="ContextType"/>
      <xsd:element name="image" type="ImageType"/>
      <xsd:element name="video" type="VideoType"/>
      <xsd:element name="audio" type="AudioType"/>
      <xsd:element name="footnote" type="FootnoteType"/>
      <xsd:element name="endnote" type="FootnoteType"/>
      <xsd:element name="anchor" type="AnchorType"/>
      <xsd:element name="ref" type="RefType"/>
      <xsd:element name="t" type="WhitespaceType"/>
      <xsd:element name="s" type="WhitespaceType"/>
      <xsd:element name="l" type="WhitespaceType"/>
      <xsd:element name="liRef" type="ListItemReferenceType"/>
      <xsd:element name="indexterm" type="IndexTermType"/>
      <xsd:element name="char" type="CharType"/>
      <xsd:element name="meta" type="MetadataType"/>
      <xsd:element name="fieldRef" type="FieldRefType"/>
      <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
    </xsd:choice>
  </xsd:group>

  <!-- ==================================================================== -->
  <!-- Reuseable group of inline elements.                                  -->
  <!-- ==================================================================== -->
  <xsd:group name="InlineElements">
    <xsd:choice>
      <xsd:group ref="CommonInlineElements"/>
      <xsd:element name="c" type="InlineType"/>
      <xsd:element name="condition" type="ConditionInlineType"/>
      <xsd:element name="link" type="LinkType"/>
      <xsd:element name="doclink" type="DocLinkType"/>
      <xsd:element name="style" type="SoftStyleInlineType"/>
      <xsd:element name="table" type="TableType"/>
    </xsd:choice>
  </xsd:group>

  <!-- ==================================================================== -->
  <!-- Reuseable group of inline elements allowed within links.             -->
  <!-- ==================================================================== -->
  <xsd:group name="LinkInlineElements">
    <xsd:choice>
      <xsd:group ref="CommonInlineElements"/>
      <xsd:element name="c" type="SubLinkType"/>
      <xsd:element name="condition" type="SubLinkType"/>
      <xsd:element name="style" type="SoftStyleSubLinkType"/>
    </xsd:choice>
  </xsd:group>

  <!-- ==================================================================== -->
  <!-- Paras are composed of inline elements.                               -->
  <!-- ==================================================================== -->
  <xsd:complexType name="InlineType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="InlineElements"/>
    </xsd:choice>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="style" type="xsd:string" use="optional"/>
    <xsd:attribute ref="xml:lang" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>


  <xsd:complexType name="SoftStyleInlineType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="InlineElements"/>
    </xsd:choice>
    <xsd:attribute name="type" type="StyleType" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute ref="xml:lang" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
    
    <xsd:assert test="not(contains(@type, 'subscript') and contains(@type, 'superscript'))"/>
    <xsd:assert test="not(matches(@type, '(^|\|)allCaps') and matches(@type, '(^|\|)smallCaps'))"/>
    
  </xsd:complexType>
  
  <!-- ==================================================================== -->
  <!-- Derived from InlineType, excluded tables                             -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ParaType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="CommonInlineElements"/>
      <xsd:element name="c" type="InlineType"/>
      <xsd:element name="condition" type="ConditionInlineType"/>
      <xsd:element name="link" type="LinkType"/>
      <xsd:element name="doclink" type="DocLinkType"/>
      <xsd:element name="style" type="SoftStyleInlineType"/>
    </xsd:choice>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="style" type="xsd:string" use="optional"/>
    <xsd:attribute ref="xml:lang" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Conditions are composed of inline elements without style attribute.  -->
  <!-- ==================================================================== -->
  <xsd:complexType name="ConditionInlineType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="InlineElements"/>
    </xsd:choice>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute ref="xml:lang" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A link contains the reference and an optional label.                 -->
  <!-- ==================================================================== -->
  <xsd:complexType name="LinkType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="LinkInlineElements"/>
    </xsd:choice>
    <xsd:attribute name="ref" type="xsd:string" use="required"/>
    <xsd:attribute name="label" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A doclink contains the reference and an optional label.              -->
  <!-- ==================================================================== -->
  <xsd:complexType name="DocLinkType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="LinkInlineElements"/>
    </xsd:choice>
    <xsd:attribute name="refType" type="RefTypeEnumeration" use="required"/>
    <xsd:attribute name="refId" type="xsd:string" use="required"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- The sub link type is a helper construction to avoid the use of       -->
  <!-- tps:link inside tps:c and tps:condition if this occur in the context -->
  <!-- of a tps:link. The attribute id is needed for conditions.            -->
  <!-- ==================================================================== -->
  <xsd:complexType name="SubLinkType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="LinkInlineElements"/>
    </xsd:choice>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
  </xsd:complexType>


  <xsd:complexType name="SoftStyleSubLinkType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:group ref="LinkInlineElements"/>
    </xsd:choice>
    <xsd:attribute name="type" type="StyleType" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>

    <xsd:assert test="not(contains(@type, 'subscript') and contains(@type, 'superscript'))"/>
    <xsd:assert test="not(matches(@type, '(^|\|)allCaps') and matches(@type, '(^|\|)smallCaps'))"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Break type.                                                          -->
  <!-- ==================================================================== -->
  <xsd:complexType name="BreakType">
    <xsd:attribute name="type" type="BreakTypeEnumeration" use="required"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Valid values for the type attribute of <break> tags.                 -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="BreakTypeEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="column"/>
      <xsd:enumeration value="frame"/>
      <xsd:enumeration value="evenPage"/>
      <xsd:enumeration value="oddPage"/>
      <xsd:enumeration value="page"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Char type.                                                           -->
  <!-- ==================================================================== -->
  <xsd:complexType name="CharType">
    <xsd:attribute name="type" type="CharTypeEnumeration" use="required"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- Valid values for the type attribute of <char> tags.                  -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="CharTypeEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="currentPageNumber"/>
      <xsd:enumeration value="nextPageNumber"/>
      <xsd:enumeration value="previousPageNumber"/>
      <xsd:enumeration value="sectionMarker"/>
      <xsd:enumeration value="rightIndentTab"/>
      <xsd:enumeration value="indentToHere"/>
      <xsd:enumeration value="endNestedStyleHere"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- Styled text is mixed with character styles and whitespace.           -->
  <!-- ==================================================================== -->
  <xsd:complexType name="StyledTextType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="c" type="StyledTextType"/>
      <xsd:element name="t" type="WhitespaceType"/>
      <xsd:element name="s" type="WhitespaceType"/>
      <xsd:element name="l" type="WhitespaceType"/>
      <xsd:element name="liRef" type="ListItemReferenceType"/>
      <xsd:element name="condition" type="StyledTextType"/>
      <xsd:element name="style" type="SoftStyleTextType"/>
      <xsd:element name="meta" type="MetadataType"/>
    </xsd:choice>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
  </xsd:complexType>
  
  
  <xsd:complexType name="SoftStyleTextType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="c" type="StyledTextType"/>
      <xsd:element name="t" type="WhitespaceType"/>
      <xsd:element name="s" type="WhitespaceType"/>
      <xsd:element name="l" type="WhitespaceType"/>
      <xsd:element name="liRef" type="ListItemReferenceType"/>
      <xsd:element name="condition" type="StyledTextType"/>
      <xsd:element name="style" type="SoftStyleTextType"/>
      <xsd:element name="meta" type="MetadataType"/>
    </xsd:choice>
    <xsd:attribute name="type" type="StyleType" use="required"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    
    <xsd:assert test="not(contains(@type, 'subscript') and contains(@type, 'superscript'))"/>
    <xsd:assert test="not(matches(@type, '(^|\|)allCaps') and matches(@type, '(^|\|)smallCaps'))"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A field set contains the field's 'name' and 'value'.                 -->
  <!-- ==================================================================== -->
  <xsd:complexType name="FieldSetType">
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="name" type="xsd:string" use="required"/>
    <xsd:attribute name="value" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A field ref allows a field value to be substituted anywhere in       -->
  <!-- content.                                                             -->
  <!-- ==================================================================== -->
  <xsd:complexType name="FieldRefType" mixed="true">
    <xsd:attribute name="name" type="xsd:string" use="required"/>
    <xsd:attribute name="refId" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <xsd:complexType name="SimpleTextType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="t" type="WhitespaceType"/>
      <xsd:element name="s" type="WhitespaceType"/>
      <xsd:element name="l" type="WhitespaceType"/>
    </xsd:choice>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- An index term.                                                       -->
  <!-- Similar to http://www.docbook.org/tdg/en/html/indexterm.html         -->
  <!-- ==================================================================== -->
  <xsd:complexType name="IndexTermType">
    <xsd:sequence>
      <xsd:element name="primary" minOccurs="0" maxOccurs="1" type="IndexTopicType"/>
      <xsd:element name="secondary" minOccurs="0" maxOccurs="1" type="IndexTopicType"/>
      <xsd:element name="tertiary" minOccurs="0" maxOccurs="1" type="IndexTopicType"/>
      <xsd:element name="quaternary" minOccurs="0" maxOccurs="1" type="IndexTopicType"/>
      <xsd:choice minOccurs="0" maxOccurs="1">
        <xsd:element name="see" type="IndexReferenceType"/>
        <xsd:element name="seealso" type="IndexReferenceType"/>
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="class" type="IndexTermClassEnumeration" use="optional"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="startref" type="xsd:string" use="optional"/>
    <xsd:attribute name="pageNumberStyle" type="xsd:string" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- An index topic.                                                      -->
  <!-- ==================================================================== -->
  <xsd:complexType name="IndexTopicType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="c" type="IndexTopicCharStyleType"/>
      <xsd:element name="s" type="WhitespaceType"/>
      <xsd:element name="meta" type="MetadataType"/>
    </xsd:choice>
    <xsd:attribute name="sortas" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A char style within an index topic.                                  -->
  <!-- ==================================================================== -->
  <xsd:complexType name="IndexTopicCharStyleType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="s" type="WhitespaceType"/>
    </xsd:choice>
    <xsd:attribute name="type" type="xsd:string" use="required"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- An index reference.                                                  -->
  <!-- ==================================================================== -->
  <xsd:complexType name="IndexReferenceType" mixed="true"/>

  <!-- ==================================================================== -->
  <!-- Valid values for the class attribute of indexterm entries.           -->
  <!-- This is used to denote the indexterm is marking a range of content.  -->
  <!-- There are two supported ways to mark a range.                        -->
  <!--                                                                      -->
  <!-- Example usage for the Microsoft Word style range:                    -->
  <!--                                                                      -->
  <!--   <indexterm class="bookmark" id="Arizona">                          -->
  <!--     <primary>Arizona</primary>                                       -->
  <!--   </indexterm>                                                       -->
  <!--   ...                                                                -->
  <!--   <anchor name="Arizona"/>                                           -->
  <!--                                                                      -->
  <!-- Example usage for the DocBook style range:                           -->
  <!--                                                                      -->
  <!--   <indexterm class="startofrange" id="Arizona"/>                     -->
  <!--     <primary>Arizona</primary>                                       -->
  <!--   </indexterm>                                                       -->
  <!--   ...                                                                -->
  <!--   <indexterm class="endofrange" startref="Arizona"/>                 -->
  <!-- ==================================================================== -->
  <xsd:simpleType name="IndexTermClassEnumeration">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="bookmark"/>
      <xsd:enumeration value="startofrange"/>
      <xsd:enumeration value="endofrange"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ==================================================================== -->
  <!-- A Table Of Contents (TOC) tag. New in CXML 3.1 for Typefi 8.4.0.     -->
  <!-- ==================================================================== -->
  <xsd:complexType name="TocType">
    <xsd:sequence>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:group ref="ContentGroup"/>
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="type" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A Metadata tag. New in CXML 3.1 for Typefi 8.4.0.                    -->
  <!-- Updated in CXML 3.2 to no longer allow nested tags within.           -->
  <!-- ==================================================================== -->
  <xsd:complexType name="MetadataType">
    <xsd:simpleContent>
      <xsd:extension base="xsd:string">
        <xsd:attribute name="type" type="xsd:string" use="optional"/>
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A section consists of (optional) section fields followed by a        -->
  <!-- possibly large amount of mixed section content.                      -->
  <!-- ==================================================================== -->
  <xsd:complexType name="SectionType">
    <xsd:sequence>
      <!-- Section fields. -->
      <xsd:element name="fieldSet" minOccurs="0" maxOccurs="unbounded" type="FieldSetType"/>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:group ref="ContentGroup"/>
      </xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="type" type="xsd:string" use="required"/>
    <xsd:attribute name="id" type="xsd:string" use="optional"/>
    <xsd:attribute name="condition" type="xsd:string" use="optional"/>
    <!-- "strictSpace" attribute deprecated (from Typefi Publish 6). -->
    <xsd:attribute name="strictSpace" type="xsd:boolean" use="optional"/>
    <xsd:attribute name="whiteSpaceMode" type="WhiteSpaceModeEnumeration" use="optional"/>
    <xsd:attribute ref="xml:lang" use="optional"/>
    <xsd:attribute name="startPageNumber" type="xsd:integer" use="optional"/>
    <xsd:attribute name="continuePageNumbering" type="xsd:boolean" use="optional"/>
    <xsd:attribute name="status" type="StatusTypeEnumeration" use="optional"/>
  </xsd:complexType>

  <!-- ==================================================================== -->
  <!-- A CXML document essentially consists of a top-level <content>        -->
  <!-- element wrapped around a sequence of <section> elements.             -->
  <!-- ==================================================================== -->
  <xsd:element name="content">
    <xsd:complexType>
      <xsd:sequence>
        <!-- Project fields. -->
        <xsd:element name="fieldSet" minOccurs="0" maxOccurs="unbounded" type="FieldSetType"/>
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
          <xsd:element name="section" type="SectionType"/>
          <xsd:element name="meta" type="MetadataType"/>
        </xsd:choice>
      </xsd:sequence>
      <!-- "type" attribute deprecated. -->
      <xsd:attribute name="type" type="xsd:string" use="optional"/>
      <xsd:attribute name="schemaVersion" use="optional" type="xsd:string"/>
      <!-- "strictSpace" attribute deprecated (from Typefi Publish 6). -->
      <xsd:attribute name="strictSpace" type="xsd:boolean" use="optional"/>
      <xsd:attribute name="whiteSpaceMode" type="WhiteSpaceModeEnumeration" use="optional"/>
      <xsd:attribute ref="xml:lang" use="optional"/>
    </xsd:complexType>
  </xsd:element>

</xsd:schema>
