OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

topicmaps-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: Re: [topicmaps-comment] Re: [topicmapmail] XML Schema for XTM DTD


I tried my hand at creating an XML Schema for XTM too, and ended up with a
somewhat different structure.  Just for fun I am including it below.  I
believe it has got everything except the xml:base attribute, which I left
off for now because I did not get around to creating a separate little
schema for it, which you have to do because it is in another namespace.

In this version, I tried to avoid duplication.  Most constructions that
appear more than once, I turned into model groups.  Any element like
instanceOf which contains one of those groups but also has an id (and
possibly other attributes),  I made a type for, and the type uses the model
group.

I used model groups partly because I like them, but also there is at least
one case where the same sequence of elements is used (in different places)
with and without a wrapper element.  The use without the wrapper just uses
the model group (otherwise it would have to use an anonymous complex type),
for the other one I created a named complex type.  This approach has, I
think, eliminated all duplication while keeping the schema simple and
reasonably understandable.

This design probably would not fall out of an automatic translation of an
RNG schema, and although I favor having a normative RNG schema, I have to
admit that more people will probably be served (at least for several years)
by an XML Schema version, whether normative or not.

I made the schema for xlink attributes define just the subset of xlink xtm
uses - href and type (fixed at "simple").

Here is the xlink schema first and then the main schema.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.w3.org/1999/xlink";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
attributeFormDefault="qualified">
 <xs:attribute name="href" type="xs:anyURI"/>
 <xs:attribute name="type" fixed="simple"/>
</xs:schema>

==================================================
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.topicmaps.org/xtm/1.0/";
xmlns:xtm="http://www.topicmaps.org/xtm/1.0/";
xmlns:xlink="http://www.w3.org/1999/xlink";
xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified">
 <xs:import namespace="http://www.w3.org/1999/xlink";
schemaLocation="xlink4.xsd"/>
 <xs:element name="topicMap">
  <xs:complexType>
   <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="topic">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="instanceOf" type="xtm:instanceOfType" minOccurs="0"
maxOccurs="unbounded"/>
       <xs:element name="subjectIdentity" minOccurs="0">
        <xs:complexType>
         <xs:sequence>
          <xs:element name="resourceRef" type="xtm:XLinkType"
minOccurs="0"/>
          <xs:group ref="xtm:addressableSubject.grp" minOccurs="0"
maxOccurs="unbounded"/>
         </xs:sequence>
         <xs:attribute name="id" type="xs:ID"/>
        </xs:complexType>
       </xs:element>
       <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="baseName">
         <xs:complexType>
          <xs:sequence>
           <xs:element name="scope" type="xtm:scopeType" minOccurs="0"/>
           <xs:element name="baseNameString">
            <xs:complexType>
             <xs:simpleContent>
              <xs:extension base="xs:string">
               <xs:attribute name="id" type="xs:ID"/>
              </xs:extension>
             </xs:simpleContent>
            </xs:complexType>
           </xs:element>
           <xs:element name="variant" type="xtm:variantType" minOccurs="0"
maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="id" type="xs:ID"/>
         </xs:complexType>
        </xs:element>
        <xs:element name="occurrence">
         <xs:complexType>
          <xs:sequence>
           <xs:element name="instanceOf" type="xtm:instanceOfType"
minOccurs="0"/>
           <xs:element name="scope" type="xtm:scopeType" minOccurs="0"/>
           <xs:group ref="xtm:resource.grp"/>
          </xs:sequence>
          <xs:attribute name="id" type="xs:ID"/>
         </xs:complexType>
        </xs:element>
       </xs:choice>
      </xs:sequence>
      <xs:attribute name="id" type="xs:ID"/>
     </xs:complexType>
    </xs:element>
    <xs:element name="association">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="instanceOf" type="xtm:instanceOfType"
minOccurs="0"/>
       <xs:element name="scope" type="xtm:scopeType" minOccurs="0"/>
       <xs:element name="member" maxOccurs="unbounded">
        <xs:complexType>
         <xs:sequence>
          <xs:element name="roleSpec" minOccurs="0">
           <xs:complexType>
            <xs:group ref="xtm:addressableSubject.grp"/>
           </xs:complexType>
          </xs:element>
          <xs:group ref="xtm:addressableResource.grp" minOccurs="0"
maxOccurs="unbounded"/>
         </xs:sequence>
         <xs:attribute name="id" type="xs:ID"/>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
      <xs:attribute name="id" type="xs:ID"/>
     </xs:complexType>
    </xs:element>
    <xs:element name="mergeMap">
     <xs:complexType>
      <xs:group ref="xtm:addressableResource.grp" minOccurs="0"
maxOccurs="unbounded"/>
      <xs:attribute name="id" type="xs:ID"/>
     </xs:complexType>
    </xs:element>
   </xs:choice>
   <xs:attribute name="id" type="xs:ID"/>
   <!--xs:attribute ref="xml:base" type="xs:string"/-->
  </xs:complexType>
 </xs:element>
 <xs:group name="addressableResource.grp">
  <xs:choice>
   <xs:element name="topicRef" type="xtm:XLinkType"/>
   <xs:element name="resourceRef" type="xtm:XLinkType"/>
   <xs:element name="subjectIndicatorRef" type="xtm:XLinkType"/>
  </xs:choice>
 </xs:group>
 <xs:group name="addressableSubject.grp">
  <xs:choice>
   <xs:element name="topicRef" type="xtm:XLinkType"/>
   <xs:element name="subjectIndicatorRef" type="xtm:XLinkType"/>
  </xs:choice>
 </xs:group>
 <xs:group name="resource.grp">
  <xs:choice>
   <xs:element name="resourceRef" type="xtm:XLinkType"/>
   <xs:element name="resourceData">
    <xs:complexType>
     <xs:simpleContent>
      <xs:extension base="xs:string">
       <xs:attribute name="id" type="xs:ID"/>
      </xs:extension>
     </xs:simpleContent>
    </xs:complexType>
   </xs:element>
  </xs:choice>
 </xs:group>
 <xs:complexType name="instanceOfType">
  <xs:group ref="xtm:addressableSubject.grp"/>
  <xs:attribute name="id" type="xs:ID"/>
 </xs:complexType>
 <xs:complexType name="scopeType">
  <xs:group ref="xtm:addressableResource.grp" maxOccurs="unbounded"/>
  <xs:attribute name="id" type="xs:ID"/>
 </xs:complexType>
 <xs:complexType name="variantType">
  <xs:sequence>
   <xs:element name="parameters">
    <xs:complexType>
     <xs:group ref="xtm:addressableSubject.grp" maxOccurs="unbounded"/>
     <xs:attribute name="id" type="xs:ID"/>
    </xs:complexType>
   </xs:element>
   <xs:element name="variantName" minOccurs="0">
    <xs:complexType>
     <xs:group ref="xtm:resource.grp"/>
     <xs:attribute name="id" type="xs:ID"/>
    </xs:complexType>
   </xs:element>
   <xs:element name="variant" type="xtm:variantType" minOccurs="0"
maxOccurs="unbounded"/>
  </xs:sequence>
  <xs:attribute name="id" type="xs:ID"/>
 </xs:complexType>
 <xs:complexType name="XLinkType">
  <xs:attribute name="id" type="xs:ID"/>
  <xs:attribute ref="xlink:href"/>
  <xs:attribute ref="xlink:type"/>
 </xs:complexType>
</xs:schema>





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC