Map Specialization XSD Step 1: Define faq-map Map Type

To define the <faq-map> map type, do the following:
  1. Create the directory faq-map/xsd.
  2. Create the directory faq-mapDomain/xsd.
  3. Create the file faq-mapDomain/xsd/faq-mapDomain.xsd with this content:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      elementFormDefault="qualified" 
      attributeFormDefault="unqualified">
      
      <xs:import namespace="http://www.w3.org/XML/1998/namespace" 
        schemaLocation="urn:oasis:names:tc:dita:xsd:xml.xsd:1.2"/>
    
    </xs:schema>

    This file acts as the stub for the FAQ map map domain, which we will define in Step 2.

  4. Find the file basemap.xsd from the standard DITA schema distribution and copy it into the faq-map/xsd directory and rename it to faq-map.xsd.
  5. Create test document faq-map/faq-map-test-xsd-01.ditamap with this content:
    <?xml version="1.0" encoding="UTF-8"?>
    <faq-map xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="xsd/faq-map.xsd">
      <title>FAQ Map Test 01</title>
      <topicmeta></topicmeta>
      <keydef keys="foo"/>  
      <faq-question-set>
        <faq-question/>
      </faq-question-set>
    </faq-map>

    Validate the document. It should complain that the element type <faq-map> is not declared.

  6. Edit faq-map.xsd.
  7. Replace the header comment with one reflecting your ownership:
    <!-- ============================================================= 
         FAQ Map document type shell
         
         Copyright (c) 2010 Your Name Here     
         ============================================================= -->
    
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      elementFormDefault="qualified" 
      attributeFormDefault="unqualified" 
      xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">
      <!-- ======= INCLUDE ======= -->
      
      ...
    
    </xs:schema>
  8. Find the reference to mapMod.xsd and add an inclusion to faq-mapMod.xsd after it:
     ...
    
     <xs:include schemaLocation="urn:oasis:names:tc:dita:xsd:mapMod.xsd:1.2" />
     <xs:include schemaLocation="faq-mapMod.xsd" />
    
     ...
    
  9. Find the declaration for the "domains-att" attribute group and add "(map faq-map faq-map-d) " to the @domains attribute value:
      <xs:attributeGroup name="domains-att">
        <xs:attribute name="domains" type="xs:string" 
           default="(map faq-map faq-map-d) (map mapgroup-d) (topic indexing-d) (topic delay-d)"/>
      </xs:attributeGroup>
  10. Create the file faq-map/xsd/faq-mapMod.xsd with this content:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      elementFormDefault="qualified" 
      attributeFormDefault="unqualified" 
      xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">
    
    
    </xs:schema>
  11. Add a header comment as for the faq-map.xsd file.
  12. Edit mapMod.xsd from the standard DITA schema distribution. Find the comment "Import - XML Attributes and Namespaces" and copy it and the two imports following it into faq-mapMod.xsd:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      elementFormDefault="qualified" 
      attributeFormDefault="unqualified" 
      xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">
      
      <!-- ======= IMPORT - XML attributes and namespace ======= -->
      <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="urn:oasis:names:tc:dita:xsd:xml.xsd:1.2"/>
      <xs:import namespace="http://dita.oasis-open.org/architecture/2005/" schemaLocation="urn:oasis:names:tc:dita:xsd:ditaarch.xsd:1.2"/>
    
      ...
    
    </xs:schema> 
  13. Find the <xs:redefine> element for mapGrp.xsd and add an include of faq-mapDomain.xsd immediately before it:
     ...
    
     <xs:include schemaLocation="../../faq-mapDomain/xsd/faq-mapDomain.xsd"/>
      
     <xs:redefine schemaLocation="urn:oasis:names:tc:dita:xsd:mapGrp.xsd:1.2">
    
     ...
  14. In mapMod.xsd find the declarations for the <map> element type (they should all be together in the file) and copy them into faq-mapMod.xsd.
  15. Change "map" to "faq-map" everywhere except in the default value of the @class attribute:
      <xs:element name="faq-map">
        <xs:annotation>
          <xs:documentation>
            The &lt;<keyword>faq-map</keyword>&gt; element represents
            an FAQ publication.
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:complexContent>
            <xs:extension base="faq-map.class">
              <xs:attribute ref="class" default="- map/map " />
            </xs:extension>
          </xs:complexContent>
        </xs:complexType>
      </xs:element>
      <xs:complexType name="faq-map.class" >
        <xs:sequence>
          <xs:group ref="faq-map.content"/>
        </xs:sequence>
        <xs:attributeGroup ref="faq-map.attributes"/>
      </xs:complexType>
      
      <xs:group name="faq-map.content">
        <xs:sequence>
          <xs:sequence>
            <xs:group ref="title" minOccurs="0" />
            <xs:group ref="topicmeta" minOccurs="0" />
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:group ref="navref" />
              <xs:group ref="anchor" />
              <xs:group ref="topicref" />
              <xs:group ref="reltable" />
              <xs:group ref="data.elements.incl" />
            </xs:choice>      
          </xs:sequence>
        </xs:sequence>
      </xs:group>
      
      <xs:attributeGroup name="faq-map.attributes">
        <xs:attribute name="title" type="xs:string" />
        <xs:attribute name="id" type="xs:ID" />
        <xs:attributeGroup ref="conref-atts" />
        <xs:attribute name="anchorref" type="xs:string" />
        <xs:attribute name="outputclass" type="xs:string" />
        <xs:attributeGroup ref="domains-att"/>
        <xs:attributeGroup ref="topicref-atts" />
        <xs:attributeGroup ref="select-atts" />
        <xs:attributeGroup ref="localization-atts"/>
        <xs:attribute ref="ditaarch:DITAArchVersion"/>
        <xs:attributeGroup ref="global-atts" />
      </xs:attributeGroup>
    
  16. Set the default value of the @class attribute to "- map/map faq-map/faq-map ":
      <xs:element name="faq-map">
        <xs:annotation>
          <xs:documentation>
            The &lt;<keyword>faq-map</keyword>&gt; element represents
            an FAQ publication.
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:complexContent>
            <xs:extension base="faq-map.class">
              <xs:attribute ref="class" default="- map/map faq-map/faq-map " />
            </xs:extension>
          </xs:complexContent>
        </xs:complexType>
      </xs:element>
    
  17. Modify the content model defined in the faq-map.content group to:
      <xs:group name="faq-map.content">
        <xs:sequence>
          <xs:sequence>
            <xs:group ref="title" minOccurs="0" />
            <xs:group ref="topicmeta" minOccurs="0" />
            <xs:group ref="keydef" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="faq-question-set" minOccurs="1" maxOccurs="1"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:group ref="reltable" />
            </xs:choice>      
          </xs:sequence>
        </xs:sequence>
      </xs:group>
    
  18. Validate the test document. You should get a message to the effect that the group named "faq-question-set" cannot be resolved.

At this point the FAQ-map map type document type shell and module is complete. Now we just need to define the FAQ-map map domain.