[英]XSD and XML - Cannot find the declaration of element
Probably this has been asked many times.But I went through all the posts but could not clear my error as I have no knowledge about XML and XSD. 可能已经问过很多次了。但是我浏览了所有帖子,但是由于我不了解XML和XSD,所以无法清除我的错误。 Can somebody please find out the error?
有人可以找出错误吗?
XML XML格式
<?xml version="1.0" encoding="UTF-8"?>
<HTMLQuestion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com ./HTMLQuestion1.xsd" xmlns="urn:Test.Namespace" >
<HTMLContent>
<html>
abcd
</html>
</HTMLContent>
<FrameHeight>450</FrameHeight>
</HTMLQuestion>
This is the schema HTMLQuestion1.xsd 这是架构HTMLQuestion1.xsd
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:Test.Namespace" xmlns="urn:Test.Namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="HTMLQuestion">
<xs:complexType>
<xs:sequence>
<xs:element name="HTMLContent">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="html"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element type="xs:short" name="FrameHeight"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The error I get is 我得到的错误是
cvc-elt.1.a : Cannot find the declaration of element 'HTMLQuestion'
I think this will solve your problem. 我认为这可以解决您的问题。
I have created the XML schema file as mentioned bu you : 我已经创建了XML模式文件,正如您所提到的:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:Test.Namespace" xmlns="urn:Test.Namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="HTMLQuestion">
<xs:complexType>
<xs:sequence>
<xs:element name="HTMLContent">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="html"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element type="xs:short" name="FrameHeight"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Now i created xml based on the above XSD, as mentioned here. 现在,我在上面提到的XSD的基础上创建了xml。
<?xml version="1.0" encoding="UTF-8"?>
<HTMLQuestion xmlns="urn:Test.Namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:Test.Namespace HTMLQuestion1.xsd ">
<HTMLContent>
<html>p:html</html>
</HTMLContent>
<FrameHeight>0</FrameHeight>
</HTMLQuestion>
This does not show any error. 这不会显示任何错误。 You can proceed with this.
您可以继续进行。
You have supplied the process with the location of the schema for namespace http://www.w3schools.com
, but you do not have any elements in this namespace. 您已为过程提供了名称空间
http://www.w3schools.com
的架构位置,但是此名称空间中没有任何元素。 You need to use the xsl:noNamespaceSchemaLocation attribute to supply the location of a schema for no-namespace elements. 您需要使用xsl:noNamespaceSchemaLocation属性为无命名空间元素提供架构的位置。
If you are hoping to learn all you need to know about XSD from the w3schools site, then think again. 如果您希望从w3schools网站学习有关XSD的所有知识,请再考虑一下。 It can be very handy as a quick reference (like those one-page quick reference cards to remind you of command syntax or keystroke combinations) but it's no way to acquire the concepts.
作为快速参考,它可能非常方便(就像那些一页的快速参考卡可以提醒您命令语法或击键组合一样),但无法掌握这些概念。 Get yourself a decent book, for example Walmsley or van der Vlist.
给自己买一本像样的书,例如Walmsley或van der Vlist。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.