ISSUE-648: Can schema be made a bit more jaxb friendly?

Can schema be made a bit more jaxb friendly?

State:
RAISED
Product:
XML Serialization
Raised by:
Luc Moreau
Opened on:
2013-03-08
Description:

Hi

I have ported the ProvToolbox and the ProvValidator to the new XML schema.
I just wanted to report on my experience with the schema and JAXB.
Obviously, others may have better experience with JAXB and may be able
to help on some of the issues I encountered.

Everything worked fine, except:
- <xs:element ref="prov:internalElement abstract=true/>
- extensibility <xs:any namespace="##other"/> in Document and Bundle


These two constructs, while processable by JAXB, are not JAXB-friendly.

Indeed, JAXB compiles the schema in a list containing all possible statements.

protected List<Object> entityAndActivityAndWasGeneratedBy;

However, the presence on an abstract element and an <any/> element result in the
content of that list to be of type:


@XmlElementRefs({
@XmlElementRef(name = "used", namespace = "http://www.w3.org/ns/prov#", type = JAXBElement.class),
@XmlElementRef(name = "wasAssociatedWith", namespace = "http://www.w3.org/ns/prov#", type = JAXBElement.class),
@XmlElementRef(name = "person", namespace = "http://www.w3.org/ns/prov#", type = JAXBElement.class),
@XmlElementRef(name = "entity", namespace = "http://www.w3.org/ns/prov#", type = JAXBElement.class),
@XmlElementRef(name = "wasInfluencedBy", namespace = "http://www.w3.org/ns/prov#"
....
})

@XmlAnyElement(lax = true)
protected List<Object> entityAndActivityAndWasGeneratedBy;

where all data structures are wrapped up in this unpleasant JAXBElement.

Without these features, we get a much more natural mapping:
@XmlElements({
@XmlElement(name = "entity", namespace = "http://www.w3.org/ns/prov#", type = Entity.class),
@XmlElement(name = "activity", namespace = "http://www.w3.org/ns/prov#", type = Activity.class),
@XmlElement(name = "wasGeneratedBy", namespace = "http://www.w3.org/ns/prov#", type = WasGeneratedBy.class),
@XmlElement(name = "used", namespace = "http://www.w3.org/ns/prov#", type = Used.class),
@XmlElement(name = "wasInformedBy", namespace = "http://www.w3.org/ns/prov#", type = WasInformedBy.class),
...
})

So, how I did I solve the problem? I inserted the extension schemas into the schema file, and hence got rid of the abstract element. I am ok with this. We could possible provide the utility to that transformation.

For the extensibility, I used a different definition. It happens to
parse prov-xml compliant xml. When serializing, it puts all
extensibility elements at the end. This is not a satisfactory
solution, and is likely to be dependent of the jaxb implementation (though I am not entirely sure).


<xs:complexType name="Document">
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:group ref="prov:documentElements"/>
<xs:element name="bundleContent" type="prov:NamedBundle"/>
</xs:choice>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

Can something be done to make the XML schema a bit more jaxb friendly,
while still keeping the same flexibility? Thoughts welcome.

Cheers,
Luc

Related Actions Items:
No related actions
Related emails:
  1. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from zednis2@rpi.edu on 2013-04-04)
  2. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from zednis2@rpi.edu on 2013-04-04)
  3. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from hook.hua@jpl.nasa.gov on 2013-04-04)
  4. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from zednis2@rpi.edu on 2013-04-04)
  5. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from hook.hua@jpl.nasa.gov on 2013-04-04)
  6. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from zednis2@rpi.edu on 2013-04-03)
  7. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from hook.hua@jpl.nasa.gov on 2013-04-03)
  8. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from zednis2@rpi.edu on 2013-04-03)
  9. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from zednis2@rpi.edu on 2013-04-02)
  10. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from zednis2@rpi.edu on 2013-04-02)
  11. Re: ISSUE-648: Can schema be made a bit more jaxb friendly? (from l.moreau@ecs.soton.ac.uk on 2013-04-02)
  12. ISSUE-648: Can schema be made a bit more jaxb friendly? (from zednis2@rpi.edu on 2013-04-02)
  13. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from hook.hua@jpl.nasa.gov on 2013-03-28)
  14. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from hook.hua@jpl.nasa.gov on 2013-03-28)
  15. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from hook.hua@jpl.nasa.gov on 2013-03-28)
  16. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from zednis@rpi.edu on 2013-03-28)
  17. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from l.moreau@ecs.soton.ac.uk on 2013-03-28)
  18. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from l.moreau@ecs.soton.ac.uk on 2013-03-28)
  19. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from zednis@rpi.edu on 2013-03-28)
  20. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from zednis@rpi.edu on 2013-03-28)
  21. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from zednis@rpi.edu on 2013-03-28)
  22. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from hook.hua@jpl.nasa.gov on 2013-03-28)
  23. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from zednis@rpi.edu on 2013-03-21)
  24. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from l.moreau@ecs.soton.ac.uk on 2013-03-21)
  25. Re: PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from hook.hua@jpl.nasa.gov on 2013-03-21)
  26. PROV-ISSUE-648: Can schema be made a bit more jaxb friendly? [XML Serialization] (from sysbot+tracker@w3.org on 2013-03-08)

Related notes:

No additional notes.

Display change log ATOM feed


Chair, Staff Contact
Tracker: documentation, (configuration for this group), originally developed by Dean Jackson, is developed and maintained by the Systems Team <w3t-sys@w3.org>.
$Id: 648.html,v 1.1 2013-06-20 07:37:58 vivien Exp $