2014-03-05 38 views
1

我正在尝试读取具有对xsd doc.properties的XML文档,但是当我这样做时,我最终得到“文档类型声明中包含或指向的标记声明必须清晰,形成“错误。不知道错误是什么。提前感谢。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> 

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> 

回答

2
<!DOCTYPE XML SYSTEM "NGPSCustomerConfig.xsd"> 

说两件事情:

  1. 下面的XML文档的根元素将被命名为XML
  2. 文件NGPSCustomerConfig.xsd是a DTD为文件。

这些都不在你的情况是真实的 - NGPSCustomerConfig.xsd是一种架构,而不是DTD所以xsi:noNamespaceSchemaLocation就足够了,你不需要DOCTYPE在所有。