Badly formed dnd4e save files.

Post/Author/DateTimePost
#1

Blakey

Jul 14, 2010 7:40:13

I am writing a little app which parses the XML of the CB save file.   Mostly it works fine.  However I am able to make the XML badly formed - according to my parser.  If I go into CB and deselect any of the source book options, I note that a load of excess XML gets added to the save file.   Much of this excess XML contains parenthesis inside XML tags and this causes my parser to cough.  We're talking XML like this:


<br />         ID_INTERNAL_CLASS_FEATURE_PROTECTOR_SPIRIT_(HYBRID) /&gt;<br />         ID_INTERNAL_CLASS_FEATURE_STALKER_SPIRIT_(HYBRID) /&gt;<br />         ID_INTERNAL_CLASS_FEATURE_STAR_PACT_(HYBRID) /&gt;<br />         ID_INTERNAL_CLASS_FEATURE_FEY_PACT_(HYBRID) /&gt;<br />         ID_INTERNAL_CLASS_FEATURE_INFERNAL_PACT_(HYBRID) /&gt;<br />         ID_INTERNAL_CLASS_FEATURE_DARK_PACT_(HYBRID) /&gt;<br />         ID_INTERNAL_CLASS_FEATURE_VESTIGE_PACT_(HYBRID) /&gt;<br />
                 


I'm parsing the XML save files using this java code:



private void parseXML(File file) {
   // get the factory
   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   try {
       // Using factory get an instance of document builder
       DocumentBuilder db = dbf.newDocumentBuilder();
       // parse using builder to get DOM representation of the XML file
       myDom = db.parse(file.toString());
   } catch (ParserConfigurationException pce) {
       pce.printStackTrace();
   } catch (SAXException se) {
       se.printStackTrace();
   } catch (IOException ioe) {
       ioe.printStackTrace();
   }
}

This is a standard DOM parsing class off the net, not something I've written myself. 


Any ideas what I can do about this?


Cheers
Blakey

#2

Kaviyd3

Jul 20, 2010 12:14:36
The example you showed is missing the initial "<" characters -- they are badly formed because the "/>" sequences are not paired with any "<".  Maybe there is a bug in the code you received that strips off that initial "<".  You need code that does not do that.

As to what those strings do -- they are lists of prohibited character elements from your character's campaign file.
#3

Blakey

Jul 21, 2010 2:05:12
The example you showed is missing the initial "<" characters -- they are badly formed because the "/>" sequences are not paired with any "<".  Maybe there is a bug in the code you received that strips off that initial "<".  You need code that does not do that.

As to what those strings do -- they are lists of prohibited character elements from your character's campaign file.



Thanks for the reply.

Yeah, I know those quotes don't have the starting "<" character on them.  I can't get the forum to accept 'proper XML' - there doesn't seem to be a "code" tag on this forum.  So if you assume there XML is tagged up correctly (which it is), then can you explain why my DOM parser doesn't like the code?

I think it's not happy about the parenthesis.

Cheers
Blakey