Map Specialization XSD Step 2: Define faq-mapDomain Map Domain

Create the FAQ-map map domain module as follows:
  1. Edit the file faq-mapDomain/xsd/faq-mapDomain.xsd.
  2. In mapGrp.xsd from the standard DITA schema distribution, find the group for "topicref" and copy it into faq-mapDomain.xsd after the <xs:import> element:
    <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:group name="topicref">
        <xs:sequence>
          <xs:choice>
            <xs:element ref="topicref"/>
          </xs:choice>
        </xs:sequence>
      </xs:group>
      
      ...
    
    </xs:schema>
  3. In mapMod.xsd find the declarations for <topicref> and copy them to faq-mapDomain.xsd:
    <?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:group name="topicref">
        <xs:sequence>
          <xs:choice>
            <xs:element ref="topicref"/>
          </xs:choice>
        </xs:sequence>
      </xs:group>
    
      <xs:element name="topicref">
        <xs:annotation>
          <xs:documentation>
            The &lt;<keyword>topicref</keyword>&gt; element designates a topic
            (such as a concept, task, or reference) as a link in a DITA map. A &lt;<keyword>topicref</keyword>&gt;
            can contain other&lt;<keyword>topicref</keyword>&gt; elements, allowing you to
            express navigation or table-of-contents hierarchies, as well as implying relationships
            between the containing &lt;<keyword>topicref</keyword>&gt; and its children.
            You can set the collection-type of a container &lt;<keyword>topicref</keyword>&gt;
            to determine how its children are related to each other. Relationships end
            up expressed as links in the output (with each participant in a relationship
            having links to the other participants). 
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:complexContent>
            <xs:extension base="topicref.class">
              <xs:attribute ref="class" default="- map/topicref " />
            </xs:extension>
          </xs:complexContent>
        </xs:complexType>
      </xs:element>
      <xs:complexType name="topicref.class">
        <xs:sequence>
          <xs:group ref="topicref.content"/>
        </xs:sequence>
        <xs:attributeGroup ref="topicref.attributes"/>
      </xs:complexType>
      
      <xs:group name="topicref.content">
        <xs:sequence>
          <xs:sequence>
            <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="data.elements.incl" />
            </xs:choice>
          </xs:sequence>
        </xs:sequence>
      </xs:group>
      
      <xs:attributeGroup name="topicref.attributes">
        <xs:attribute name="navtitle" type="xs:string"/>
        <xs:attribute name="href" type="xs:string"/>
        <xs:attribute name="keys" type="xs:string"/>
        <xs:attribute name="keyref" type="xs:string"/>
        <xs:attribute name="query" type="xs:string"/>
        <xs:attribute name="copy-to" type="xs:string"/>
        <xs:attributeGroup ref="topicref-atts" />
        <xs:attributeGroup ref="univ-atts" />
        <xs:attribute name="outputclass" type="xs:string"/>
        <xs:attributeGroup ref="global-atts" />
      </xs:attributeGroup>
      
    </xs:schema>
    
  4. Change "topicref" to "faq-question-set" everywhere but in the default value for the @class attribute and in the reference to the "topicref-atts" attribute group:
      
      <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:group name="faq-question-set">
        <xs:sequence>
          <xs:choice>
            <xs:element ref="faq-question-set"/>
          </xs:choice>
        </xs:sequence>
      </xs:group>
      
      <xs:element name="faq-question-set">
        <xs:annotation>
          <xs:documentation>
            The &lt;<keyword>faq-question-set</keyword>&gt; element 
            groups sets of <keyword>faq-question</keyword> references
            together. The question set should either point to a topic
            that provides a title for the question set or specify
            a navigation title.
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:complexContent>
            <xs:extension base="faq-question-set.class">
              <xs:attribute ref="class" default="- map/topicref " />
            </xs:extension>
          </xs:complexContent>
        </xs:complexType>
      </xs:element>
      <xs:complexType name="faq-question-set.class">
        <xs:sequence>
          <xs:group ref="faq-question-set.content"/>
        </xs:sequence>
        <xs:attributeGroup ref="faq-question-set.attributes"/>
      </xs:complexType>
      
      <xs:group name="faq-question-set.content">
        <xs:sequence>
          <xs:sequence>
            <xs:group ref="topicmeta" minOccurs="0"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:group ref="navref" />
              <xs:group ref="anchor" />
              <xs:group ref="faq-question-set" />
              <xs:group ref="data.elements.incl" />
            </xs:choice>
          </xs:sequence>
        </xs:sequence>
      </xs:group>
      
      <xs:attributeGroup name="faq-question-set.attributes">
        <xs:attribute name="navtitle" type="xs:string"/>
        <xs:attribute name="href" type="xs:string"/>
        <xs:attribute name="keys" type="xs:string"/>
        <xs:attribute name="keyref" type="xs:string"/>
        <xs:attribute name="query" type="xs:string"/>
        <xs:attribute name="copy-to" type="xs:string"/>
        <xs:attributeGroup ref="topicref-atts" />
        <xs:attributeGroup ref="univ-atts" />
        <xs:attribute name="outputclass" type="xs:string"/>
        <xs:attributeGroup ref="global-atts" />
      </xs:attributeGroup>
    
  5. Validate your test document. You should now get a message to the effect that the content of <faq-question-set> is invalid starting with <faq-question>.
  6. Modify the content model for <faq-question-set> to:
      <xs:group name="faq-question-set.content">
        <xs:sequence>
          <xs:sequence>
            <xs:group ref="topicmeta" minOccurs="0"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:group ref="faq-question" />
            </xs:choice>
          </xs:sequence>
        </xs:sequence>
      </xs:group>
      
  7. Modify the value of the @class attribute to "+ map/topicref faq-map-d/faq-question-set ":
      <xs:element name="faq-question-set">
        <xs:annotation>
          <xs:documentation>
            The &lt;<keyword>faq-question-set</keyword>&gt; element 
            groups sets of <keyword>faq-question</keyword> references
            together. The question set should either point to a topic
            that provides a title for the question set or specify
            a navigation title.
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:complexContent>
            <xs:extension base="faq-question-set.class">
              <xs:attribute ref="class" default="+ map/topicref faq-map-d/faq-question-set " />
            </xs:extension>
          </xs:complexContent>
        </xs:complexType>
      </xs:element>
    
  8. Validate your test document. You should now get a message to the effect that the group "faq-question" cannot be resolved.
  9. Copy all the declarations for <faq-question-set> and rename "faq-question-set" to "faq-question," resulting in these declarations:
      <xs:group name="faq-question">
        <xs:sequence>
          <xs:choice>
            <xs:element ref="faq-question"/>
          </xs:choice>
        </xs:sequence>
      </xs:group>
      
      <xs:element name="faq-question">
        <xs:annotation>
          <xs:documentation>
            The &lt;<keyword>faq-question</keyword>&gt; element 
            represents a single FAQ question within a larger
            FAQ question set.
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:complexContent>
            <xs:extension base="faq-question.class">
              <xs:attribute ref="class" default="+ map/topicref faq-map-d/faq-question " />
            </xs:extension>
          </xs:complexContent>
        </xs:complexType>
      </xs:element>
      <xs:complexType name="faq-question.class">
        <xs:sequence>
          <xs:group ref="faq-question.content"/>
        </xs:sequence>
        <xs:attributeGroup ref="faq-question.attributes"/>
      </xs:complexType>
      
      <xs:group name="faq-question.content">
        <xs:sequence>
          <xs:sequence>
            <xs:group ref="topicmeta" minOccurs="0"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:group ref="faq-question" />
            </xs:choice>
          </xs:sequence>
        </xs:sequence>
      </xs:group>
      
      <xs:attributeGroup name="faq-question.attributes">
        <xs:attribute name="navtitle" type="xs:string"/>
        <xs:attribute name="href" type="xs:string"/>
        <xs:attribute name="keys" type="xs:string"/>
        <xs:attribute name="keyref" type="xs:string"/>
        <xs:attribute name="query" type="xs:string"/>
        <xs:attribute name="copy-to" type="xs:string"/>
        <xs:attributeGroup ref="topicref-atts" />
        <xs:attributeGroup ref="univ-atts" />
        <xs:attribute name="outputclass" type="xs:string"/>
        <xs:attributeGroup ref="global-atts" />
      </xs:attributeGroup>
    
  10. Validate your test document. It should be valid.
  11. Modify the content model of <faq-question> to remove the reference to <faq-question-set>:
      <xs:group name="faq-question.content">
        <xs:sequence>
          <xs:sequence>
            <xs:group ref="topicmeta" minOccurs="0"/>
          </xs:sequence>
        </xs:sequence>
      </xs:group>
  12. Validate your test document. It should still be valid. Verify that you cannot add any subelements to <faq-question> other than <topicmeta>.

At this point the FAQ map and FAQ-map map domain declarations are complete. All that remains is to define appropriate URNs for the schema locations, modify the document type shell to use the URNs rather than relative URLs, and package it all up as a Toolkit plugin.