eclipse - JAXB 绑定(bind) XBRL 元素不起作用

标签 eclipse xpath binding jaxb xbrl

我正在尝试在 Eclipse 中使用 JAXB 生成本地化的 XBRL 类,但出现错误:

[ERROR] Property "Title" is already defined. Use <jaxb:property> to resolve this conflict. 
line 145 of http://www.xbrl.org/2003/xl-2003-12-31.xsd

[ERROR] The following location is relevant to the above error
line 151 of http://www.xbrl.org/2003/xl-2003-12-31.xsd

正如错误所暗示的,元素和属性名称冲突。这些是第 145 和 151 行:
<element ref="xl:title" minOccurs="0" maxOccurs="unbounded" />
<attribute ref="xlink:title" use="optional" />

所以我需要重命名一个(或两个)。这就是我一直在尝试做的 - 将元素标题绑定(bind)到 titleElement:
<jxb:bindings version="1.0"
  xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xl="http://www.xbrl.org/2003/XLink" 
  schemaLocation="http://www.xbrl.org/2003/xl-2003-12-31.xsd">
    <jxb:bindings node="//element[@ref='xl:title']">
        <jxb:property ref="xl:titleElement"/>
    </jxb:bindings>
</jxb:bindings>

这会产生以下错误,以及原始的“标题已定义”错误:
[ERROR] XPath evaluation of "//element[@ref='xl:title']" results in empty target node
line 6 of titleElementAttributeFixer.xjb

建议让它工作?

编辑:正如helderdarocha 建议的那样,我的表达是错误的。我是 XML 和 XPath 的新手,这有点令人困惑,因为该元素没有明确键入的“xs:”命名空间。在我修复了这个错误之后,我得到了另一个:
[ERROR] XPath evaluation of "//xs:element[@ref='xl:title']" results in too many (3) target nodes

由于所有“ref”属性都需要更新,我将标签“multiple='true'”放在绑定(bind)中。现在我收到以下错误,无法弄清楚如何解决它:
[ERROR] cvc-complex-type.3.2.2: Attribute 'ref' is not allowed to appear in element 'jxb:property'.

对此有什么想法?我确实想将相关元素的属性“ref”中的内容绑定(bind)到另一个名称。

最佳答案

毕竟,我通过应用这些 SO 问题解决了这个问题:
JAXB fails to generate Java classes for XBRL
JAXB XJC Two declarations cause a collision. Customized binding cannot be honored

所以在我解决了最初的问题之后,我还遇到了对象工厂冲突的其他问题,我也修复了这些问题。这就是我的工作 bindings.xjb 的一般外观:

<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
version="2.1">

    <bindings schemaLocation="http://www.xbrl.org/2003/xl-2003-12-31.xsd" 
        node="//xsd:schema//xsd:element[@name='title']">
        <property name="xlTitle"/>
    </bindings>

    <bindings schemaLocation="<local_dimension_file_D002>.xsd"
        node="//xsd:schema//xsd:element[@name='AcceleratedDepreciation']"> 
        <factoryMethod name="AcceleratedDepreciationD002"/>
    </bindings>

    ...many more objectfactory collisions solved...
</bindings>

我希望这有助于其他 XBRL/XML/JAXB 新手入门。

关于eclipse - JAXB 绑定(bind) XBRL 元素不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24490950/

相关文章:

java.lang.NoClassDefFoundError Spark-submit 使用其他项目中的类

android - 无法解码流 java.io.FileNotFoundException/storage/emulated/0 打开失败 :ENOENT(No such file or directory

python - Xpath获取亚马逊价格

python - Pybind11 用于 C++ 代码,内部结构通过静态工厂方法创建

java - 在 Eclipse 中调试 List<Class> 对象?

javascript - 在 eclipse luna 中启用 javascript 验证

sql - 如何重写 SQL xpath 查询以创建索引 View

xpath - 如何找到其中包含输入元素的嵌入 li?

c# - 将标签内容绑定(bind)到嵌套类中的值而不是 Datacontext

绑定(bind)和闭合 groovy