jakartaee / jakartaee/jaxb-api

mapping XML schema for containment vs reference

Open
#22 6 comments 0 reactions 1 assignee Claimed by @glassfishrobot View on GitHub
enhancement javatoxsd Major
Dominant language
Java
Stars
79
Forks
48
Avg merge
7h 12m
Merged PRs (30d)
2

Description

Issue 22: mapping : Containment vs. reference

The following two approaches have been discussed in the expert group
prior to the F2F.

1\. JAXB 2.0 provides mechanisms which can be used to customize the
generated XML schema to allow a reference to an object to be
marshalled by containment or by reference.This approach has
issues - not user friendly (e.g. can result in for cycles), hard
to use etc. Nonetheless, this option does provide control to a
user for customizing the generated schema and was thought
worthwhile to explore this option further.

The discussion threads are here:

[http://archives.java.sun.com/cgi-bin/wa?A2=ind0402&L=jsr-222-eg&X=12E27C5E49150B4D5C&Y=sekhar.vajjhala@sun.com&P=3204](http://archives.java.sun.com/cgi-bin/wa?A2=ind0402&L=jsr-222-eg&X=12E27C5E49150B4D5C&Y=sekhar.vajjhala@sun.com&P=3204)

[http://archives.java.sun.com/cgi-bin/wa?A2=ind0403&L=jsr-222-eg&X=12E27C5E49150B4D5C&Y=sekhar.vajjhala@sun.com&P=728](http://archives.java.sun.com/cgi-bin/wa?A2=ind0403&L=jsr-222-eg&X=12E27C5E49150B4D5C&Y=sekhar.vajjhala@sun.com&P=728)

2\. JAXB 2.0 determines based on the object graph the marshalling of
an object by containment or reference. For example, the first time
an object is marshalled, it is marshalled by
containment. Subsequent references of object are marshalled by
reference. This would be enabled by generating an XML schema with
a that includes both an id or a reference to an id
(defined elsewhere). See the thread

[http://archives.java.sun.com/cgi-bin/wa?A2=ind0402&L=jsr-222-eg&X=12E27C5E49150B4D5C&Y=sekhar.vajjhala@sun.com&P=3204](http://archives.java.sun.com/cgi-bin/wa?A2=ind0402&L=jsr-222-eg&X=12E27C5E49150B4D5C&Y=sekhar.vajjhala@sun.com&P=3204)

Additionally the following approach was suggested at the JAXB 2.0 F2F.

3\. A third approach was suggested in JAXB 2.0 F2F by Steve
Brodsky. The discussion is in bullet 13 in the F2F minutes:

[https://www.dev.java.net/files/documents/919/3776/f2f-minutes.txt](https://www.dev.java.net/files/documents/919/3776/f2f-minutes.txt)

The summary of this approach is: XML instance could just list
every single object at the top-level and all the references can be
ID/IDREF (since Java does not distinguish between containment
vs. reference). The generated XML schema might not be useful or
meaningful in some cases. In such a case, Java classes have to be
customized to produce the desired XML schema i.e. use approach 1
noted in bullet item 1 above.
#### Environment
Operating System: All
Platform: All
#### Affected Versions
[2.0 draft]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.