JOX and attribut problem

Discussion in 'Java' started by pcouas, Jan 22, 2007.

  1. pcouas

    pcouas Guest

    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>
    <sub age=\"35\" name=\"Mark\" />
    <cell id='1' tdata='0' style= 'valeur' langdata='fr' color='green'
    >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
    pcouas, Jan 22, 2007
    #1
    1. Advertising

  2. pcouas

    pcouas Guest

    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
    pcouas, Jan 22, 2007
    #2
    1. Advertising

  3. pcouas

    pcouas Guest

    i have resolved problem
    pcouas, Jan 22, 2007
    #3
  4. pcouas

    Lew Guest

    pcouas wrote:
    > i have resolved problem


    Care to share the solution?

    - Lew
    Lew, Jan 22, 2007
    #4
  5. pcouas

    pcouas Guest

    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);
    }
    }
    pcouas, Jan 23, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. khaled Hajjar
    Replies:
    5
    Views:
    410
    Patrick TJ McPhee
    Oct 19, 2003
  2. hp_

    variable and attribut

    hp_, Sep 13, 2004, in forum: XML
    Replies:
    3
    Views:
    417
  3. Replies:
    9
    Views:
    420
  4. Tony Johansson

    reference attribut

    Tony Johansson, Aug 12, 2005, in forum: C++
    Replies:
    4
    Views:
    347
    Adrian
    Aug 12, 2005
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    543
    Bullschmidt
    May 11, 2004
Loading...

Share This Page