J'utilise JOX 1.16 pour transformer des chaines en objets JavaBeans,
pour les fichiers XML simple c'est ok, mais j'ai desormais des fichiers
avec des attriuts complexe du style.
J'ai l'impression que cela n'est pas possible, je n'ai que des erreurs
Merci d'avance
Philippe
<MarkTest foo=3D'8' bar=3D\"AAAAAAThis is the bar value\">
<thingies>Moe</thingies> <thingies>Larry</thingies>
<sub age=3D\"35\" name=3D\"Mark\" />
<cell id=3D'1' tdata=3D'0' style=3D 'valeur' langdata=3D'fr' color=3D'green'
>AAA</cell>
<cell id=3D'2' tdata=3D'0' style=3D'valeur' langdata=3D'fr' color=3D'green'
>BBB</cell>
</MarkTest>
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[i]); } }
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[i]); } }
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)
Merci d'avance Philippe
Un exemple simple avec le message d'erreur
String x2=new String("<MarkTest foo='8' bar="AAAAAAThis is
the bar value"><thingies>Moe</thingies> <thingies>Larry</thingies><sub
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[i]);
}
}
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[i]);
}
}
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)
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[i]); } }
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[i]); } }
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)