Mapping Java with JAXB annotations to XSD keys/keyrefs

We are using JAXB to map Java classes into XML files. Currently we use the Java-to-XSD approach by annotating the Java classes.

This works fine in general but we've hit the following problem now: we want an attribute of one XML element to refer to another XML element by it's name/ID. Imagine some XML describing a conceptual schema, with the entities defined in <entity> elements and <property> elements used to establish the links. The @type attribute of the properties should then reference an entity in the same file.

Is it possible to model this using JAXB? What I imagine is having xsd:key and xsd:keyref elements in the schema which should then be resolved to the matching Java objects when unmarshalling.


It's non-trivial, but possible:

http://weblogs.java.net/blog/2005/08/15/pluggable-ididref-handling-jaxb-20

链接地址: http://www.djcxy.com/p/62962.html

上一篇: 为什么JAXB不想验证

下一篇: 将带有JAXB注释的Java映射到XSD键/ keyrefs