我想使用xjc
工具来生成xsd
文件中的类。
但是我可以接受 例外 :
$ xjc -d generated POCD_MT000040.xsd
parsing a schema...
compiling a schema...
Exception in thread "main" java.lang.IllegalArgumentException: trying to create the same field twice: id
at com.sun.codemodel.internal.JDefinedClass.field(JDefinedClass.java:410)
at com.sun.codemodel.internal.JDefinedClass.field(JDefinedClass.java:381)
at com.sun.tools.internal.xjc.generator.bean.field.AbstractFieldWithVar.createField(AbstractFieldWithVar.java:62)
at com.sun.tools.internal.xjc.generator.bean.field.SingleField.<init>(SingleField.java:79)
at com.sun.tools.internal.xjc.generator.bean.field.SingleField.<init>(SingleField.java:66)
at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.sun.tools.internal.xjc.generator.bean.field.GenericFieldRenderer.generate(GenericFieldRenderer.java:54)
at com.sun.tools.internal.xjc.generator.bean.field.DefaultFieldRenderer.generate(DefaultFieldRenderer.java:67)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateFieldDecl(BeanGenerator.java:759)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateClassBody(BeanGenerator.java:540)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:243)
at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:151)
at com.sun.tools.internal.xjc.model.Model.generateCode(Model.java:275)
at com.sun.tools.internal.xjc.Driver.run(Driver.java:342)
at com.sun.tools.internal.xjc.Driver.run(Driver.java:184)
at com.sun.tools.internal.xjc.Driver._main(Driver.java:107)
at com.sun.tools.internal.xjc.Driver.access$000(Driver.java:64)
at com.sun.tools.internal.xjc.Driver$1.run(Driver.java:87)
我试图在在线验证器中对此架构进行校准,但它包括其他三个架构:
<xs:include schemaLocation="coreschemas/datatypes.xsd"/>
<xs:include schemaLocation="coreschemas/voc.xsd"/>
<xs:include schemaLocation="coreschemas/NarrativeBlock.xsd"/>
失败了一堆错误。
现在我不知道 如何从此架构生成类 ?
现在如何验证呢? 有什么建议吗?