MOXy创建的名称空间前缀与JAXB-RI不同

MOXy创建的名称空间前缀与JAXB-RI不同,jaxb,moxy,Jaxb,Moxy,我正在尝试从JAXBRI2.2.7切换到MOXy JAXB2.5.2实现。 我注意到生成的XML输出片段中的命名空间和前缀存在以下差异: JAXB-RI: <xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:bd-algemeen="http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen" xmlns:iso4217="http://www.xbrl.o

我正在尝试从JAXBRI2.2.7切换到MOXy JAXB2.5.2实现。 我注意到生成的XML输出片段中的命名空间和前缀存在以下差异:

JAXB-RI:

<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:bd-algemeen="http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen" xmlns:iso4217="http://www.xbrl.org/2003/iso4217">
   <bd-algemeen:OperatingSystem contextRef="cc_131">W</bd-algemeen:OperatingSystem>
   <xbrli:unit id="uu_692">
        <xbrli:measure>iso4217:EUR</xbrli:measure>
    </xbrli:unit>
</xbrli:xbrl>
<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:bd-algemeen="http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen">
  <bd-algemeen:OperatingSystem contextRef="cc_131">W</bd-algemeen:OperatingSystem>
  <xbrli:unit id="uu_662">
    <xbrli:measure xmlns:ns0="http://www.xbrl.org/2003/iso4217">ns0:EUR</xbrli:measure>
   </xbrli:unit>
</xbrli:xbrl>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "divide", "measures" })
@XmlRootElement(name = "unit")
public class Unit {
    protected Divide divide;

    @XmlElement(name = "measure")
    protected List<QName> measures;
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "operatingSystem"})
public static class TaxDataBedrijf  {

   @XmlElement(name = "OperatingSystem", namespace = "http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen")
   protected Astring1ItemType operatingSystem;
final Unit item = new Unit();
item.getMeasures().add(new QName("http://www.xbrl.org/2003/iso4217", "EUR", "iso4217"));

taxData = new TaxDataBedrijf();
taxData.setOperatingSystem(createOperatingSystem(context, 'W'));
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "value" })
@XmlRootElement(name = "explicitMember")
public class ExplicitMember {

    @XmlValue
    protected QName value;

    @XmlAttribute(name = "dimension")
    protected QName dimension;
}
final ExplicitMember item = new ExplicitMember();
item.setDimension(new QName("http://www.nltaxonomie.nl/7.0/domein/bd/axes/bd-axes", "TimeDimension"));
item.setValue(new QName("http://www.nltaxonomie.nl/7.0/basis/bd/domains/bd-domains", "Current"));
@XmlElementRefs({ @XmlElementRef(name = "unit", namespace = "http://www.xbrl.org/2003/instance", type = Unit.class),
  @XmlElementRef(name = "context", namespace = "http://www.xbrl.org/2003/instance", type = Context.class),
  @XmlElementRef(name = "item", namespace = "http://www.xbrl.org/2003/instance", type = JAXBElement.class),
  @XmlElementRef(name = "tuple", namespace = "http://www.xbrl.org/2003/instance", type = JAXBElement.class),
  @XmlElementRef(name = "footnoteLink", namespace = "http://www.xbrl.org/2003/linkbase", type = JAXBElement.class) })
    protected List<Object> itemsAndTuplesAndContexts;
我认为这可能是因为使用了QName,但这也被直接用于其他地方,并且使用正确。例如,Moxy能够生成以下代码段:

<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:bd-domains="http://www.nltaxonomie.nl/7.0/basis/bd/domains/bd-domains" xmlns:bd-axes="http://www.nltaxonomie.nl/7.0/domein/bd/axes/bd-axes">
  <xbrli:scenario>
     <xbrldi:explicitMember dimension="bd-axes:TimeDimension">bd-domains:Current</xbrldi:explicitMember>
  </xbrli:scenario>
</xbrli:xbrl>
以及它的创建:

<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:bd-algemeen="http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen" xmlns:iso4217="http://www.xbrl.org/2003/iso4217">
   <bd-algemeen:OperatingSystem contextRef="cc_131">W</bd-algemeen:OperatingSystem>
   <xbrli:unit id="uu_692">
        <xbrli:measure>iso4217:EUR</xbrli:measure>
    </xbrli:unit>
