XML新手,但无法弄清楚我在这里做错了什么。方向说:使用Russian Doll设计创建名为menu.xsd的模式,指定模式的目标名称空间并保存更改。在menu.xml中,指定模式文件的位置并保存更改。验证
文档未验证。得到错误:
“使用XML架构验证当前文件:
错误:元素'{http://example.com/chestershartland/menu} itemName':不需要此>元素。预期是(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>
提前感谢您的帮助!它似乎与命名空间有关,但我只是没有得到它。
答案 0 :(得分:0)
Key是elementFormDefault =“qualified”