【发布时间】:2014-10-03 16:35:49
【问题描述】:
我有下面的 XML,它代表一个调用事件,需要解组为 Java 对象。我正在使用 JAXB 并且能够处理其中的大部分,除了将值集合表示为元素名称的块。
没有为每个可能的元素创建一个类(即给定here),有没有办法在 JAXB 中更动态地表示它?
<message xmlns='jabber:client' from='pubsub.server.example.com' to='leon@server.example.com'
id='leon_office_vmstsp_default__leon@server.example.com__uz8mQ'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='leon_office_vmstsp_default'>
<item id='leon_office_vmstsp_default'>
<callstatus xmlns='http://xmpp.org/protocol/openlink:01:00:00#call-status'
busy='false'>
<call>
<id>1411743786867</id>
<profile>leon_office</profile>
<interest>leon_office_vmstsp_default</interest>
<changed>State</changed>
<state>CallEstablished</state>
<direction>Outgoing</direction>
<duration>3</duration>
<caller>
<number>6001</number>
<name>leon_office</name>
</caller>
<called>
<number>3807</number>
<name>3807</name>
</called>
<actions>
<ClearCall />
<RemoveThirdParty />
<StopVoiceDrop />
<MuteParty />
<AddThirdParty />
<SendDigit />
<ClearConnection />
<UnMuteParty />
<StartVoiceDrop />
</actions>
<participants>
<participant exten='3807' />
<participant exten='6001' />
</participants>
<features>
<feature id='Conference'>true</feature>
</features>
</call>
</callstatus>
</item>
</items>
</event>
<headers xmlns='http://jabber.org/protocol/shim'>
<header name='pubsub#subid'>aLfatHpG059mNcAe5ta11YNOAjA02l486sE1p4hK</header>
</headers>
【问题讨论】:
-
你解决了这个问题吗?如果是,你是怎么解决的?