如何解决如何为以下 XML 代码创建 XSD?
我正在尝试为以下 XML 编写 XSD:
<?xml version="1.0" encoding="UTF-8"?>
<PersonList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="PersonList.xsd">
<Person>
<adhaarno>414356782345</adhaarno>
<name>
<firstname>Zeenath</firstname>
</name>
<age>28</age>
<address>
<doorno>33</doorno>
<street>Raidu Street</street>
<city>coimbatore</city>
<pincode>641039</pincode>
</address>
</Person>
<Person Category="seniorcitizen">
<adhaarno>414356782345</adhaarno>
<name>
<firstname>Simon</firstname>
</name>
<age>75</age>
<address>
<doorno>7</doorno>
<street>Raja Street</street>
<city>Chennai</city>
<pincode>600005</pincode>
</address>
</Person>
<Person>
<adhaarno>414356782345</adhaarno>
<name>
<lastname>Varma</lastname>
</name>
<age>25</age>
<address>
<doorno>25</doorno>
<street>cox street</street>
<city>Bangalore</city>
<pincode>560025</pincode>
</address>
</Person>
这是我目前的 XSD 代码:
<?xml version="1.0" encoding = "utf-8"?>
<schema xlmns = "http://www.w3.org/2001/XMLSchema">
<element name="PersonList">
<complexType>
<sequence>
<element name="Person" maxOccurs="unbounded">
<complexType>
<attribute name="Category" type="string"/>
<sequence>
<element name="adhaarno"/>
<element name="name">
<complexType>
<sequence>
<element name="firstname"/>
<element name="lastname"/>
</sequence>
</complexType>
</element>
<element name="age"/>
<element name="address">
<complexType>
<sequence>
<element name="doorno"/>
<element name="street"/>
<element name="city"/>
<element name="pincode"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
但是,我收到如下错误:
Exception: s4s-elt-schema-ns: The namespace of element 'schema' must be from the
schema namespace,'http://www.w3.org/2001/XMLSchema'.
我尝试添加然后删除前缀,但无济于事。据我所知,命名空间声明(?)是正确的。什么可能导致此错误?
注意:请原谅格式问题,因为我在添加 XML 时无法正确显示它。
解决方法
我找到了答案:我输入的是 xlmns 而不是 xmlns。
这行代码解决了:
<schema xmlns = "http://www.w3.org/2001/XMLSchema">
不可否认,这不是我最闪亮的时刻。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。