代码之家  ›  专栏  ›  技术社区  ›  Tom Tresansky

JAXB Ant任务错误:XJC2[错误]空未知位置

  •  5
  • Tom Tresansky  · 技术社区  · 16 年前

    当使用Ant的XJC2任务绑定到一些有效的XML文档时,我得到以下失败消息:

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

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

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

    有人知道这是什么意思吗?

    1 回复  |  直到 16 年前
        1
  •  5
  •   bdoughan    16 年前

    架构正确性检查

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

    请尝试以下系统属性以禁用架构正确性检查。

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

    对于蚂蚁,尝试:

    <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();