I don't seem to be making a duplicate post, so here's the details...
When I parse the document using the non-static method Builder.build() from XOM (XML Object Model, a Java library), in the Eclipse console I get:
[Fatal Error] :1:1: Premature end of file.
This is a severe problem, that forcibly halts the operation of the program.
The contents of the method I'm using is the following...
public boolean buildDocument() {
boolean out = true;
Builder b = null;
b = new Builder();
String xml = "";
String newXml = "";
StringBuilder xmlSb = new StringBuilder();
URL xmlUrl = null;
try {
xmlUrl = new URL(this.packAddr);
} catch (MalformedURLException e1) {
Pcdl.log.severe(e1.getMessage());
out = false;
}
InputStream is;
try {
is = xmlUrl.openStream();
while (is.available() > 0) {
xmlSb.append(is.read());
}
} catch (IOException e1) {
e1.printStackTrace();
Pcdl.log.severe(e1.getMessage());
out = false;
}
xml = xmlSb.toString();
// Add more lines if needed. I hope that nobody actually had to use any XML entities.
newXml = Util.removeUTF8BOM(xml)
.replace("&", "&")
;
Pcdl.log.info("XML Data Size: " + newXml.length() + " B.");
System.out.println(newXml);
// Actually build it.
try {
this.doc = b.build(new ByteArrayInputStream(newXml.getBytes("UTF-8")));
} catch (ParsingException | IOException e) {
Pcdl.log.severe("Document build error: " + e.getMessage());
System.out.println(e.getMessage());
out = false;
}
System.out.println(this.doc);
return out;
}
I have the entire program on a GitHub repository: "http://github.com/Treyzania/PraseocraftDL/". If you wish to contribute to this project in any way, please do! Just make a fork, and I'll see what's in it.
This method is from "com.treyzania.praseocraft.ftb.downloader.PackFile". I know my package names are very long, but it's too late to change them now. The project I am working on is a program to take the XML document (EXAMPLE: http://pastebin.com/raw.php?i=B42in4c5 ), and compile it into a Minecraft modpack in %appdata%/.mc-pcdl/packs/ (or similar), and edit a few other files to properly register the data with the Minecraft Launcher. I'm trying to keep this project as abstract as possible, so it may look like there are more classes than necessary. I'm also trying as many things as I can to fix this myself. None are working.