我正在尝试为具有多个名称空间的文档创建架构。事情是这样的:XML架构:可扩展容器元素
<?xml version="1.0"?>
<parent xmlns="http://myNamespace"
xmlns:c1="http://someone/elses/namespace"
xmlns:c2="http://yet/another/persons/namespace">
<c1:child name="Jack"/>
<c2:child name="Jill"/>
</parent>
这是我在我的模式至今:
<xs:element name="parent" type="Parent"/>
<xs:complexType name="Parent">
<!-- don't know what to put here -->
</xs:complexType>
<!-- The type that child elements must extend -->
<xs:complexType name="Child" abstract="true">
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
的计划是让其他人能够创建具有任意的子元素的文件,只要这些孩子元素扩展了我的Child
类型。我的问题是:如何限制<parent>
元素,使其只能包含类型为Child
类型的扩展的元素?
感谢链接。这篇文章似乎没有涉及我后来的事情:我可以做继承,我只是不知道如何限制'Parent'的内容,只允许其类型继承自'Child'的元素。 – Daniel