XSD 验证错误 - 在同一定义中引用了复杂类型

XSD Validation Error - Complex Type referenced in same Definition

我正在尝试写我的第一个 XSD 。 . . XSD如下,不验证

<xsd:schema elementFormDefault="qualified" 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">   
    <xsd:complexType name="Hdr">
        <xsd:sequence>
            <xsd:element name="ID" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>    
    <xsd:element name="Header" type="xsd:Hdr" />
</xsd:schema>

我正在使用 http://www.utilities-online.info/xsdvalidation/ 进行验证

我收到这个错误

Not valid.Error - Line 7, 49: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 49; src-resolve.4.2: Error resolving component 'xsd:Hdr'. It was detected that 'xsd:Hdr' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document 'null'. If this is the incorrect namespace, perhaps the prefix of 'xsd:Hdr' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'null'. Error - Line 7, 49: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 49; src-resolve: Cannot resolve the name 'xsd:Hdr' to a(n) 'type definition' component.

我无法弄清楚我的 XSD 有什么问题。有人可以指导一下吗

改变

  <xsd:element name="Header" type="xsd:Hdr" />

  <xsd:element name="Header" type="Hdr" />

如果定义了目标命名空间,您将使用其前缀来引用 Hdr,但您永远不会使用 http://www.w3.org/2001/XMLSchema 命名空间来进行此类引用。