作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是后续问题:
How to set restriction on XSD for id attributes
我使用 Eclipse。我用答案代码创建了一个 XSD 文件,但我遇到了这 3 个错误:
error: Error: No resource type specified (at 'xpath' with value '@id'). fsm.xsd /test/res/xml line 24 Android AAPT Problem
error: Error: No resource type specified (at 'xpath' with value '@toState'). fsm.xsd /test/res/xml line 32 Android AAPT Problem
error: Error: No resource type specified (at 'xpath' with value '@fromState'). fsm.xsd /test/res/xml line 28 Android AAPT Problem
使用 xsd 的 XMLSchema 实例的 XML 测试文件验证正常,即使存在 3 个提到的错误。
我想知道这些错误是否只是 Eclipse 中的一个小故障,还是我需要定义其他东西来消除它们。
XSD 源代码:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="FSM">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="state">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedByte" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="transition">
<xs:complexType>
<xs:attribute name="fromState" type="xs:unsignedByte" use="required"/>
<xs:attribute name="toState" type="xs:unsignedByte" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="PKStates">
<xs:selector xpath="state"/>
<xs:field xpath="@id"/>
</xs:key>
<xs:keyref name="FKTransitionToStatesFrom" refer="PKStates">
<xs:selector xpath="transition"/>
<xs:field xpath="@fromState"/>
</xs:keyref>
<xs:keyref name="FKTransitionToStatesTo" refer="PKStates">
<xs:selector xpath="transition"/>
<xs:field xpath="@toState"/>
</xs:keyref>
</xs:element>
</xs:schema>
XML 测试文件:
<?xml version="1.0" encoding="utf-8"?>
<FSM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="fsm.xsd">
<state name="S1" id="1"/>
<state name="S2" id="2"/>
<state name="S3" id="3"/>
<transition toState="1" fromState="2"/>
</FSM>
最佳答案
这是一个 Eclipse 问题,很可能与您的设置有关。该模式在各种工具和平台中完全有效,包括 QTAssistant、Visual Studio、NetBeans、Xerces 和 Eclipse Helios(我知道,有点旧)。
关于android - XSD 字段 "No resource type specified"上的 Eclipse 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15790321/
我是一名优秀的程序员,十分优秀!