</xbrli:xbrl>
<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:bd-algemeen="http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen">
  <bd-algemeen:OperatingSystem contextRef="cc_131">W</bd-algemeen:OperatingSystem>
  <xbrli:unit id="uu_662">
    <xbrli:measure xmlns:ns0="http://www.xbrl.org/2003/iso4217">ns0:EUR</xbrli:measure>
   </xbrli:unit>
</xbrli:xbrl>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "divide", "measures" })
@XmlRootElement(name = "unit")
public class Unit {
    protected Divide divide;

    @XmlElement(name = "measure")
    protected List<QName> measures;
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "operatingSystem"})
public static class TaxDataBedrijf  {

   @XmlElement(name = "OperatingSystem", namespace = "http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen")
   protected Astring1ItemType operatingSystem;
final Unit item = new Unit();
item.getMeasures().add(new QName("http://www.xbrl.org/2003/iso4217", "EUR", "iso4217"));

taxData = new TaxDataBedrijf();
taxData.setOperatingSystem(createOperatingSystem(context, 'W'));
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "value" })
@XmlRootElement(name = "explicitMember")
public class ExplicitMember {

    @XmlValue
    protected QName value;

    @XmlAttribute(name = "dimension")
    protected QName dimension;
}
final ExplicitMember item = new ExplicitMember();
item.setDimension(new QName("http://www.nltaxonomie.nl/7.0/domein/bd/axes/bd-axes", "TimeDimension"));
item.setValue(new QName("http://www.nltaxonomie.nl/7.0/basis/bd/domains/bd-domains", "Current"));
@XmlElementRefs({ @XmlElementRef(name = "unit", namespace = "http://www.xbrl.org/2003/instance", type = Unit.class),
  @XmlElementRef(name = "context", namespace = "http://www.xbrl.org/2003/instance", type = Context.class),
  @XmlElementRef(name = "item", namespace = "http://www.xbrl.org/2003/instance", type = JAXBElement.class),
  @XmlElementRef(name = "tuple", namespace = "http://www.xbrl.org/2003/instance", type = JAXBElement.class),
  @XmlElementRef(name = "footnoteLink", namespace = "http://www.xbrl.org/2003/linkbase", type = JAXBElement.class) })
    protected List<Object> itemsAndTuplesAndContexts;

请就如何解决此问题提供一些建议,以便我可以使用MOXy而不是RI(也许可以在MOXy代码中查找到什么?)

您看到的行为是一个bug,我为它打开了以下问题:


我使用正确的名称空间表示法使其工作,即它生成:

<xbrli:unit id="uu_382">
     <xbrli:measure>iso4217:EUR</xbrli:measure>
</xbrli:unit>

iso4217:欧元
我花了一些(很多;)时间调试Moxy代码,比较正确使用的名称空间,发现上面代码段的ObjectFactory不包含任何@XmlElementDecl注释,就像那些正在工作的注释一样。添加此项时,它会起作用,即:

private static final QName EUR_QNAME = new QName("http://www.xbrl.org/2003/iso4217", "EUR", "iso4217");

