嗨,我正在做一个将 xlm 传递给 xsd 的练习。xsd 验证正确,它只在属性中给出错误,我不知道为什么它是错误的。而且我的笔记很差。这是错误
Referenced entity at "nbres:/org/netbeans/modules/xml/catalog/resources/datatypes.dtd".
cvc-complex-type.2.4.a: Se ha encontrado contenido no válido a partir del elemento 'atribute'. Se esperaba uno de '{"http://www.w3.org/2001/XMLSchema":simpleType, "http://www.w3.org/2001/XMLSchema":complexType, "http://www.w3.org/2001/XMLSchema":group, "http://www.w3.org/2001/XMLSchema":attributeGroup, "http://www.w3.org/2001/XMLSchema":element, "http://www.w3.org/2001/XMLSchema":attribute, "http://www.w3.org/2001/XMLSchema":notation, "http://www.w3.org/2001/XMLSchema":annotation}'. [31]
cvc-complex-type.4: El atributo 'name' debe aparecer en el elemento 'xs:simpleType'. [32]
XML validation finished.
这是xsd
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="alumno">
<xs:complexType>
<xs:sequence>
<xs:element name="nombre" type="xs:string"/>
<xs:element name="direccion" type="tdireccion" minOccurs="1" maxOccurs="2"/>
<xs:element name="telefono" type="xs:integer" minOccurs="0" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="tdireccion">
<xs:sequence>
<xs:element name="calle" type="xs:string"/>
<xs:element name="numero" type="infonumero"/>
<xs:element name="ciudad" type="xs:string"/>
<xs:element name="provincia" type="infoprovincia"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="infonumero">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="500"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="infoprovincia">
<xs:restriction base="xs:string">
<xs:pattern value="caceres|badajoz"/>
</xs:restriction>
</xs:simpleType>
<atribute name="dni">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{8}[A-Z]" />
</xs:restriction>
</xs:simpleType>
</atribute>
</xs:schema>
看看能不能告诉我错误的原因,空间问题我不放xlm,因为它会告诉我代码太多。
!好的!
在没有XML的情况下,我尝试查看您拥有的XSD ,并且发现了一些错误。
第一的
第二
您的代码如下所示:
现在试试XSD并告诉我。