Okay, I'll check this out later today and fix the problem before doing a release. The code generation for items in a collection goes through different paths from that for items outside collections, and it sounds like there's a problem doing the map-as to a type-name in that case.

 - Dennis

Mocky Habeeb wrote:

I had been using RC1 but I just tried it with CVS version and I seem to
get the same error in both versions in all cases:
        1) my original code
        2) original + item-type="Pair" on the collections
        3) original + type="Pair" on the structures
        4) both 2 and 3 together

Mocky



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dennis
Sosnoski
Sent: Monday, September 12, 2005 5:23 PM
To: [email protected]
Subject: Re: [jibx-users] Multiple Abstract mappings for a class


Looks like a bug, Mocky - I'll try to duplicate this and make sure it's fixed. Is this with CVS code or RC1? I did find and correct a couple more bugs in the course of doing the tutorial, though this doesn't look like one.

What *should* happen according to the documentation is that you get an error to the effect that you're trying to use an Object as a Pair. The map-as requires that the working type of the object can be assigned to the type associated with the mapping. If you add either item-type="Pair"

on the <collection> elements, or type="Pair" on the <structure map-as="..."/> element, this should work. I'll add a note on the working

type vs. mapping type to the new tutorial, too.

 - Dennis

Mocky Habeeb wrote:

I'm using a class named 'Pair' which has 2 Strings, a name and a value.

I want to map it to more than one set of XML structures something like
this:

<Response>
  <UserProfile>
      <GenericAssociation>
          <value>IRCMXH</value>
          <key>User_ID</key>
      </GenericAssociation>
      <GenericAssociation>
          <value>Habeeb/Mocky</value>
          <key>User_Name</key>
      </GenericAssociation>
  </UserProfile>
  <ReturnObject>
      <DataElements>
          <ObjectDataAttribute>
              <name>Record_ID</name>
              <value>00584259548</value>
          </ObjectDataAttribute>
          <ObjectDataAttribute>
              <name>Action_Taken</name>
              <value>Cancelled</value>
          </ObjectDataAttribute>
      </DataElements>
  </ReturnObject>
</Response>

Where each 'GenericAssociation' would be a Pair, and also each 'ObjectDataAttribute' eventhough one has name/value and the other has value/key. To do this I created 2 abstract mappings for class Pair, one

named 'value-key-pair' and the other named 'name-value-pair', like this:

<binding direction="both" > <mapping name="Response" class="AuthResponse">
      <structure field="response" map-as="standard-response"/>
  </mapping>
<mapping abstract="true" class="ServerResponse" type-name="standard-response"> <collection name="UserProfile" field="profileValues" usage="optional"> <structure name="GenericAssociation" map-as="value-key-pair"/>
      </collection>
      <structure name="ReturnObject">
<collection name="DataElements" field="dataValues" usage="optional"> <structure name="ObjectDataAttribute" map-as="name-value-pair"/>
          </collection>
      </structure>
  </mapping>
<mapping abstract="true" class="Pair" type-name="value-key-pair" value-style="element">
      <value name="value" field="value"/>
      <value name="key" field="name"/>
  </mapping>
<mapping abstract="true" class="Pair" type-name="name-value-pair" value-style="element">
      <value name="name" field="name"/>
      <value name="value" field="value"/>
  </mapping>
</binding>

However the binding compiler gives me the following error when direction is both (it works fine for direction="input"):

*** Error during code generation - please report this error on the JiBX

users list so that the condition can be caught during validation ***

java.lang.RuntimeException: Internal error: Attempting to compare types

Pair and value-key-pair
at org.jibx.binding.classes.MethodBuilder.verifyCompatible(MethodBuilder.j
a
va:400)
      at
org.jibx.binding.classes.MethodBuilder.verifyCallStack(MethodBuilder.ja
v
a:495)
      at
org.jibx.binding.classes.MethodBuilder.appendCallVirtual(MethodBuilder.
j
ava:852)
      at
org.jibx.binding.def.ObjectBinding.genMarshalCall(ObjectBinding.java:55
1
)
      at
org.jibx.binding.def.ObjectBinding.genMarshalContentCall(ObjectBinding.
j
ava:866)
      at
org.jibx.binding.def.ObjectBinding.genContentMarshal(ObjectBinding.java
:
910)
      at
org.jibx.binding.def.ComponentProperty.genContentMarshal(ComponentPrope
r
ty.java:279)
      at
org.jibx.binding.def.ElementWrapper.genContentMarshal(ElementWrapper.ja
v
a:380)
      at
org.jibx.binding.def.PassThroughComponent.genContentMarshal(PassThrough
C
omponent.java:116)

Any suggestions? My java code is below.

Mocky


public class AuthResponse {
  private ServerResponse response;

  public String toString() {
      return response.toString();
  }

  public static void main(String[] argz) {

     IBindingFactory bfact = null;
     IUnmarshallingContext uctx = null;
     Object result = null;
try { bfact = BindingDirectory.getFactory(ServerResponse.class);
         uctx = bfact.createUnmarshallingContext();
result = uctx.unmarshalDocument(new FileInputStream("soap.xml"), null);
         System.out.println(result);
     } catch (Exception e) { e.printStackTrace();}
 }

}
public class Pair {
  private String name;
  private String value;
public String toString() {
      return "Pair(" + name + ", " + value + ")";
  }
}
public class ServerResponse {
  private ArrayList profileValues;
  private ArrayList dataValues;
public String toString() { return "ServerResponse:{profile: " + profileValues + ", data:" + dataValues + "}";
  }
}




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams *

Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users





-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices Agile & Plan-Driven Development * Managing Projects & Teams *
Testing & QA Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to