ilomambo
ilomambo

Reputation: 8350

Eclipse Errors on XSD field "No resource type specified"

This is a follow up question on:

How to set restriction on XSD for id attributes

I use Eclipse. I created an XSD file with the answer code and I got these 3 errors:

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

An XML test file with XMLSchema-instance using the xsd validates OK, even with the 3 mentioned errors.
I want to know if these errors are just a glitch in Eclipse or is there something else I need to define to get rid of them.

XSD source code:

<?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 test file:

<?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>

Upvotes: 1

Views: 829

Answers (2)

ilomambo
ilomambo

Reputation: 8350

This is the bypass I found that works on Eclipse.
Note that the original syntax is perfectly legal, but Eclipse XSD validator does not seem to accept it.
The prefix .// to each xpath in the <xs:field> attribute seems to do the trick, the validation using this XSD schema on XML files is performed correctly. And more important, the XSD file is not flagged with error by Eclipse, and the project compilation is carried on successfully.

    <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>

Upvotes: 0

Petru Gardea
Petru Gardea

Reputation: 21638

It is an Eclipse problem, most likely to your setup. The schema is perfectly valid in a variety of tools and platforms, including QTAssistant, Visual Studio, NetBeans, Xerces, and Eclipse Helios (I know, kind of old).

Upvotes: 1

Related Questions