XML标记声明错误

XML标记声明错误,xml,xsd,Xml,Xsd,我试图读取一个引用xsd文档的XML文档,但当我这样做时,我得到了“文档类型声明包含或指向的标记声明必须是格式正确的”错误。我不知道错在哪里。提前谢谢 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE XML SYSTEM "NGPSCustomerConfig.xsd"> <NGPSCustomerConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance

我试图读取一个引用xsd文档的XML文档,但当我这样做时,我得到了“文档类型声明包含或指向的标记声明必须是格式正确的”错误。我不知道错在哪里。提前谢谢

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE XML SYSTEM "NGPSCustomerConfig.xsd">
<NGPSCustomerConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="NGPSCustomerConfg.xsd">
    <CustomerInfo id="NGPS">
        <CustomerName>NGPS</CustomerName>
        <CustomerAdditionalInfo> Additional Info</CustomerAdditionalInfo>
        <ToolInfo>
            <toolName>Service Manager</toolName>
            <toolID>SM01</toolID>
            <toolType>ITSM</toolType>
            <toolProperty>001_SM01.Properties</toolProperty>
        </ToolInfo>
        <ToolInfo>
            <toolName>Orchestrator</toolName>
            <toolID>ORCH01</toolID>
            <toolType>ORCHESTRATOR</toolType>
            <toolProperty>001_ORCH01.properties</toolProperty>
        </ToolInfo>
        <ToolInfo>
            <toolName>Event Manager</toolName>
            <toolID>EM01</toolID>
            <toolType>EVENT MANAGER</toolType>
            <toolProperty>001_EM01.properties</toolProperty>
        </ToolInfo>
    </CustomerInfo>
</NGPSCustomerConfig>

NGPS
附加信息
服务经理
SM01
ITSM
001_SM01.1属性
编曲
ORCH01
编曲
001_ORCH01.properties
事件管理器
EM01
事件管理器
001_EM01.properties
XSD文件是

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="NGPSCustomerConfig">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="CustomerInfo">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element type="xs:string" name="CustomerName" />
                            <xs:element type="xs:string" name="CustomerAdditionalInfo">
                            </xs:element>
                            <xs:element name="ToolInfo" maxOccurs="unbounded"
                                minOccurs="0">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element type="xs:string" name="toolName" />
                                        <xs:element type="xs:string" name="toolID" />
                                        <xs:element type="xs:string" name="toolType" />
                                        <xs:element type="xs:string" name="toolProperty" />
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <xs:attribute type="xs:string" name="id" />
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>


说了两件事:

  • 以下XML文档的根元素将命名为
    XML
  • 文件
    NGPSCustomerConfig.xsd
    是文档的DTD
  • 这两种情况在您的情况下都不正确-
    NGPSCustomerConfig.xsd
    是一个模式,而不是DTD,因此
    xsi:noNamespaceSchemaLocation
    就足够了,您根本不需要DOCTYPE

    <!DOCTYPE XML SYSTEM "NGPSCustomerConfig.xsd">