JAXB Ant任务错误:xjc2 [ERROR] null未知位置

时间:2010-08-13 15:45:30

标签: java ant jaxb xjc

使用Ant的xjc2任务绑定某些有效的XML文档时,我收到以下失败消息:

[xjc2] [ERROR] null
[xjc2] unknown location

文档与已成功绑定的其他文件非常相似,所有导入的模式都存在。以详细模式运行xjc:

Parent is not Defined Class...I cannot get the fields from this class

任何人都知道这意味着什么?

1 个答案:

答案 0 :(得分:5)

架构正确性检查

在我们使用XJC时,我们看到了一个类似的问题(参见下面的链接),它通过禁用模式正确性检查来解决:

尝试使用以下System属性来禁用架构正确性检查。

-Dcom.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.noCorrectnessCheck=true

对于Ant,请尝试:

<xjc target="src">
  <schema dir="src" includes="**/*.xsd" excludes="**/debug.xsd"/>
  <arg value="-nv" />
</xjc>

在以下页面中,-nv参数与架构正确性检查有关:

进入守则

您可以尝试以编程方式与XJC交互(请参阅下文)并插入您自己的EntityResolver以查看导入/包含失败的位置:

import com.sun.codemodel.*;
import com.sun.tools.xjc.*;
import com.sun.tools.xjc.api.*;

SchemaCompiler sc = XJC.createSchemaCompiler();
sc.setEntityResolver(new YourEntityResolver());
sc.setErrorListener(new YourErrorListener());
sc.parseSchema(SYSTEM_ID, element);
S2JJAXBModel model = sc.bind();