Greetings,
Using the schema below, the binding file ends up creating abstract
mappings for all types other than CComplexObject. As you can see, only
OBJECT_ID is supposed to be an abstract class. The generated java
sources are fine, only OBJECTID Java class is abstract, but the
binding file marks all classes involved in the abstract class as
abstract, please see below for details: This is my schema, used with
jibx v 1.2.3 under windows XP sp3.


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns="http://schemas.openehr.org/v1";
targetNamespace="http://schemas.openehr.org/v1";
xmlns:tns="http://www.example.org/AOM"; elementFormDefault="qualified">
    <xs:element name="CComplexObject">
            <xs:complexType>
                <xs:sequence>
                        <xs:element name="NodeId" type="xs:string"></xs:element>
                        <xs:element name="nodeNo" type="xs:int"></xs:element>
                </xs:sequence>
            </xs:complexType>
    </xs:element>

    <xs:complexType name="OBJECT_ID" abstract="true">
                <xs:sequence>
                        <xs:element name="value" type="xs:token"/>
                </xs:sequence>
        </xs:complexType>
        
        <xs:complexType name="UID_BASED_ID">
                <xs:complexContent>
                        <xs:extension base="OBJECT_ID">
                                <xs:sequence/>
                        </xs:extension>
                </xs:complexContent>
        </xs:complexType>
        

    <xs:complexType name="OBJECT_REF">
                <xs:sequence>
                        <xs:element name="id" type="OBJECT_ID"/>
                        <xs:element name="namespace" type="xs:token"/>
                        <xs:element name="type" type="xs:token"/>
                </xs:sequence>
        </xs:complexType>

</xs:schema>

This is the generated binding.xml: Both UID_BASED_ID and OBJECT_REF
are abstract=true, and serializing objectref instances in java gives
an exception, saying that root level mapping is required etc.

<binding xmlns:ns1="http://schemas.openehr.org/v1"; name="binding"
package="org.openehr.schemas.v1" trim-whitespace="true">
  <namespace uri="http://schemas.openehr.org/v1"; default="elements"/>
  <mapping class="org.openehr.schemas.v1.CComplexObject" name="CComplexObject">
    <value style="element" name="NodeId" get-method="getNodeId"
set-method="setNodeId"/>
    <value style="element" name="nodeNo" get-method="getNodeNo"
set-method="setNodeNo"/>
  </mapping>
  <mapping abstract="true" type-name="ns1:OBJECT_ID"
class="org.openehr.schemas.v1.OBJECTID">
    <value style="element" name="value" get-method="getValue"
set-method="setValue"/>
  </mapping>
  <mapping abstract="true" type-name="ns1:UID_BASED_ID"
class="org.openehr.schemas.v1.UIDBASEDID">
    <structure map-as="ns1:OBJECT_ID"/>
  </mapping>
  <mapping abstract="true" type-name="ns1:OBJECT_REF"
class="org.openehr.schemas.v1.OBJECTREF">
    <structure map-as="ns1:OBJECT_ID" get-method="getId"
set-method="setId" name="id"/>
    <value style="element" name="namespace" get-method="getNamespace"
set-method="setNamespace"/>
    <value style="element" name="type" get-method="getType"
set-method="setType"/>
  </mapping>
</binding>

This is the binding file which works for me. When I remove the
abstract=true from all classes other than OBJECTID, I get the expected
behaviour.

<binding xmlns:ns1="http://schemas.openehr.org/v1"; name="binding"
package="org.openehr.schemas.v1" trim-whitespace="true">
  <namespace uri="http://schemas.openehr.org/v1"; default="elements"/>
  <mapping class="org.openehr.schemas.v1.CComplexObject" name="CComplexObject">
    <value style="element" name="NodeId" get-method="getNodeId"
set-method="setNodeId"/>
    <value style="element" name="nodeNo" get-method="getNodeNo"
set-method="setNodeNo"/>
  </mapping>
  <mapping factory="org.openehr.schemas.v1.OBJECTID.getObjId"
abstract="true" type-name="ns1:OBJECT_ID"
class="org.openehr.schemas.v1.OBJECTID">
    <value style="element" name="value" get-method="getValue"
set-method="setValue"/>
  </mapping>
  <mapping name="UID_BASED_ID" class="org.openehr.schemas.v1.UIDBASEDID">
    <structure map-as="ns1:OBJECT_ID"/>
  </mapping>
  <mapping name="OBJECT_REF" class="org.openehr.schemas.v1.OBJECTREF">
    <structure map-as="ns1:OBJECT_ID" get-method="getId"
set-method="setId" name="id"/>
    <value style="element" name="namespace" get-method="getNamespace"
set-method="setNamespace"/>
    <value style="element" name="type" get-method="getType"
set-method="setType"/>
  </mapping>
</binding>

Am I doing something wrong here? I'll have to manually fix a large
binding.xml if I can't figure out a way to make codegen create what I
need. I'm also having trouble handling the deserialization of the
field that is subclass of the abstract class, but that is another
issue.

Kind regards
Seref

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to