【发布时间】:2011-02-19 03:45:52
【问题描述】:
我在 xml 架构方面有点新手。如果有人帮助我理解为什么我的 xml 没有通过架构验证,我将不胜感激:
这是我的架构:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/testSchema" xmlns="http://www.example.org/testSchema">
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element name="Name">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" />
<xs:element name="LastName" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
这是我的测试 xml:
<?xml version="1.0" encoding="UTF-8"?>
<Employee xmlns="http://www.example.org/testSchema">
<Name>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
</Name>
</Employee>
Eclipse xml 编辑器/验证器出现以下错误:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'Name'. One of '{Name}' is expected.
我不明白这个架构或我的 xml 有什么问题。
【问题讨论】:
-
您能发布您尝试验证的架构吗?
-
架构现在在原始帖子中可见。很抱歉使用“答案”而不是编辑
标签: schema xsd xsd-validation