使用Eclipse/ADT根据XSD验证XML时出现问题-否“;“验证”;上下文菜单项
我试图让Eclipse根据我创建的模式验证我创建的XML文件,但它不起作用,上下文菜单中没有“验证”条目 我将Eclipse3.6.2与ADT10.0.1一起使用,在帮助->关于->安装详细信息,插件选项卡中,我有EclipseXML编辑器和工具版本1.1.103 根据我在Eclipse网站和其他问题上的发现,我应该能够右键单击XML文件并单击“验证”。我的上下文菜单没有“验证”条目,我找到的所有内容都假定它在那里。我进入了Eclipse首选项->XML->XML文件->验证,并勾选了“启用标记验证”,但这并没有改变任何东西 另外,将noNamespaceSchemaLocation值更改为不正确的值不会在保存XML文件时给我任何错误。我不知道我错过了什么 其想法是在Eclipse中的properties窗格中显示元素“name”属性的下拉列表,显示有效值,我希望在根据XSD进行验证后会出现这种情况 类似问题 就像我一样,即使答案被接受,也找不到解决方案。评论中提到了已安装的Web工具平台 我已经做了公认答案中提到的事情 文件夹 它们可能很糟糕,我以前没有做过很多XML使用Eclipse/ADT根据XSD验证XML时出现问题-否“;“验证”;上下文菜单项,xml,eclipse,validation,Xml,Eclipse,Validation,我试图让Eclipse根据我创建的模式验证我创建的XML文件,但它不起作用,上下文菜单中没有“验证”条目 我将Eclipse3.6.2与ADT10.0.1一起使用,在帮助->关于->安装详细信息,插件选项卡中,我有EclipseXML编辑器和工具版本1.1.103 根据我在Eclipse网站和其他问题上的发现,我应该能够右键单击XML文件并单击“验证”。我的上下文菜单没有“验证”条目,我找到的所有内容都假定它在那里。我进入了Eclipse首选项->XML->XML文件->验证,并勾选了“启用标记
res/xml/magicks.xml
:
<?xml version="1.0" encoding="utf-8"?>
<magicks xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="magicksschema.xsd">
<magick name="Haste" description="Increases the wizard's movement speed by up to double for 10 seconds.">
<combination>
<element name="Lightning"/>
<element name="Arcane" />
<element name="Fire" />
</combination>
</magick>
</magicks>
编辑
- 已将架构更新为@Per norman的版本
感谢您修复我的架构!我看到的示例只声明了一个属性,我注意到序列用于多个元素,所以我编造了一段:)但是我仍然无法在Eclipse中验证,它实际上给了我一个新模式的解析错误(在最后一行:“找不到元素”)。我在编写原始模式时也出现了奇怪的解析错误。也许我的Eclipse安装坏了?
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="magicks">
<xs:complexType>
<xs:sequence>
<xs:element name="magick" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="combination">
<xs:complexType>
<xs:sequence>
<xs:element name="element" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Water" />
<xs:enumeration value="Life" />
<xs:enumeration value="Shield" />
<xs:enumeration value="Cold" />
<xs:enumeration value="Lightning" />
<xs:enumeration value="Arcane" />
<xs:enumeration value="Earth" />
<xs:enumeration value="Fire" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="description" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="magicks">
<xs:complexType>
<xs:sequence>
<xs:element name="magick" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="combination">
<xs:complexType>
<xs:sequence>
<xs:element name="element" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Water" />
<xs:enumeration value="Life" />
<xs:enumeration value="Shield" />
<xs:enumeration value="Cold" />
<xs:enumeration value="Lightning" />
<xs:enumeration value="Arcane" />
<xs:enumeration value="Earth" />
<xs:enumeration value="Fire" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="description" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>