以文本方式查看主题

-  W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL  (http://bbs.xml.org.cn/index.asp)
--  『 Web Services & Semantic Web Services 』  (http://bbs.xml.org.cn/list.asp?boardid=10)
----  请教xml schema转换成.java文件  (http://bbs.xml.org.cn/dispbbs.asp?boardid=10&rootid=&id=35146)


--  作者:tianya
--  发布时间:7/3/2006

--  请教xml schema转换成.java文件
我有4个几个固定的选择项,故选择枚举类型来写 schema,可是转换成java出现了如下问题, 例子如下
       <simpleType name="ID_TYPE">
  <restriction base="string">
   <enumeration value="test1" />
   <enumeration value="test2" />
   <enumeration value="test3" />
   <enumeration value="test4" />
  </restriction>
 </simpleType>
         我在用jaxb将此schema转换成.java文件的时候出现此提示
                                                                                                      parsing a schema...                                                             [ERROR] src-resolve.4.2: Error resolving component 'ID_TYPE'. It was detected that 'ID_TYPE' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document 'file:/E:/JavaProgram/temp/WEB-INF/L1HttpInterface.xsd'. If this is the incorrect namespace, perhaps the prefix of 'ID_TYPE' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/E:/JavaProgram/temp/WEB-INF/L1HttpInterface.xsd'.                                                   line 72 of L1HttpInterface.xsd                                                                                                                Failed to parse a schema.                                                                                                                     请叫高手是不是转换中java不支持枚举类型所致, 那么这里应该用什么类型了?
--  作者:MerryZhang
--  发布时间:7/6/2006 9:42:00 AM

--  
你应该添加xmlns:xsd="http://www.w3.org/2001/XMLSchema"
作为NameSpace.
<xsd:simpleType name="ID_TYPE">
  <xsd:restriction base="string">
   <xsd:enumeration value="test1" />
   <xsd:enumeration value="test2" />
   <xsd:enumeration value="test3" />
   <xsd:enumeration value="test4" />
  </xsd:restriction>
</xsd:simpleType>

然后再试一下行不行。


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
6,013.672ms