DITA 1.2 + XML Schemaの幻想(2)

「ああなんと簡単か!」と思ったのですが感激したのはそこまででした、と考えたのは次のような理由です.

たまたまあとになってやめましたが、image/@placement="inline|block"に対して、"flost-left|float-right"を加えようと考えました.しかしそれはできないのです.xs:refdefineで属性+値を追加定義することは非常に簡単でも、既存の属性に値を追加したり、値を制限するなどの再定義はできません.

例えばimageの属性は

<xs:attributeGroup name="image.attributes">
<xs:attribute name="href" type="xs:string"/>
<xs:attribute name="keyref" type="xs:string"/>
<xs:attribute name="alt" type="xs:string"/>
<xs:attribute name="longdescref" type="xs:string"/>
<xs:attribute name="height" type="xs:NMTOKEN"/>
<xs:attribute name="width" type="xs:NMTOKEN"/>
<xs:attribute name="scale" type="xs:NMTOKEN"/>
<xs:attribute name="scalefit" type="yesno-att.class"/>
<xs:attribute name="scope" type="scope-att.class"/>
<xs:attribute name="align" type="xs:string"/>
<xs:attribute name="placement" type="image-placement-att.class" default="inline"/>
<xs:attribute name="outputclass" type="xs:string"/>
<xs:attributeGroup ref="univ-atts"/>
<xs:attributeGroup ref="global-atts"/>
</xs:attributeGroup>
<xs:simpleType name="image-placement-att.class">
<xs:restriction base="xs:string">
<xs:enumeration value="inline"/>
<xs:enumeration value="break"/>
<xs:enumeration value="-dita-use-conref-target"/>
</xs:restriction>
</xs:simpleType>

OASIS XSDで定義されていますが、image-placement-att.classに"float-left|float-right"は加えられないのです.

また、xs:redefineでは既存のコンテンツモデルの前後に要素を定義することはできますが、元のコンテンツモデル自身の中の定義を変えることはできません.例えばfiggroupのtitleの後にdescを加えようとします.

[元のfiggroupの定義]

<xs:group name="figgroup.content">
<xs:sequence>
<xs:sequence>
<xs:group ref="title" minOccurs="0"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="figgroup"/>
<xs:group ref="basic.ph"/>
<xs:group ref="basic.block.notbnofg"/>
<xs:group ref="fn"/>
<xs:group ref="data.elements.incl"/>
<xs:group ref="foreign.unknown.incl"/>
</xs:choice>
</xs:sequence>
</xs:sequence>
</xs:group>

[再定義:これはエラーになる]
<xs:redefine schemaLocation="urn:oasis:names:tc:dita:xsd:commonElementMod.xsd:1.2">
<xs:group name="figgroup.content">
<xs:sequence>
<xs:sequence>
<xs:group ref="title" minOccurs="0"/>
<xs:group ref="desc" minOccurs="0"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="figgroup"/>
<xs:group ref="basic.ph"/>
<xs:group ref="basic.block.notbnofg"/>
<xs:group ref="fn"/>
<xs:group ref="data.elements.incl"/>
<xs:group ref="foreign.unknown.incl"/>
</xs:choice>
</xs:sequence>
</xs:sequence>
</xs:group>
</xs:redefine>

という訳で、XML Schema 1.0のxs:redefineでは極めて出来ることは限られてしまいます.もしそれでもやろうとするならば、xs:redefineをやめて、元のOASISスキーマをデッドコピーを取り、自分の必要な箇所に修正を加えなければなりません.これはさすがに気が引けます.

しかしこれはあくまでXML Schame 1.0のxs:redefineを使っているからなのです.XML Schemaは1.1がすでにW3C勧告となっており、そこではxs:redefineはobsoleteという扱いになり、overrideに取って代わられています.

Priscilla Warmsley著 DEFINITIVE XML SCHEME p.447

"There are two methods of including a schema document into a schema modifying or overriding certain parts of it: redefine and override. Redefinition - a varsion 1.0 feature - allows you  to extend or restrict certain components (namely types and groups), replacing the original definitions, but only in certain constraint ways. Because of the limitations of redefinition and its inconsisitent implementation among processors, redefinition was deprecated in version 1.1 and replaced with a new override feature which is more flexible and better defined."

ではということで、xs:overrideを使用して書き直してみると(私がやったかぎりですが)oXygenでXML Schemaの検証レベルを1.0から1.1に上げると、私の特殊化部分でなく、OASISスキーマ部分で山ほどエラーが出てきてしまい、手のつけようがなくなってしまうのです.

ということで、DITA 1.2 + XML Schema 1.0のxs:redefineでは正直展望がないのではないかと思います.

またDITA 1.3のスキーマはRENAX NGで作成され、DTDXML Schemaが自動生成されています.しかしこのXML Schemeでもxs:overrideでなく引き続きxs:redefineが使用されています.これはまだXML Schema 1.1のインプリメンテーションが限られていて、xs:overrideを使用するには至らないからなのでしょう.

2014年のBalisage The Markup ConferenceでEliot Kimberさんは次のように述べていますが、やはり無理だったのではないかと思います.XML Schema 1.2のインプリメンターがXercesとSaxonだけではやはり足りないのです.

RELAX NG and DITA: An Almost Perfect Match

"The XSD 1.1 override facility, which was driven in part by DITA requirements, appears to provide the override semantics DITA requires, but as XSD 1.1 is not universally implemented it is difficult to justify requiring the use of XSD 1.1. However, because the DITA XSDs are generated starting with DITA 1.3, it would be possible to generate XSDs that use override in place of redefine if the DITA community requires them. As of May 2014 it appears that the only XSD 1.1 implementations are Xerces-J and Saxon EE, which is not sufficient to support the full DITA community."

ということで、DITA 1.2 + XML Schema 1.0はソリューションには成り得ないのではないかと思います.