Jump to content
XCOMUFO & Xenocide

Xerces


Beetle

Recommended Posts

Why do we have xercesc::XMLPlatformUtils::Initialize(); and Terminate(); in xnetloader.cpp ???

Don't we should move it to xenocideapp initialization ???

 

Sorry if my question is stupid, but i'm new to xerces. :Help:

 

Greetings,

Beetle

Link to comment
Share on other sites

Hi,

 

actually, you right that it doesn't belong there. The newer loaders use XmlUtility (which in turn will soon be replaced by Guyver's XMLManager), but if you need to write a loader yourself, use XmlUtility, switching to the XMLManager is easy from there.

Take a look at StaticData/CraftType for pointers.

 

Also someone will have to eventually port the XNetLoader to the new stuff but I would wait with that until the XMLManager is ready.

 

Rincewind

Edited by rincewind
Link to comment
Share on other sites

I did it.

 

XmlManager is in repository. You can see how it'll be used looking at xenotest module.

 

There's an issue with it. It doesn't see schema files. XmlManager uses ogre's DataStream to load xml file, but then, during parsing parser requires schema file which is defined. I don't know how to make it use schemas with ogre's DataStream (which abstracts access to normal files as well as zipped files), or I need to "upload" that schema before parsing.

 

Guyver

 

EDIT: ps. working with Xerces is pain in a**. Everytime I'm starting to write some XML code I'm ending being frustrated debugging really wierd exceptions xerces throws...

Edited by guyver6
Link to comment
Share on other sites

I'm in doubt how to implement that schema validation, so I want those of you interested in XML to tell me what is the better way.

 

First option: XML schema filename is being passed as an parameter during resource creation. That way you can parse XML without validation (which is faster, and not needed when file is program-generated - IMHO only XML files created by people need validation, programs are predictable :) ).

 

Second option: load all XML schemas to parser at the begining. This is doable, but I don't know how it's gonna work and how to do it, but it's possible.

 

Third option: you have to manually load xml schema before parsing files that use this schema. This should be pretty easy to implement.

 

So, now I'm waiting for suggestions, and I'm going back to work on Shed, a project yet to be announced, but I hope really helpful for lots of us :) And totally in C#.

 

Greetings,

Guyver

 

PS. After some debugging, I'm happy with xerces :)

Link to comment
Share on other sites

I'm in doubt how to implement that schema validation, so I want those of you interested in XML to tell me what is the better way.

 

First option: XML schema filename is being passed as an parameter during resource creation. That way you can parse XML without validation (which is faster, and not needed when file is program-generated - IMHO only XML files created by people need validation, programs are predictable :) ).

 

Second option: load all XML schemas to parser at the begining. This is doable, but I don't know how it's gonna work and how to do it, but it's possible.

 

Third option: you have to manually load xml schema before parsing files that use this schema. This should be pretty easy to implement.

 

So, now I'm waiting for suggestions, and I'm going back to work on Shed, a project yet to be announced, but I hope really helpful for lots of us :) And totally in C#.

 

Greetings,

Guyver

 

PS. After some debugging, I'm happy with xerces :)

 

Going without validation is not really an option as you don't get type information when validation is not enabled and some of our files need those in order to be read into the runtime structures (for example CraftType).

 

If possible, I think the second option is the most user friendly, but I think the third one would work, too.

 

Rincewind

Link to comment
Share on other sites

  • 2 weeks later...

I have ported XNetLoader to XmlManager. I can't test it yet, cuz I wanted to port one more thing (one of the static data loaders).

 

Here's my question: maybe instead of growing namespace hierarchy (now static data is in Xenocide::Common::StaticData) we could flatten it a little so it becomes Xenocide::StaticData?

 

Btw, I see very bad looking code. It's working but is ugly, hard to read by another programmer :Coffee: like me in example ^_^. Going through XNetLoader code was a really painful experiance, but I corrected lots of what was there wrong to comply with coding convention from wiki. Maybe we should enforce some standards before commits? Review system? :unsure:

 

Oh, another thought. You could look at DOMNodeIterator and DOMTreeWalker and how the iterator is being used in XNetLoader. Can be useful, since writting a filter ain't that hard, right? :)

 

Guyver

Edited by guyver6
Link to comment
Share on other sites

I added some code formatting suggestions to Wiki. That XNetLoader I ported needs a little fixing in naming, but most of dirty work reformatting is done and made it readable at last.

 

I'm commiting changes made to XNetLoader, HumanFacilityType (little change to make it use XmlManager instead of XmlUtility), and XNet. It's too late here so I'll correct any errors at the morning.

 

Edit: It's commited. G'nite

 

Guyver

Edited by guyver6
Link to comment
Share on other sites

×
×
  • Create New...