@XmlElementDecl(namespace = "http://www.xbrl.org/2003/iso4217", name = "EUR", substitutionHeadNamespace = "http://www.xbrl.org/2003/instance", substitutionHeadName = "item")
public JAXBElement<EUR> createEURO() {
    return new JAXBElement<EUR>(EUR_QNAME, EUR.class, null, createEUR());
}
private静态最终QName EUR_QName=新QName(“http://www.xbrl.org/2003/iso4217“,”欧元“,”iso4217“;
@XmlElementDecl(命名空间=”http://www.xbrl.org/2003/iso4217,name=“EUR”,substitutionHeadNamespace=”http://www.xbrl.org/2003/instance“,substitutionHeadName=“项目”)
公共JAXBElement createEURO(){
返回新的JAXBElement(EUR_QNAME,EUR.class,null,createEUR());
}
我注意到,当创建Xbrl(根标记)映射时,它将循环遍历属性,其中一个属性是属性“itemsAndTuplesAndContexts”。然后,它循环遍历关联的引用元素(Moxy代码:MappingGenerator.generateMappingForReferenceProperty(..),并将它们添加到其命名空间解析器映射中,该映射带有生成的前缀,该前缀存储在其描述符中。 在编组过程中,它将使用前缀映射器映射其存储的名称空间。因为我为iso4217元素添加了@XmlElementDecl声明,所以它找到了一个引用元素,因此它被添加到Xbrl根元素的名称空间解析程序映射中,并在前缀映射器中进行编组时使用

有几个问题我不太清楚:

  • 为什么Moxy中需要@xmlementdecl,而JaxB-RI不需要它
  • 为什么在使用XJC生成代码的过程中没有生成@XmlElementDecl元素
  • @布莱斯:你认为这是虫子吗
  • 属性“itemsAndTuplesAndContexts”声明:

    <xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:bd-algemeen="http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen" xmlns:iso4217="http://www.xbrl.org/2003/iso4217">
       <bd-algemeen:OperatingSystem contextRef="cc_131">W</bd-algemeen:OperatingSystem>
       <xbrli:unit id="uu_692">
            <xbrli:measure>iso4217:EUR</xbrli:measure>
        </xbrli:unit>
    </xbrli:xbrl>
    
    <xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:bd-algemeen="http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen">
      <bd-algemeen:OperatingSystem contextRef="cc_131">W</bd-algemeen:OperatingSystem>
      <xbrli:unit id="uu_662">
        <xbrli:measure xmlns:ns0="http://www.xbrl.org/2003/iso4217">ns0:EUR</xbrli:measure>
       </xbrli:unit>
    </xbrli:xbrl>
    
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = { "divide", "measures" })
    @XmlRootElement(name = "unit")
    public class Unit {
        protected Divide divide;
    
        @XmlElement(name = "measure")
        protected List<QName> measures;
    }
    
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = { "operatingSystem"})
    public static class TaxDataBedrijf  {
    
       @XmlElement(name = "OperatingSystem", namespace = "http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-algemeen")
       protected Astring1ItemType operatingSystem;
    
    final Unit item = new Unit();
    item.getMeasures().add(new QName("http://www.xbrl.org/2003/iso4217", "EUR", "iso4217"));
    
    taxData = new TaxDataBedrijf();
    taxData.setOperatingSystem(createOperatingSystem(context, 'W'));
    
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = { "value" })
    @XmlRootElement(name = "explicitMember")
    public class ExplicitMember {
    
        @XmlValue
        protected QName value;
    
        @XmlAttribute(name = "dimension")
        protected QName dimension;
    }
    
    final ExplicitMember item = new ExplicitMember();
    item.setDimension(new QName("http://www.nltaxonomie.nl/7.0/domein/bd/axes/bd-axes", "TimeDimension"));
    item.setValue(new QName("http://www.nltaxonomie.nl/7.0/basis/bd/domains/bd-domains", "Current"));
    
    @XmlElementRefs({ @XmlElementRef(name = "unit", namespace = "http://www.xbrl.org/2003/instance", type = Unit.class),
      @XmlElementRef(name = "context", namespace = "http://www.xbrl.org/2003/instance", type = Context.class),
      @XmlElementRef(name = "item", namespace = "http://www.xbrl.org/2003/instance", type = JAXBElement.class),
      @XmlElementRef(name = "tuple", namespace = "http://www.xbrl.org/2003/instance", type = JAXBElement.class),
      @XmlElementRef(name = "footnoteLink", namespace = "http://www.xbrl.org/2003/linkbase", type = JAXBElement.class) })
        protected List<Object> itemsAndTuplesAndContexts;
    
    @xmlementrefs({@xmlementref(name=“unit”,名称空间=”http://www.xbrl.org/2003/instance,类型=单位.class),
    @XmlElementRef(name=“context”,名称空间=”http://www.xbrl.org/2003/instance,type=Context.class),
    @xmlementref(name=“item”,名称空间=”http://www.xbrl.org/2003/instance,type=JAXBElement.class),
    @XmlElementRef(name=“tuple”,名称空间=”http://www.xbrl.org/2003/instance,type=JAXBElement.class),
    @XmlElementRef(name=“footnoteLink”,命名空间=”http://www.xbrl.org/2003/linkbase,type=JAXBElement.class)})
    受保护的列表项和tuplesandcontexts;
    
    您使用的是哪个版本的EclipseLink MOXy?抱歉,我忘了,刚刚添加的(RI:2.2.7;MOXy:2.5.2)MOXy根本没有命中
    NamespacePrefixMapper
    或者它命中的是所有元素,但不是限定的文本值?使用了NamespacePrefixMapper,但没有用于此iso4217前缀。我只是添加了一个使用前缀mapper的映射。哇,我知道你很快。。。但这很快;)。。。我只是添加了一些工作场景。。。谢谢,我一直在监控这个bug。。。在问题解决之前(一周、几个月……)有什么想法吗?解决办法?我可以提供更多的调试信息吗?