如何在基于Docbook标签的XSD中包含MathML标签?

问题描述:

我正在研究基于子集Docbook 5标记的XSD。下面是这个XSD只为说明问题解的几个标签的非常小的一部分:如何在基于Docbook标签的XSD中包含MathML标签?

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" targetNamespace="http://docbook.org/ns/docbook" elementFormDefault="qualified" attributeFormDefault="unqualified"> 
<xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink.xsd"/> 
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/> 
<xs:element name="book"> 
    <xs:annotation> 
     <xs:documentation>Root element</xs:documentation> 
    </xs:annotation> 
    <xs:complexType> 
     <xs:sequence> 
      <xs:element ref="chapter" maxOccurs="unbounded"/> 
     </xs:sequence> 
     <xs:attribute ref="xml:lang" use="required"/> 
    </xs:complexType> 
</xs:element> 
<xs:element name="chapter"> 
    <xs:complexType> 
     <xs:sequence> 
      <xs:element ref="informalequation" maxOccurs="unbounded"/> 
     </xs:sequence> 
     <xs:attribute ref="xml:lang" use="required"/> 
     <xs:attribute ref="xml:id" use="required"/> 
    </xs:complexType> 
</xs:element> 
<xs:element name="informalequation"> 
    <xs:complexType> 
     <xs:attribute ref="xml:id"/> 
     <xs:attribute name="condition" use="required"> 
      <xs:simpleType> 
       <xs:restriction base="xs:string"> 
        <xs:enumeration value="block"/> 
        <xs:enumeration value="inline"/> 
       </xs:restriction> 
      </xs:simpleType> 
     </xs:attribute> 
    </xs:complexType> 
</xs:element> 

眼下,元<informalequation>没有内容,只有属性。我想要做的就是把它里面的MATHML格式,如公式:

<math display='block'> 
<mrow> 
    <msqrt> 
    <mn>2</mn> 
    </msqrt> 
</mrow> 
</math> 

而且这里的问题是...我不知道该怎么做,因为MATHML标签中不包含的Docbook ...我使用Altova XMLSpy 2011企业版创建我的XSD。我已经从http://www.w3.org/Math/XMLSchema/下载了MathML 3 XSD,但我不知道下一步该怎么做。有谁知道如何做到这一点,并得到一个有效的XSD这样我就可以创建基于其与此结构的XML?:

<?xml version="1.0" encoding="UTF-8"?> 
<book xml:lang="en" version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> 
<chapter xml:lang="en" xml:id="1"> 
    <informalequation condition="block"> 
     <math display='block'> 
      <mrow> 
       <msqrt> 
        <mn>2</mn> 
       </msqrt> 
      </mrow> 
     </math> 
    </informalequation> 
</chapter> 

我感谢所有帮助。

谢谢!

首先你要算算是在MATHML命名空间,这样

<math display='block' xmlns="http://www.w3.org/1998/Math/MathML"> 

那么我想你可以通过

 <xs:sequence> 
     <xs:element ref="mml:math" xmlns:mml="http://www.w3.org/1998/Math/MathML"/> 
    </xs:sequence> 

取代<xs:simpleType>,在你验证了MATHML名[王牌安排与MathML模式相关联。

(但我从不使用XSD,我个人只会在RelaxNG中编写并翻译:-)