A
Andreas
I want to build an editor for a tree structure like
<Trunk>
<Branch/>
<Branch>
<Branch>
<Leaf/>
<Leaf/>
</Branch>
..
</Branch>
<Branch>
<Leaf/>
</Branch>
..
</Trunk>
The schema definition for a branch element type looks like
<xs:complexType name="BranchType">
<xs:annotation>
<xs:appinfo>
<jxb:class implClass="BranchTypeExt"/>
</xs:appinfo>
</xs:annotation>
<xs:sequence minOccurs="0">
<xs:element name="Branch" type="BranchType"
minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Leaf" type="LeafType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
The tree is part of a navigational JTree in an application, so it
should handle objects, not XML elements.
When I create a JAXB tree out of my schema for this structure, JAXB
creates an interface "branchType" and an implementation class
"branchTypeImpl". The generated interfaces "branchType" and
"Trunc" then declare methods like
java.util.List getBranch()
so that it is possible to navigate DOWN to the smaller branches and
to the leafs. However, the JAXB generated interfaces do not contain
any means to navigate from a leaf or branch back to the trunk!
In my opinion, this back pointing information could easily be
extracted from the underlying XML Schema (?). I would have expected
that the interfaces would declare a method like
Object getParent()
to do this. I have checked the JAXB specification and the javadoc
Documentation for a hint but did not found anything. Does anybody
know whether there is special customization element (or another way)
to do this with JAXB?
Of course there are several workarounds (involving
DefaultMutableTreeNodes or extending the branchImpl class via class
customizing, for example) but all make the XML binding more
complicated. I would think that many XML based structures need to
implement links to the parent elements, not only mine, so it would
be a serious drawback of JAXB not to implement this. Does anybody
know whether other XML binding frameworks do support this feature?
Thanks in advance,
Andreas
<Trunk>
<Branch/>
<Branch>
<Branch>
<Leaf/>
<Leaf/>
</Branch>
..
</Branch>
<Branch>
<Leaf/>
</Branch>
..
</Trunk>
The schema definition for a branch element type looks like
<xs:complexType name="BranchType">
<xs:annotation>
<xs:appinfo>
<jxb:class implClass="BranchTypeExt"/>
</xs:appinfo>
</xs:annotation>
<xs:sequence minOccurs="0">
<xs:element name="Branch" type="BranchType"
minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Leaf" type="LeafType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
The tree is part of a navigational JTree in an application, so it
should handle objects, not XML elements.
When I create a JAXB tree out of my schema for this structure, JAXB
creates an interface "branchType" and an implementation class
"branchTypeImpl". The generated interfaces "branchType" and
"Trunc" then declare methods like
java.util.List getBranch()
so that it is possible to navigate DOWN to the smaller branches and
to the leafs. However, the JAXB generated interfaces do not contain
any means to navigate from a leaf or branch back to the trunk!
In my opinion, this back pointing information could easily be
extracted from the underlying XML Schema (?). I would have expected
that the interfaces would declare a method like
Object getParent()
to do this. I have checked the JAXB specification and the javadoc
Documentation for a hint but did not found anything. Does anybody
know whether there is special customization element (or another way)
to do this with JAXB?
Of course there are several workarounds (involving
DefaultMutableTreeNodes or extending the branchImpl class via class
customizing, for example) but all make the XML binding more
complicated. I would think that many XML based structures need to
implement links to the parent elements, not only mine, so it would
be a serious drawback of JAXB not to implement this. Does anybody
know whether other XML binding frameworks do support this feature?
Thanks in advance,
Andreas