我的 XSD 出现问题,当我将代码输入 XSD 验证器时出现此错误:“no-xmlns:属性声明的 {name} 不得匹配 'xmlns'。”
这是我的 XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Test">
<xs:complexType>
<xs:attribute name="xmlns" type="xs:string" use="required"/>
<xs:sequence>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="Screens" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Screen" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="package" type="xs:string" use="required"/>
<xs:attribute name="class" type="xs:string" use="required"/>
<xs:sequence>
<xs:element name="ScreenData" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="step" type="xs:int" use="required"/>
<xs:attribute name="description" type="xs:string" use="required"/>
<xs:sequence>
<xs:element name="element" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="DBSession" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="use_test.properties" type="xs:boolean" use="required"/>
<xs:attribute name="use_dbserver" type="xs:string" use="required"/>
<xs:attribute name="use_db" type="xs:string" use="required"/>
<xs:sequence>
<xs:element name="login" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="server" type="xs:string" use="required"/>
<xs:attribute name="database" type="xs:string" use="required"/>
<xs:attribute name="username" type="xs:string" use="required"/>
<xs:attribute name="password" type="xs:string" use="required"/>
<xs:sequence>
<xs:element name="Queries" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:attribute name="query" type="xs:string" use="required"/>
<xs:attribute name="expectedResults" type="xs:string" use="required"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CLISession" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="use_test.properties" type="xs:boolean" use="required"/>
<xs:sequence>
<xs:element name="login" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="host" type="xs:string" use="required"/>
<xs:attribute name="password" type="xs:string" use="required"/>
<xs:attribute name="username" type="xs:string" use="required"/>
<xs:sequence>
<xs:element name="Commands" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="Command" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="exe" type="xs:string" use="required"/>
<xs:attribute name="args" type="xs:string" use="required"/>
<xs:attribute name="wait" type="xs:int" use="required"/>
<xs:attribute name="expectedOutput" type="xs:string" use="required"/>
<xs:attribute name="toVariable" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我假设这与模式中的第二行代码有关。此行与我的 XML 文档中的以下行相关:
<Test xmlns="http://MyURL">