The solution I've come up with is to subclass Reader to patch my invalid xml
files. I create a mapping for <data_list> (even though my files only contain
<data> elements) and when unmarshalling I pass an instance of the following
DataReader class to unmarshallDocument(). Is this is a good or bad idea?
import java.io.Reader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.StringReader;
public class DataReader extends Reader {
private final StringReader START_READER = new StringReader("<data_list>");
private final StringReader END_READER = new StringReader("</data_list>");
private InputStreamReader isr;
public TrackingDataReader(InputStreamReader isr) {
this.isr = isr;
}
public int read(char[] cbuf, int off, int len) throws IOException {
int retval = START_READER.read(cbuf, off, len);
if (retval == -1) {
retval = isr.read(cbuf, off, len);
}
if (retval == -1) {
retval = END_READER.read(cbuf, off, len);
}
return retval;
}
public void close() throws IOException {
}
}
----- Original Message ----
From: netb0y <[EMAIL PROTECTED]>
To: jibxusers <[email protected]>
Sent: Saturday, April 7, 2007 1:13:53 AM
Subject: [jibx-users] No Root Element
I am working with xml files that do not have a root element. Basically I have
files that look like the following:
----------------start-file----------------
<data>
<something></something>
</data>
<data>
<something></something>
</data>
<data>
<something></something>
</data>
-----------------end-file-----------------
I've been trying to unmarshall all the <data> objects from this type of file
but have not figured out how to do it. Is it possibly to unmarshall a file like
this? The unmarshallDocument(reader) method successfully returns the first
<data> object within the file. How can I get the rest of the <data> objects?
Thanks,
Chris
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users
____________________________________________________________________________________
Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users