[英]Can anyone tell me why I am having error in validating my xml against my xsd?
Can anyone tell me why I am having error in validating my xml against my xsd? 谁能告诉我为什么我在针对xsd验证xml时出错? This is my xml:
这是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<Person xsi:noNamespaceSchemaLocation=person.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Lecturer>
<Name>John</Name>
<Surname>Smith</Surname>
</Lecturer>
</Person>
This is my xsd: 这是我的xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Person">
<xs:complexType>
<xs:sequence>
<xs:element name="Lecturer">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Surname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The only thing preventing your XML from being valid against your XSD is the omission of a quote around the xsi:noNamespaceSchemaLocation=person.xsd"
attribute value. 唯一使XML对XSD无效的原因是省略了
xsi:noNamespaceSchemaLocation=person.xsd"
属性值周围的引号。
Here is your corrected XML: 这是您更正的XML:
<?xml version="1.0" encoding="utf-8"?>
<Person xsi:noNamespaceSchemaLocation="person.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Lecturer>
<Name>John</Name>
<Surname>Smith</Surname>
</Lecturer>
</Person>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.