Search code examples
xmlxsddita

XSD to add new elements on top of DITA topic. Which DITA XSD do I have to reference?


due to customer requirements, I would need to generate a new XSD schema to validate XML documents that add some information to DITA topic documents. More or less the idea is to have the following:

<?xml version="1.0" encoding="UTF-8"?>
<customdocument>
  <custommetadata>
  ...
  </custommetadata>
  <topic>
   <!-- Here it comes a complete valid DITA topic -->
  </topic>
</customdocument>

My proposal for the XSD is the following:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://myNamespace"
    targetNamespace="http://myNamespace"
    elementFormDefault="qualified">
    <xs:include schemaLocation="MetaInfo.xsd"></xs:include>
    <xs:include schemaLocation=".\dita-v1.3-os\part3-all-inclusive\all-inclusive-grammars\schema-url\base\xsd\basetopic.xsd"></xs:include>
    <xs:element name="customerdocument" type="customerdocumentType"></xs:element>
    <xs:complexType name="customerdocumentType">
        <xs:sequence>
            <xs:element ref="custommetadata" minOccurs="1"></xs:element>
            <xs:element ref="topic" minOccurs="1"></xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

The custommetadata element is coming from an already defined XSD (MetaInfo.xsd). On the other side the topic element comes from the \dita-v1.3-os\part3-all-inclusive\all-inclusive-grammars\schema-url\base\xsd\basetopic.xsd (which I thought was the root XSD for DITA topic validation).

I've tried to validate some documents including simple DITA topics and it works fine. However, for more complex DITA topics including <uicontrol> elements, the validation fails.

Engine name: Xerces
Severity: error
Description: cvc-complex-type.2.4.a: Invalid content was found starting with element 'uicontrol'. One of '{dl, div, fig, imagemap, image, lines, lq, note, hazardstatement, object, ol, pre, simpletable, sl, table, ul, boolean, cite, keyword, ph, b, i, line-through, overline, sup, sub, tt, u, q, term, text, tm, xref, state, data, sort-as, data-about, foreign, unknown, draft-comment, fn, indextermref, indexterm, required-cleanup}' is expected.
Start location: 12:22
End location: 12:31
URL: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type

So the question is, is the referenced XSD the correct entry point for validating DITA topics? The DITA specification 1.3 includes around 153 XSD files.

Some help would be really appreciated.


Solution

  • You should try to use the open in "schema\technicalContent\xsd\topic.xsd".