cvc-elt.1.a:找不到元素"家族"的声明



我试图使用xsd验证一个非常简单的xml,但由于某种原因,我收到了这个错误。

cvc elt.1.a:找不到元素'family'的声明

此外,在元素"中存在问题;nome":

src resolve:无法将名称"nome"解析为(n("element declaration"组件。

如果有人能解释原因,我将不胜感激。

XML文件

<?xml version="1.0" encoding="UTF-8"?>
<familia xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.painatal.pt/familia"
xsi:schemaLocation="http://www.painatal.pt/familia familia.xsd">

<detalhesFamilia>
<nome>Familia</nome>
<pais>Portugal</pais>
<cidade>Porto</cidade>
<dataNascimento>2000-02-01</dataNascimento>
<numeroMembros>5</numeroMembros>
</detalhesFamilia>
<prefDias>
<numeroDias>5</numeroDias>
</prefDias>
</familia>

XSD文件

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="familia"
elementFormDefault="qualified">
<xs:element name="nome" type="xs:string"/>
<xs:element name="pais" type="xs:string"/>
<xs:element name="cidade" type="xs:string"/>
<xs:element name="dataNascimento" type="xs:date"/>
<xs:element name="numeroMembros" type="xs:integer"/>
<xs:element name="numeroDias" type="xs:integer"/>
<xs:element name="familia">
<xs:complexType>
<xs:sequence>
<xs:element ref="nome"/>
<xs:element ref="pais"/>
<xs:element ref="cidade"/>
<xs:element ref="dataNascimento"/>
<xs:element ref="numeroMembros" minOccurs="1" maxOccurs="7"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="prefDias">
<xs:complexType>
<xs:sequence>
<xs:element ref="numeroDias" minOccurs="1" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

模式中定义的目标命名空间("familya"(与实例中使用的实际命名空间(";http://www.painatal.pt/familia"(。

此外,在模式中,<xs:element ref="nome"/>是对具有本地名称nome的无名称空间元素的引用;您想要<xs:element ref="p:nome"/>,其中命名空间前缀p绑定到架构的(已更正的(目标命名空间。

最新更新