JOX and attribut problem

P

pcouas

Hi,

I use Jox 1.16 to map XML flow with JavaBean since two year, but now i
need to add complex attribut to my XML flow and i have error message,
could i make it with Jox ?

Regards
Philippe

My sample
<MarkTest foo='8' bar=\"AAAAAAThis is the bar value\">
<thingies>Moe</thingies> <thingies>Larry</thingies>
AAA</cell>
<cell id='2' tdata='0' style='valeur' langdata='fr' color='green'
BBB</cell>
</MarkTest >

And

<table>
<row tdata='0'><cell chp='0'>Quantité</cell><cell
chp='1'>Prix%20unitaire</cell><cell chp='2'>Total</cell></row>
<row tdata='2'><cell chp='0'>5</cell><cell
chp='1'>10.00</cell><cell chp='2'>50.00</cell></row>
</table>

Regards
Philippe
 
P

pcouas

An example with error message

String x2=new String("<MarkTest foo='8' bar=\"AAAAAAThis is
the bar value\"><thingies>Moe</thingies> <thingies>Larry</thingies><sub
age=\"35\" name=\"Mark\"> </sub> </MarkTest>");
TestBean2 testBean2=
(TestBean2)BeanXMLMapping.fromXML(x2,TestBean2.class);
System.out.println("TEST2");
System.out.println("foo "+testBean2.getFoo());
System.out.println("bar "+testBean2.getBar());

import util.xml.jox.*;
import java.util.*;

public class TestBean2 implements java.io.Serializable
{
protected int foo;
protected String bar;
protected Vector thingies;
protected Vector subbean;

public TestBean2()
{
bar = "";
//baz = new Date();
thingies = new Vector();
}

public int getFoo() { return foo; }
public void setFoo(int aFoo) { foo = aFoo; }

public String getBar() { return bar; }
public void setBar(String aBar) { bar = aBar; }

public TestSubbean []getSub() {

TestSubbean[] tretThingies = new TestSubbean[subbean.size()];
if (subbean.size() > 0) subbean.copyInto(tretThingies);
return tretThingies;
}

public void setSub(TestSubbean[] aSub) {
thingies = new Vector(aSub.length);
for (int i=0; i < aSub.length; i++)
{
subbean.addElement(aSub);
}
}

public String[] getThingies()
{
String[] retThingies = new String[thingies.size()];
if (thingies.size() > 0) thingies.copyInto(retThingies);

return retThingies;
}

public void setThingies(String[] newThingies)
{
thingies = new Vector(newThingies.length);
for (int i=0; i < newThingies.length; i++)
{
thingies.addElement(newThingies);
}
}

public String getThingies(int i)
{
return (String) thingies.elementAt(i);
}

public void setThingies(int i, String thingy)
{
thingies.setElementAt(thingy, i);
}
}

java.io.IOException: Error parsing XML document:
java.lang.reflect.InvocationTargetException
at util.xml.jox.JOXSAXBeanInput.readObject(JOXSAXBeanInput.java:166)
at
util.xml.jox.JOXBeanInputStream.readObject(JOXBeanInputStream.java:96)
at util.xml.jox.BeanXMLMapping.fromXML(BeanXMLMapping.java:34)
at TestAttrDeser.main(TestAttrDeser.java:46)


Regards
Philippe
 
P

pcouas

Threre was error into my object

Philippe
String x2=new String("<MarkTest foo='82' bar=\"AAAAAAThis
is the bar value\"><thingies>Moe</thingies>
<thingies>Larry</thingies><sub age=\"36\" name=\"dddd\" /><sub
age=\"35\" name=\"Mark\" /> </MarkTest>");
TestBean2 testBean2=
(TestBean2)BeanXMLMapping.fromXML(x2,TestBean2.class);


import util.xml.jox.*;
import java.util.*;

public class TestBean2 implements java.io.Serializable
{
protected int foo;
protected String bar;
protected Vector thingies;
protected Vector subbean;

public TestBean2()
{
bar = "";
thingies = new Vector();
}

public int getFoo() { return foo; }
public void setFoo(int aFoo) { foo = aFoo; }

public String getBar() { return bar; }
public void setBar(String aBar) { bar = aBar; }


public TestSubbean[] getSub()
{
TestSubbean[] retSubbeans = new TestSubbean[subbean.size()];
if (subbean.size() > 0) subbean.copyInto(retSubbeans);

return retSubbeans;
}

public void setSub(TestSubbean[] newSubbeans)
{
subbean= new Vector(newSubbeans.length);
for (int i=0; i < newSubbeans.length; i++)
{
subbean.addElement(newSubbeans);
}
}

public String[] getThingies()
{
String[] retThingies = new String[thingies.size()];
if (thingies.size() > 0) thingies.copyInto(retThingies);

return retThingies;
}


public TestSubbean getSub(int i) {

return (TestSubbean)subbean.elementAt(i);
}

public void setSub(TestSubbean aSub) {
subbean.addElement(aSub);
}


public void setThingies(String[] newThingies)
{
thingies = new Vector(newThingies.length);
for (int i=0; i < newThingies.length; i++)
{
thingies.addElement(newThingies);
}
}

public String getThingies(int i)
{
return (String) thingies.elementAt(i);
}

public void setThingies(int i, String thingy)
{
thingies.setElementAt(thingy, i);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top