Answering my own question again...

I'm a bit further along;

I now have :

binding :

<binding>

<mapping name="a" class="A">
<collection name="bs" set-method="setBs" get-method="getBs" item-type="B"/>
<value name="c" set-method="setC" get-method="getC" usage="optional"/>
</mapping>


 <mapping name="b" class="B">
 </mapping>

 <mapping name="c" class="C">
 </mapping>

</binding>

classes :

public class A
{
 public A(){}

 protected ArrayList _bs=new ArrayList();
 public void setBs(ArrayList bs){_bs=bs;}
 public ArrayList getBs(){return _bs;}

 protected C _c=new C();
 public void setC(C c){_c=c;}
 public C getC(){return _c;}
}

public class B
{
 protected String _value="";
 public B(){}
 public B(String value){_value=value;}
 public String toString(){return _value;}
}

public class C
{
 protected String _value="";
 public C(){}
 public C(String value){_value=value;}
 public String toString(){return _value;}
}

input :

 <a>
   <bs>
     <b>foo</b>
     <b>bar</b>
     <b>baz</b>
   </bs>
   <c>faz</c>
 </a>

and output :

<a>
 <bs>
   <b/>
   <b/>
   <b/>
 </bs>
 <c>faz</c>
</a>

!!!

so, you see - I have string elements working outside a collection, but not inside :-(

am I on the right track ?

cheers,

Jules

P.S. I'm using JiBX bet3c, Sun 1.4.1_05


Jules Gosnell wrote:


The classes to which I am binding have fields that contain String arrays,

I am trying to sort out how best to represent them :

class A
{
   ArrayList getBs();
   setBs(ArrayList);
}

I would like to map this to perhaps e.g. ;


<a> <bs> <b>foo</b> <b>bar</b> <b>baz</b> </bs> </a>

Should be quite simple - I thought, and happily wrote a binding e.g. :

<binding>

<mapping name="a" class="A">
<collection name="bs" set-method="setBs" get-method="getBs" item-type="java.lang.String"/>
</mapping>


 <mapping name="b" class="java.lang.String">
 </mapping>

</binding>

roundtripping the document (no errors) returned :

<a>
 <bs>
   <b/>
   <b/>
   <b/>
 </bs>
</a>

Then I realised that I had made a slight leap of faith, and that I actually had no idea how to bind the content of the <b/>s to the value of the Strings...

I've looked through the doc for a similar usecase but...

Does JiBX support mapping of a simple element such as <b>foo</b> to a String - how can I accomplish this - or am I going about it the wrong way - any suggestions ?

Thanks for your time,


Jules



-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users




-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to