Anand
Anand

Reputation: 21320

Error while generating JAXB model from xsd in eclipse

I am trying to generate JAXB model from the following xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://abc.com/mmm/trt" attributeFormDefault="unqualified"
    elementFormDefault="qualified">
    <xs:annotation>
        <xs:documentation>Schema for Cache Refresh Event.
        </xs:documentation>
    </xs:annotation>
    <xs:simpleType name="cacheCode">
        <xs:restriction base="xs:string">
            <xs:enumeration value="BUSINESS_RULE" />
            <xs:enumeration value="USER" />
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="cacheRefreshEvent">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="cacheCode" type="cacheCode" minOccurs="1"
                    maxOccurs="1" />
                <xs:element name="entityRefId" type="xs:string"  minOccurs="0"
                    maxOccurs="20" />
                <xs:element name="cacheRefreshDate" type="xs:dateTime"
                    minOccurs="1" maxOccurs="1" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

But, it is giving me the following error, which i got in Eclipse console

parsing a schema...
[ERROR] src-resolve.4.1: Error resolving component 'cacheCode'. It was detected that 'cacheCode' has no namespace, but components with no target namespace are not referenceable from schema document 'file:/F:/Sprint6/cache/src/main/resources/CacheRefreshEvent.xsd'. If 'cacheCode' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'cacheCode' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:/F:/Sprint6/cache/src/main/resources/CacheRefreshEvent.xsd'.
  line 18 of file:/F:/Sprint6/cache/src/main/resources/CacheRefreshEvent.xsd

Failed to parse a schema.

Please help.

Upvotes: 1

Views: 1694

Answers (1)

Sunny Gupta
Sunny Gupta

Reputation: 7067

Remove this extra namespace attribute targetNamespace="http://www.hcentive.com/mea/trr"

OR add this xmlns="http://www.hcentive.com/mea/trr"

Both solutions will work :)

For you reference targetnamespace-and-xmlns

Upvotes: 2

Related Questions