Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JOX and attribut problem

Reply
Thread Tools

JOX and attribut problem

 
 
pcouas
Guest
Posts: n/a
 
      01-22-2007
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

 
Reply With Quote
 
 
 
 
pcouas
Guest
Posts: n/a
 
      01-22-2007
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.cla ss);
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[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(JOXSAXBean Input.java:166)
at
util.xml.jox.JOXBeanInputStream.readObject(JOXBean InputStream.java:96)
at util.xml.jox.BeanXMLMapping.fromXML(BeanXMLMapping .java:34)
at TestAttrDeser.main(TestAttrDeser.java:46)


Regards
Philippe

 
Reply With Quote
 
 
 
 
pcouas
Guest
Posts: n/a
 
      01-22-2007
i have resolved problem

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      01-22-2007
pcouas wrote:
> i have resolved problem


Care to share the solution?

- Lew
 
Reply With Quote
 
pcouas
Guest
Posts: n/a
 
      01-23-2007
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.cla ss);


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[i]);
}
}

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[i]);
}
}

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

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tag or attribut for correct Image-size klausklausenator@googlemail.com HTML 9 09-16-2006 10:24 AM
reference attribut Tony Johansson C++ 4 08-12-2005 04:55 PM
Seeking Movie "Robot Jox" Charlie Sapp DVD Video 1 05-04-2005 01:40 AM
variable and attribut hp_ XML 3 09-14-2004 06:43 AM
Counting an elment where its attribut equals to true khaled Hajjar XML 5 10-19-2003 10:07 PM



Advertisments