[英]How can I create an XSD for the following XML code?
我正在嘗試為以下 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">
不可否認,這不是我最閃亮的時刻。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.