History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-257
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Henrik Winther Jensen
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XStream

XML tags with underscores cannot be matched to classes

Created: 23/Nov/05 06:31 AM   Updated: 07/Aug/06 09:17 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2

Issue Links:
dependent
 

JDK version and platform: Sun 1.4.2_01 on Suse Linux 10.0


 Description  « Hide
If there is a tag in the XML file, say: Date_Time this seems to be impossble to make it match an object. I get:

com.thoughtworks.xstream.converters.ConversionException: Date_Time : Date_Time
---- Debugging information ----
required-type : Flowsync$Export
cause-message : Date_Time : Date_Time
class : Flowsync$Dataroot
message : Date_Time : Date_Time
line number : 6
path : /dataroot/Export/Date_Time
cause-exception : com.thoughtworks.xstream.alias.CannotResolveClassException

No matter what i try.

Kind regards
Henrik



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Henrik Winther Jensen - 23/Nov/05 06:38 AM
Maybe the XML file that causes the problem could be helpfull:

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata">
<Export>
<Manufacturer>PEUGEOT</Manufacturer>
<AXCode>B 08</AXCode>
<Date_Time>2005-11-18T15:27:22</Date_Time>
<Model>1007</Model>
<Edition>01/0</Edition>
<New>N</New>
<Body_Style>Sedan</Body_Style>
<Body_Code>Pass.Car</Body_Code>
<WTBplanned>2005-08-10T00:00:00</WTBplanned>
<DeliverytoEC>2005-08-25T00:00:00</DeliverytoEC>
<Compl>15.06.2005</Compl>
<Stups>2005-06-18T00:00:00</Stups>
</Export>
</dataroot>

The code:

class Export
{
String date_Time=null;
String AX_Code =null;
String manufacturer=null;
String model=null;
String edition=null;
String newx=null;
String body_Style=null;
String body_Code=null;
String wTBplanned=null;
String deliverytoEC=null;
String compl=null;
String stups=null;

public String getDate_Time()

{ return date_Time; }

public void setDate_Time(String date_Time)

{ this.date_Time = date_Time; }

public String getAXCode()

{ return AX_Code; }

public void setAXCode(String AX_Code)

{ this.AX_Code = AX_Code; }

public String getManufacturer()

{ return manufacturer; }

public void setManufacturer(String manufacturer)

{ this.manufacturer = manufacturer; }

public String getModel()

{ return model; }

public void setModel(String model)

{ this.model = model; }

public String getEdition()

{ return edition; }

public void setEdition(String edition)

{ this.edition = edition; }

public String getNewx()

{ return newx; }

public void setNewx(String newx)

{ this.newx = newx; }

public String getBody_Style()

{ return body_Style; }

public void setBody_Style(String body_Style)

{ this.body_Style = body_Style; }

public String getBody_Code()

{ return body_Code; }

public void setBody_Code(String body_Code)

{ this.body_Code = body_Code; }

public String getwTBplanned()

{ return wTBplanned; }

public void setwTBplanned(String wTBplanned)

{ this.wTBplanned = wTBplanned; }

public String getDeliverytoEC()

{ return deliverytoEC; }

public void setDeliverytoEC(String deliverytoEC)

{ this.deliverytoEC = deliverytoEC; }

public String getCompl()

{ return compl; }

public void setCompl(String compl)

{ this.compl = compl; }

public String getStups()

{ return stups; }

public void setStups(String stups)

{ this.stups = stups; }

}

class Dataroot
{
ArrayList export=null;
public Dataroot()

{ new ArrayList(); }

}

public void readDe() throws Exception
{
XStream xstream = new XStream();
xstream.alias("dataroot",Dataroot.class);
xstream.alias("Export",Export.class);
xstream.alias("Manufacturer",String.class);
xstream.alias("AXCode",String.class);
File file = new File("./x.xml");
Reader r=new FileReader(file);
Dataroot dc = (Dataroot)xstream.fromXML(r);


Mauro Talevi - 23/Nov/05 07:21 AM
You can use field aliases as a workaround as detailed in
https://svn.codehaus.org/xstream/trunk/xstream/src/test/com/thoughtworks/xstream/XStreamTest.java

The general issue is being tracked via XSTR-252


Guilherme Silveira - 29/Jul/06 10:18 AM
Tested and marked as resolved on 1.2 release.