cvc-elt.1:找不到元素'data'的声明 [英] cvc-elt.1: Cannot find the declaration of element 'data'
本文介绍了cvc-elt.1:找不到元素'data'的声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这些是我的简单XSD和XML文件,对于数据"节点,我一直在获取cvc-elt.1.
These are my simple XSD and XML files, I keep getting cvc-elt.1 for the "data" node.
这是XML
<?xml version="1.0" encoding="UTF-8" ?>
<data xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.w3schools.com/xml {FULL_PATH}/car_designer.xsd">
<car_designer id="1" designer_name="A C Bertelli"/>
<car_designer id="2" designer_name="Adam Ty Dean Smith"/>
</data>
这是XSD
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.w3schools.com"
xmlns="https://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="data">
<xs:complexType>
<xs:sequence>
<xs:element name="car_designer" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:int"></xs:attribute>
<xs:attribute name="designer_name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
推荐答案
问题是XML文件中的默认名称空间是 http://www.w3schools.com
,但是目标名称空间在架构为 https://www.w3schools.com
.
The problem is that the default namespace in the XML file is http://www.w3schools.com
, but the targetNamespace in the schema is https://www.w3schools.com
.
请注意uri中 http
和 https
之间的区别.如果将XML中的命名空间更改为https( xmlns ="https://www.w3schools.com"
),则该命名空间应该可以使用.
Notice the difference between http
and https
in the uri. If you change the namespace in the XML to https (xmlns="https://www.w3schools.com"
), it should work.
这篇关于cvc-elt.1:找不到元素'data'的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文