1

我正在尝试从以下 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.

请帮忙。

4

1 回答 1

2

移除这个额外的命名空间属性targetNamespace="http://www.hcentive.com/mea/trr"

或添加此xmlns="http://www.hcentive.com/mea/trr"

两种解决方案都可以工作:)

供您参考targetnamespace-and-xmlns

于 2013-04-29T15:03:53.573 回答