XML架构名称空间
问题描述:
XML新手但无法弄清楚我在这里做错了什么。方向说:使用俄罗斯娃娃设计创建一个名为menu.xsd的模式,为该模式指定目标名称空间并保存更改。在menu.xml中,指定模式文件的位置并保存更改。验证。XML架构名称空间
文档未验证。收到错误:
"Validation of current file using XML schema:
ERROR: Element '{ http://example.com/chestershartland/menu }itemName': This >element is not expected. Expected is (itemName).
我的XML文件:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<menuItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://example.com/chestershartland/menu"
xsi:schemaLocation="http://example.com/chestershartland/menu menu.xsd">
<itemName>Oatmeal Breakfast</itemName>
<description>
<![CDATA[Our oatmeal is served warm with fresh fruit, pecans, raisins,
and 100% maple syrup. Available all day.
]]>
</description>
<price>6.95</price>
<icon>♠</icon>
<icon>♥</icon>
</menuItem>
我menu.xsd文件
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://example.com/chestershartland/menu"
targetNamespace="http://example.com/chestershartland/menu">
<xs:element name="menuItem">
<xs:complexType>
<xs:sequence>
<xs:element name="itemName" type="xs:string" />
<xs:element name="description" type="xs:string" />
<xs:element name="price" type="xs:string" />
<xs:element name="icon" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
提前感谢您的帮助!这似乎与名称空间有关,但我只是没有得到它。
答
主要是将elementFormDefault = “合格”