扩展GraphML模式

时间:2018-10-25 11:02:47

标签: xml xsd

GraphML Primer描述了如何扩展GraphML模式,以便data元素支持SVG元素。根据本教程,我尝试通过一个复杂类型扩展模式,该类型可以在文件OwnTypes.xsd中找到,内容如下:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="/foo/bar">
    <xs:complexType name="MyComplexType">
        <xs:sequence>
            <xs:element name="MyElement" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>

文件GraphMLExtension.xsd取自链接的教程并进行了修改,以使data元素支持上面显示的我的复杂类型MyComplexType

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
   targetNamespace="http://graphml.graphdrawing.org/xmlns"
   xmlns="http://graphml.graphdrawing.org/xmlns"  
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:own="/foo/bar"
   elementFormDefault="qualified"
   attributeFormDefault="unqualified"
>

    <xs:import schemaLocation="OwnTypes.xsd" namespace="/foo/bar" />

    <xs:redefine 
    schemaLocation="http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
        <xs:complexType name="data-extension.type">
            <xs:complexContent>
                <xs:extension base="data-extension.type">
                    <xs:sequence>
                        <xs:element ref="own:MyComplexType"/>
                    </xs:sequence>
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:redefine>

</xs:schema>

我正在使用Liquid Studio 2018作为XML编辑器,它显示文件GraphMLExtension.xsd的以下错误:

C:\GraphMLExtension.xsd (20:25) Error
The <element> [MyComplexType], is of Type [/foo/bar:MyComplexType]. However [/foo/bar:MyComplexType] is not defined as a root item (either a <complexType>, <simpleType> or <element>), within this schema or any included or imported schemas.

错误消息指出MyComplexType

  

未定义为根项目(complexType,simpleType或   元素)

但是正如上面可以看到的,它肯定是一个complexType。我在做什么错了?

0 个答案:

没有答案