JAXB - 解组时跟随keyref的示例 [英] JAXB - Example of following a keyref when unmarshalling

查看:59
本文介绍了JAXB - 解组时跟随keyref的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个,您可以在JAXB 2.x中编组和解组数据时使用xs:key和xs:keyref。

According to this, you can make use of xs:key and xs:keyref when marshalling and unmarshalling data in JAXB 2.x.

但是,我找不到这是在任何地方完成的一个工作示例。

However, I can't find a working example of this being done anywhere.

我们正在做的是在每个XML消息中设置一个查找部分,其中包含参考/代码值的详细信息(id,名称,描述等),然后让消息中的数据元素使用其键引用这些项目。 XML模式通过xs:keyref和xs:key定义并支持它(xs:IDREF不是允许的选项)。

What we're doing is setting a lookup section in each XML message containing the details for the reference/code values (id, name, description, etc), and then have the data elements later in the message refer back to these items using their key. XML schema defines and supports this through xs:keyref and xs:key (xs:IDREF is not an allowed option).

我想做的是拥有我的JAXB unmarshaller动态地遵循这些引用,用引用的对象替换键。

What I'd like to do is have my JAXB unmarshaller follow these refs dynamically, replacing the key with the referenced object.

有人可以参考我这样做的例子吗?

Could anybody refer me to an example of this being done?

推荐答案

你在谈论复合关键因素吗?

Are you talking about a compound key situtation?

<directory>
   <employee>
      <eID>123</eID>
      <country>CA</country>
   </employee>
   <employee>
      <eID>123</eID>
      <country>US</country>
   </employee>
   <employee>
      <eID>456</eID>
      <country>US</country>
   </employee>
   <phone-number>
      <contact eID="123" country="US"/>
   </phone-number>
</directory>

如果是这样的话 EclipseLink JAXB(MOXy)

  • http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA/CompoundPrimaryKeys

这篇关于JAXB - 解组时跟随keyref的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