Page 1 of 1
XSD, XML and C++
Posted: Mon Feb 28, 2011 10:39 am
by MadPumpkin
I need some help or direction on where I might find how to write an XSD file for use with my game and XML. I've googled lots of things like this but I have no idea where to learn more, most things are "XML for beginners" notes/tutorials. I will be using XML for my sprite animations (along with lua), map formats, character saves and design layouts, so any help would be greatly appreciated.
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 12:06 pm
by N64vSNES
I've only started looking into XML since yesterday. But I thought the point of XML was just a format that anybody can create and parse through it however they pleased? I could be horribly wrong though.....
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 12:29 pm
by MadPumpkin
N64vSNES wrote:I've only started looking into XML since yesterday. But I thought the point of XML was just a format that anybody can create and parse through it however they pleased? I could be horribly wrong though.....
Oh no, that's definitely correct, but the thing is that an XSD file is what tells the XML file what each tag that you place in the XML is actually supposed to be, it's like altering HTML to your liking for example. (but much different) Look up XSD.
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 1:49 pm
by TheBuzzSaw
I'll just come out and say it: XSD and DTD are wastes of time for game development. It makes sense to have some kind of schema to verify the XML if you are attempting to publish some mega-national standard, but if you're just coming up with your own home-grown XML format, just have the C++ verify it. Seriously, there are not many good validation tools, and you won't really gain anything by having a matching schema anyway. The instant you lock the schema in place, you'll want to make a change and not be in the mood to change the schema to match.
I obviously cannot speak for everyone, but of the places I have worked, they pretty much all gave up on schema maintenance. "Oh, it's like 4 years old. Don't bother." It is definitely worth your while to document what the XML should define and how it should be structured, but I would not go much beyond using a simple DTD.
If you're doing this just for the sake of learning/practicing XSD, well, disregard much of what I said. I'm just trying to point out that they really don't add much.
It is ironic you brought this up because I literally started using XML + Lua for my 2D animations last night. I briefly considered using a schema but instantly stopped due to how rapidly my spec was changing based on my needs. If you want to know more, I can teach you a few things. I also have a massive XML reference book on my shelf. ^_^
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 2:49 pm
by MadPumpkin
TheBuzzSaw wrote:. . .
It is ironic you brought this up because I literally started using XML + Lua for my 2D animations last night. I briefly considered using a schema but instantly stopped due to how rapidly my spec was changing based on my needs. If you want to know more, I can teach you a few things. I also have a massive XML reference book on my shelf. ^_^
Alright! Thanks for all your help, what way would you suggest having C++ verify the tags and what have you? Also how do you use Lua with XML for your animations? For me it was mostly an idea and a plan not that I actually know how yet so haha :P any helps appreciated.
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 3:02 pm
by TheBuzzSaw
I have C++ "verify" the XML by simply explicitly hunting for tags. I don't just parse through linearly and read the string; I tell my code to search specifically for the "sprite" tag and then the "animation" tag and so on. If I ever fail a search, I report an error. It's that simple.
Lua itself does not control the animations. That is all handled with XML meta data and C++. The Lua is there to handle events and determine certain behaviors. It's mostly trigger based at this point.
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 4:27 pm
by MadPumpkin
TheBuzzSaw wrote:I have C++ "verify" the XML by simply explicitly hunting for tags. I don't just parse through linearly and read the string; I tell my code to search specifically for the "sprite" tag and then the "animation" tag and so on. If I ever fail a search, I report an error. It's that simple.
Lua itself does not control the animations. That is all handled with XML meta data and C++. The Lua is there to handle events and determine certain behaviors. It's mostly trigger based at this point.
Have you ever played Aquaria? if so, do you know how they did the character animations in that? I know that most of them are separate images and it's a sort of a 2D ragdoll system but some of them are a single image and still appear to bend and slither and things. Do you know how this is done?
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 4:49 pm
by TheBuzzSaw
I have Aquaria. The animation system is quite fascinating, but I know nothing about its technical side. I need to play it again to refresh my memory on what you are describing.
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 5:04 pm
by MadPumpkin
TheBuzzSaw wrote:I have Aquaria. The animation system is quite fascinating, but I know nothing about its technical side. I need to play it again to refresh my memory on what you are describing.
Alright, well if you have any ideas toward it I would be happy to know :P.
Yea, I have a small idea of what might be going on with those ones. What it seems like is that with the single image he put that one texture on a strip of rects, not just one rect, and use the same ragdoll system as he did with the other objects.
Re: XSD, XML and C++
Posted: Mon Feb 28, 2011 5:30 pm
by dandymcgee
Re: XSD, XML and C++
Posted: Thu Mar 03, 2011 11:02 pm
by MadPumpkin
Yea I actually knew that, but thanks for the link I wouldn't have found it on my own >.<... Mostly I just didn't check it out because I wouldn't even know where to begin in the code to find such a thing.