我正在尝试从以下xsd
生成JAXB模型<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>
但是,它给了我以下错误,我在Eclipse控制台中得到了
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.
请帮忙。
答案 0 :(得分:2)
删除此额外的命名空间属性 targetNamespace =“http://www.hcentive.com/mea/trr”
或添加此 xmlns =“http://www.hcentive.com/mea/trr”
两种解决方案都有效:)