|
From: mamutas <mam...@ho...> - 2004-03-19 21:44:52
|
I think it would depends on how are we going to use the parser. I imagine it similar to following: For each XML file we would have, there would be a processing class written. Let take for example, technology tree. The class XMLTechTreeLoader will be the intermediate class between the rest of the game code and the Xerces. The class will use Xerces to read, parse, validate, etc. the XML file. The class will load the whole file data into memory in DOM structure. To do that the class should not really use many Xerces methods as I imagine: few methods to initialize and set parameters, then very few methods to initiate reading and creating of the DOM. The same class will expose set of methods to access the data from the DOM, which will be used by the rest of the game. Here some more Xerces methods will be used, but all in the same form. It would be possible to write a wrapper method for data retrieval calls, so all Xerces methods will be located in one place. There are some pros and cons about that approach. Cons: - There will be as many intermediate classes as many XML files. - If XML file will be changed, the intermediate class will need to be update to expose additional interfaces. Pros: - Only one class will deal with Xerces for a given XML file. What are your suggestions? Regards, mamutas ----- Original Message ----- From: "Christopher C. Phillips" <chr...@sb...> To: <xen...@li...> Cc: "mamutas" <mam...@ho...> Sent: Thursday, March 18, 2004 10:49 PM Subject: Re: [Xenocide-programming] XML interface > > It would be what you describe, but for two reasons. > > 1. To hide the complexity of parsing our XML files. Basically we just send it > to an XMLParse() type function, and get back some type of data structure. > I'm not really sure what the best way to return the parsed data would be, but > I think we could come up with something sensible. > > 2. I think it's dangerous to have such a major dependency on the XML > libraries. Some such dependencies (like Ogre) can't be avoided, but I think > it would be best to allow us to be able to swap XML libraries. That way if > Xerces (or any library) becomes so outdated that it won't even compile (could > definitely see that happening, then we can just write a new Parser class and > we're not SOL. Imagine having to sift through all the code and change how > the parsing is done. *shudder* > > -Chrisp |