【发布时间】:2019-04-23 12:24:22
【问题描述】:
由于客户的要求,我需要生成一个新的 XSD 模式来验证向 DITA 主题文档添加一些信息的 XML 文档。或多或少的想法是有以下几点:
<?xml version="1.0" encoding="UTF-8"?>
<customdocument>
<custommetadata>
...
</custommetadata>
<topic>
<!-- Here it comes a complete valid DITA topic -->
</topic>
</customdocument>
我对 XSD 的建议如下:
<?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>
custommetadata 元素来自已定义的 XSD (MetaInfo.xsd)。另一方面,topic 元素来自\dita-v1.3-os\part3-all-inclusive\all-inclusive-grammars\schema-url\base\xsd\basetopic.xsd(我认为它是用于 DITA 主题验证的根 XSD)。
我尝试验证一些文档,包括简单的 DITA 主题,并且效果很好。但是,对于更复杂的 DITA 主题,包括 <uicontrol> 元素,验证会失败。
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
所以问题是,引用的 XSD 是否是验证 DITA 主题的正确入口点? DITA 规范 1.3 包括大约 153 个 XSD 文件。
我们将不胜感激。
【问题讨论】: