users@jaxb.java.net

element and type interchangeability

From: Philip A. Culver <pculver_at_bostonatlantic.net>
Date: Mon, 22 Sep 2003 18:35:28 -0400

Hi All,
 
I was wondering if something is possible currently in JAXB v1.0.1.
 
The example schema fragment is :
 
<xs:element name="someElement" type="someElementType"/>
<xs:complexType name="someElementType">
    <xs:attribute name="attr1example" type="xs:int"/>
</xs:complexType>
 
<xs:element name="someOtherElement" type="someOtherElementType"/>
<xs:complexType name="someOtherElementType">
    <xs:all>
        <xs:element ref="someElement"/>
    </xs:all>
     <!-- ... other things here -->
</xs:complexType>
 
This generates a someOtherElement class that has a method getSomeElement
with a return type of someElementType.
 
I was expecting the getSomeElement method to return a type of someElement.
I have an instance of someOtherElement and a method that takes as a
parameter someElement and I would like to pass the someElement contained in
someOtherElement to this method but this doesn't seem possible.
 
e.g.
 
ObjectFactory of = new ObjectFactory();
someOtherElement otherElem = of.createSomeOtherElement();
 
// Populate someOtherElement
...
 
// call method public void doSomething(someElement elem);
foo.doSomething(otherElem.getSomeElement()); // A compile error would
occur at this point.
 
 
Is there any solution to this issue? Do I need to expand the explanation
of my issue/question?
 
Thanks,
Phil