JiBX 生成忽略属性命名空间的绑定

JiBX generates binding that ignores attribute namespace

我有以下架构(片段):

<xs:complexType name="partnerPaymentsItemType">
    <xs:sequence>
        <xs:element name="changeTime" type="dateTime"/>
        <xs:element name="statusId" type="shortId"/>
        <xs:element name="paymentPointId" type="shortString"/>
        <xs:element name="money" type="currency"/>
        <xs:element name="paymentDestination" type="shortString"/>
        <xs:element name="paymentDestinationType" type="shortId"/>
        <xs:element name="subagentId" type="shortId" minOccurs="0"/>
        <xs:element name="discountCardNumber" type="xs:string" minOccurs="0"/>
        <xs:element name="amountAll" type="currency" minOccurs="0"/>
        <xs:element name="rewardPercent" type="percentAmount" minOccurs="0"/>
        <xs:element name="rewardPercentValue" type="percentAmount" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="paymentTime" use="required" type="dateTime"/>
    <xs:attribute name="externalId" use="required" type="id"/>
    <xs:attribute name="registeredId" use="required" type="id"/>
</xs:complexType>

我使用 JibX Codegen 工具从中生成源代码,然后编译应该允许我将 XML 解组为 Java 对象的绑定。这是我的代码生成设置:

<schema-set xmlns:xs="http://www.w3.org/2001/XMLSchema"
        delete-annotations="true"
        prefer-inline="false"
        generate-all="true"
        show-schema="true"
        type-substitutions="xs:date xs:string"
        package="here.lays.my.package">
    <class-decorator     class="org.jibx.schema.codegen.extend.SerializableDecorator"/>
</schema-set>

稍后,我尝试解析一个 XML 文档,该文档对标签和属性都有命名空间前缀,结果出现异常

Missing required attribute "paymentTime"

通过 JiBX 源进行调试显示它试图在文档中查找没有名称空间和名称 "paymentTime" 的属性,而文档具有名称空间映射到 URL 的属性,而不是当然能找到。

我已经反编译了与 JAD 的绑定,它搜索具有 null 命名空间的属性:

public static PartnerPaymentsItemType JiBX_beeline_binding_unmarshalAttr_1_93(PartnerPaymentsItemType arg1, UnmarshallingContext arg2)
    throws JiBXException
{
    arg2.pushTrackedObject(arg1);
    arg1;
    arg1.setPaymentTime(arg2.attributeText(null, "paymentTime"));
    arg1.setExternalId(Utility.parseLong(WhitespaceConversions.trim(arg2.attributeText(null, "externalId"))));
    arg1.setRegisteredId(Utility.parseLong(WhitespaceConversions.trim(arg2.attributeText(null, "registeredId"))));
    arg2.popObject();
    return arg1;
}

如果有任何有助于解决问题的建议,我将不胜感激 - 例如,为什么 JiBX 会生成这样的映射,如何使其尊重属性命名空间,等等。

JiBX 行为实际上是正确的,属性的命名空间前缀并非基于 xsd。

实际解决方案是用 XJC/JAXB 替换 JiBX,并为我需要属性的名称空间前缀的实体单独架构。