[英]How to include MathML tags in an XSD based on Docbook tags?
I'm working on an XSD that is based on a subset of Docbook 5 tags. 我正在研究基于Docbook 5标签子集的XSD。 Here is a very small part of this XSD with a few tags just for illustrate de problem: 这是此XSD的很小部分,仅带有一些标记,用于说明问题:
<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>
Right now, element <informalequation>
has no content, only attributes. 现在,元素<informalequation>
没有内容,只有属性。 What I would like to do is put inside it an equation in MathML format such as: 我想做的是在其中放入MathML格式的方程式,例如:
<math display='block'>
<mrow>
<msqrt>
<mn>2</mn>
</msqrt>
</mrow>
</math>
And here is the problem... I don't know how to do that because MathML tags are not included in Docbook... I'm using Altova XMLSpy 2011 Enterprise Edition to create my XSD. 这就是问题所在...我不知道该怎么做,因为Docbook中不包含MathML标记...我正在使用Altova XMLSpy 2011 Enterprise Edition创建我的XSD。 I've downloaded MathML 3 XSD from http://www.w3.org/Math/XMLSchema/ but I don't know what to do next. 我已经从http://www.w3.org/Math/XMLSchema/下载了MathML 3 XSD,但我不知道下一步该怎么做。 Does anyone know how to do it and get a valid XSD so I can create an XML based on it with this structure?: 有谁知道该怎么做并获得有效的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>
I'll appreciate any help. 我将不胜感激。
Thanks! 谢谢!
Firstly you want the math to be in the mathml namespace so 首先,您希望数学位于mathml命名空间中,因此
<math display='block' xmlns="http://www.w3.org/1998/Math/MathML">
Then I think you can just replace <xs:simpleType>
by 然后我认为您可以将<xs:simpleType>
替换为
<xs:sequence>
<xs:element ref="mml:math" xmlns:mml="http://www.w3.org/1998/Math/MathML"/>
</xs:sequence>
and arrange in your validator that the mathml names[ace is associated to the MathML schema. 并在您的验证器中安排mathml名称[ace与MathML模式相关联。
(But I never use XSD, personally I'd just write in RelaxNG and translate:-) (但我从不使用XSD,我个人只是用RelaxNG编写并翻译:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.