jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-257

XML tags with underscores cannot be matched to classes

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.2
  • Component/s: None
  • Labels:
    None
  • JDK version and platform:
    Sun 1.4.2_01 on Suse Linux 10.0

Description

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

Issue Links

is depended upon by

Task - A task that needs to be done. XSTR-317 XStream 1.2 release coordination.

  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Henrik Winther Jensen added a comment - 23/Nov/05 6: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);

Show
Henrik Winther Jensen added a comment - 23/Nov/05 6: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);
Hide
Permalink
Mauro Talevi added a comment - 23/Nov/05 7: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

Show
Mauro Talevi added a comment - 23/Nov/05 7: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
Hide
Permalink
Guilherme Silveira added a comment - 29/Jul/06 10:18 AM

Tested and marked as resolved on 1.2 release.

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

People

  • Assignee:
    Unassigned
    Reporter:
    Henrik Winther Jensen
Vote (0)
Watch (1)

Dates

  • Created:
    23/Nov/05 6:31 AM
    Updated:
    07/Aug/06 9:17 PM
    Resolved:
    29/Jul/06 10:18 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.