如何将xml“引用”属性映射到具有jaxb绑定的实际实例?

时间:2019-06-18 08:46:21

标签: java jaxb xjc

我正在使用xjc / jaxb从xsd生成Java类。我原始的(不可修改的)xml包含“引用”属性(作为字符串),我希望使用bindings.xsd将它们映射到生成的代码中的实际Java实例。

这是xml片段

 <FactMappingValue>
            <factIdentifier reference="../../../../../simulationDescriptor/factMappings/FactMapping[2]/factIdentifier"/>
</FactMappingValue>

其中FactMappings是一个数组,并且该数组的每个元素都包含一个“ factIdentifier”。

这是相关的xsd定义

   <xs:complexType name="factIdentifierType">
    <xs:sequence>
      <xs:element type="xs:string" name="name" minOccurs="0"/>
      <xs:element type="xs:string" name="className" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
...
<xs:complexType name="factIdentifierReferenceType">
    <xs:attribute type="xs:string" name="reference"/>
  </xs:complexType>
  <xs:complexType name="FactMappingValueType">
    <xs:sequence>
      <xs:element type="factIdentifierReferenceType" name="factIdentifier"/>
    </xs:sequence>
  </xs:complexType>

任何建议将不胜感激,谢谢!

0 个答案:

没有答案