问题描述
使用 Ant 的 xjc2 任务绑定一些有效的 XML 文档时,我收到以下失败消息:
When binding on some valid XML documents using Ant's xjc2 task, I get the following failure message:
[xjc2] [ERROR] null
[xjc2] unknown location
这些文件与其他绑定成功的文件非常相似,所有导入的模式都存在.以详细模式运行 xjc 产生:
The documents are very similar to other files which have bound successfully, all imported schemas exist. Running xjc in verbose mode produced:
Parent is not Defined Class...I cannot get the fields from this class
有人知道这是什么意思吗?
Anyone have any idea what this means?
推荐答案
架构正确性检查
在我们使用 XJC 的过程中,我们看到了一个类似的问题(请参阅下面的链接),该问题已通过禁用架构正确性检查得到解决:
In our use of XJC we have seen a similar problem (see the link below) that was solved by disabling the schema correctness check:
尝试使用以下系统属性来禁用架构正确性检查.
Try the following System property to disable the schema correctness check.
-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 参数与架构正确性检查相关:
From the following page the -nv parameter relates to the schema correctness check:
进入代码
您可以尝试以编程方式与 XJC 交互(见下文)并插入您自己的 EntityResolver 以查看导入/包含失败的位置:
You could try interacting with XJC programmatically (see below) and plug-in your own EntityResolver to see where the import/include fails:
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();
这篇关于JAXB Ant 任务错误:xjc2 [ERROR] null 未知位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!