开发者

different schema types for the same xml element depending on attribute

the xml looks like

<root>
<service name="product" />
<service name="sim" />
<service name="blub" />
</root>

the schema should look like

<xs:element name="root">
<xs:complexeType>
<xs:element type='serviceProduct' name='service' />
<xs:element type='serviceSim' name='service' />
<xs:element type='serviceBlub' name='service' />
</xs:complexeType>
</xs:element>

Is it possible with JAXB Bindings to do that? I cannot change the xml but I would like t to have different java classes for product, sim, blub but its all the same xml element.

With class binding declerations it is possible to开发者_如何转开发 change the class name but how could I do this for the same element but with different attributes?

Thanks, Ralph


Another solution would be here ... Java/JAXB: Unmarshall XML attributes to specific Java object attributes

but I would prefer a solution in the schema. It could work as described in the 'Bind Choice Example' which shows how to bind a choice model group to a Java Interface ... http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.5/tutorial/doc/JAXBUsing4.html#wp155808

The problem with this solution is that the @bindingStyle attribute is no longer allowed as of JAXB 2.0.

Any ideas?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