下面是我的 XSD。我收到错误。您能验证一下吗?
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://api.vvz.com/"
xmlns:vz="http://api.vvz.com/"
targetNamespace="http://api.vvz.com/">
<vz:element name="Account">
<annotation>
<documentation>
A sample element
</documentation>
</annotation>
<simpleType name="ID">
<restriction base="xs:string">
<pattern value='[a-zA-Z0-9]'/>
</restriction>
</simpleType>
<complexType>
<complexContent>
<sequence>
<element minOccurs="0" maxOccurs="unbounded" name="fieldsToNull"
nillable="true" type="string"/>
<element minOccurs="0" maxOccurs="1" name="Id" nillable="true"
type="vz:ID"/>
</sequence>
</complexContent>
</complexType>
</vz:element>
</xsd:schema>
错误是
The namespace of element schema must be from schema namespace 'http://www.w3.org/2001/XMLSchema'
请帮帮我。
最佳答案
有关目标命名空间的直接错误是由于在 xsd:schema
上声明 xmlns="http://api.vvz.com/"
造成的。删除它。您不希望 XSD 本身位于该命名空间中;您希望在该命名空间中使用受管理的 XML,这已经通过 targetNamespace="http://api.vvz.com/"
实现了。
您的 XSD 的其余部分有许多错误且目标不明确。这是一组使其有效的一致修复:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:vz="http://api.vvz.com/"
targetNamespace="http://api.vvz.com/">
<xsd:element name="Account" type="vz:AccountType">
<xsd:annotation>
<xsd:documentation>
A sample element
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="AccountType">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="fieldsToNull"
nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Id" nillable="true"
type="vz:IdType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="IdType">
<xsd:restriction base="xsd:string">
<xsd:pattern value='[a-zA-Z0-9]'/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
关于xml - 错误 : The namespace of element schema must be from schema namespace http://www. w3.org/2001/XMLSchema,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38641268/