hi all,

using the class SchemaGenerator on my classes with my mapping gives me the wrong schema. The core problem is the way SchemaGenerator generates the schema for a structure element using the map-as attribute. Schemagenerator encapsulate the element into another complextype. This is then contradictory with the xml the marshall method returns.

Basically I have a Song that has an artist:

------ MAPPING FILE --------

 <mapping name="artist" class="ID3Artist">
   <value name="id" set-method="setId" get-method="getId"/>
   <value name="name" set-method="setName" get-method="getName"/>
 </mapping>

 <mapping name="song" class="Song">
   <structure set-method="setArtist" get-method="getArtist"
                map-as="ID3Artist"/>
 </mapping>


------ GENERATED XSD FILE --------
Schema gen gives me the following schema

  <element name="artist">
    <complexType>
      <sequence>
        <element name="id" type="xsd:string"/>
        <element name="name" type="xsd:string"/>
      </sequence>
    </complexType>
  </element>

  <element name="song">
    <complexType>
      <sequence>
        <element name="artist">
          <complexType>
            <sequence>
              <element ref="tns:artist"/>
            </sequence>
          </complexType>
        </element>
      </sequence>
    </complexType>
  </element>

The problem here is that schemagenerator encapsulate <element ref="tns:artist"/> into a complex type.
the marshalling returns the following xml:

------ MARSHALLING RESULT --------

<ns1:song>
  <ns1:artist>
    <ns1:id>artistid</ns1:id>
    <ns1:name>artistname</ns1:name>
  </ns1:artist>
</ns1:song>


------ DESIRED XSD FILE --------
I believe this is what the xsd should look like.

  <element name="song">
        <complexType>
          <sequence>
            <element ref="tns:artist"/>
          </sequence>
        </complexType>
  </element>


As a temporary solution, I'm implementing my own version of SchemaGenerator. Though I might break the schema for other use cases. Looking on the web, I've seen example where the xsd generation was done right. Maybe it's only the latest Jibx build that has a problem.

Thanks

Thibaut Lamadon






-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to