#147071 - qw3rky - Fri Dec 14, 2007 1:07 am
I have been intensively looking around for a decent XML parsing library to use on the DS. It had to be small (libxml2 need not apply), simple and non-validating (no thanks Expat), and written in good ole plain C (sorry TinyXML). And preferably, it would support both DOM and SAX processing.
I came upon Mini-XML by Michael Sweet and I found it to be a completely perfect fit for my criteria. It is compact and has a minimal footprint, it supports both DOM and SAX, and it has a very pleasant API. Mini-XML is coded in standard ANSI C, and thanks to the hard work of wintermute and others on devkitpro, after 10 seconds of editing a configuration header file, I was able to compile it with the latest release of devkitarm without any problems or changes.
I am using Mini-XML right now for a little project of mine (I'll give you 3 guesses as to what it is), and I thought that this library might prove useful for someone else. If you want to try it out for yourself, I whipped up a zip file containing the ARM9 compiled library and header file. I also added in a couple of examples (Apache Ant build file, iTunes music library, Google Earth export and more) that show you how nice it is to work with Mini-XML. The examples include source, XML, and unpatched compiled nds binaries. I use chism's excellent FAT library so you'll need to DLDI patch it to get it to work with your card. The examples have been tested on the iDeaS 1.0.2.0 emulator with R4 support and on my real DS with the Games N Music card.
You can download my pre-compiled, ready-to-go archive at http://brian.grogan.jr.googlepages.com/mxml.zip. If you want it straight from the source to compile it yourself, go to http://www.minixml.org/software.php. I hope someone out there finds this useful, and if so, let me know.
_________________
I've coded about 17 different implementations of Pong. It's the game dev's "hello, world".
DualScheme - Scheme Interpreter for DS
#147087 - OOPMan - Fri Dec 14, 2007 8:27 am
Very nice :-)
I'm a big fan of XML...
Now all we need is a Schema-validating parser ;-)
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#147097 - chishm - Fri Dec 14, 2007 1:06 pm
This might be very useful as a replacement for the custom XML parser in Nitro Hax. I'll have to give it a try when I have time.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com
#147098 - kusma - Fri Dec 14, 2007 1:13 pm
Just keep in mind that complying to the LGPL license for embedded software without giving full source of your program is a bit of a hassle, as you have to allow the users of your program to re-link to newer version of the LGPL'ed library themselves.
#147101 - a128 - Fri Dec 14, 2007 2:30 pm
I used sometimes
TinyXML
http://www.grinninglizard.com/tinyxml/index.html
where I simply loaded the file from memory instead of the use of fread()
#147105 - kusma - Fri Dec 14, 2007 3:53 pm
In the original post, TinyXML was discarded as it was written in C++. I'm not sure how valid reason that is in general for NDS homebrew, though.
#147131 - qw3rky - Fri Dec 14, 2007 8:50 pm
Quote: |
Just keep in mind that complying to the LGPL license for embedded software without giving full source of your program is a bit of a hassle, as you have to allow the users of your program to re-link to newer version of the LGPL'ed library themselves. |
I included the full Mini-XML source directory in my zip so I'm pretty sure that makes me compliant. And even if I didn't, I'm sure the author wouldn't mind some more exposure for his very nice work. And secondly, this is for a fun little homebrew application of mine. Not a for-profit venture. If it was, I would be a bit more wary. Please don't turn into Tepples on me.
Quote: |
In the original post, TinyXML was discarded as it was written in C++. |
I wanted a library in plain C because mostly, I personally prefer to work in plain C. I also find that on average, C++ programs tend to be a bit more bloated in size and use up more memory on the DS. I will not get into a language war with you though.
If you like C++, TinyXML is a fine library to use, and it's even smaller than Mini-XML. However, I did find that Mini-XML has more useful functionality. If you haven't given it a spin yourself yet, you should really check out the Walk, Find, Index, and SAX parsing provided in Mini-XML. Michael Sweet has created some very powerful and easy-to-use abstractions and for me, it made my work with XML an absolute joy (as opposed to the drudgery it usually is).
_________________
I've coded about 17 different implementations of Pong. It's the game dev's "hello, world".
DualScheme - Scheme Interpreter for DS
#147133 - tepples - Fri Dec 14, 2007 9:16 pm
After some prodding from (remain nameless), I decided to check out C++ in devkitARM, and I discovered that C++ itself isn't as much of a problem as I once thought. I compile a GBA program as C and as C++, and the difference is about 40 bytes. I just finished writing a simple program to demonstrate that linking in support for throw (which most C++ libraries use) adds about 40 KiB, which is a big deal for GBA multiboot or DS ARM7 but not for DS ARM9.
The bloat comes in when I try to use the <iostream> of GNU libstdc++. But based on my reading of TinyXML's source code, it appears you can turn off <iostream> by not defining TIXML_USE_STL.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#147138 - kusma - Sat Dec 15, 2007 12:06 am
qw3rky wrote: |
I included the full Mini-XML source directory in my zip so I'm pretty sure that makes me compliant.
|
No, it does not. To be compliant, you need to distribute the object files of your build. To be honest, I was more concerned that chishm would get in some kind of trouble with NitroHax, not you.
Quote: |
And even if I didn't, I'm sure the author wouldn't mind some more exposure for his very nice work.
|
Don't take this the wrong way, but now you're just making assumptions on the creators behalf. If I were you, I'd take what the license states as better assumption of what the author wants, because... well, it's what he actually stated ;)
Quote: |
And secondly, this is for a fun little homebrew application of mine. Not a for-profit venture. If it was, I would be a bit more wary. Please don't turn into Tepples on me.
|
Again, don't take this the wrong way, but fun is no excuse for theft, IMO. Hookers and booze, on the other hand, are.
I'm not sure what you mean by "turn into Tepples", but my first instinct is that it would be a positive thing. He sure is a helpful person.
Quote: |
I wanted a library in plain C because mostly, I personally prefer to work in plain C. I also find that on average, C++ programs tend to be a bit more bloated in size and use up more memory on the DS. I will not get into a language war with you though.
|
That's perfectly OK. You can interface from c++ to c code if you want to, but I'm not going to go into a language war here either - it's just that people seem to believe that all of C++ is bloated just because iostream is ;)
Quote: |
If you haven't given it a spin yourself yet, you should really check out the Walk, Find, Index, and SAX parsing provided in Mini-XML. |
I sure will the next time I'm in need for an XML-library on a project that I can afford giving away the source on (I find the whole object-file distribution-thingie to be a hassle).
#147147 - chishm - Sat Dec 15, 2007 4:18 am
kusma wrote: |
Just keep in mind that complying to the LGPL license for embedded software without giving full source of your program is a bit of a hassle, as you have to allow the users of your program to re-link to newer version of the LGPL'ed library themselves. |
Ooh, you're right. I suppose releasing the source to the menu wouldn't be that bad, since all the card stuff is done within a second program that is compiled separately and embedded within the menu for convenience. If the LGPL somehow infects that, then there's something wrong with the LGPL.
The menu for Nitro Hax is written in C++ anyway, so I don't need pure C. I did take a look at TinyXML when I was writing the menu. I didn't use it because I'd end up with 2 complete document trees in memory: the one created by TinyXML, and a version converted into the data structures used by the program. Having the data structure (the one produced by TinyXML) separate from the application code kinda defeats the whole OO thing. Copying the data into the proper class hierarchy, like I tried, creates problems with large XML files (1MB+) and the small memory capacity of the DS.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com
#147149 - tepples - Sat Dec 15, 2007 5:57 am
LGPL doesn't "infect" across process boundaries, but one would have to define "process" for a single-tasking embedded system with no resident loader.
chishm wrote: |
Having the data structure (the one produced by TinyXML) separate from the application code kinda defeats the whole OO thing. Copying the data into the proper class hierarchy, like I tried, creates problems with large XML files (1MB+) and the small memory capacity of the DS. |
In other words, TinyXML works only in "DOM mode" (parse the whole document and read it into a tree), unlike say Expat that works in a SAX-style mode (parse one tag or text element at a time).
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#147153 - chishm - Sat Dec 15, 2007 12:46 pm
tepples wrote: |
In other words, TinyXML works only in "DOM mode" (parse the whole document and read it into a tree), unlike say Expat that works in a SAX-style mode (parse one tag or text element at a time). |
Exactly what I was trying to express. I'll have to look into using a SAX-style library, as I'm sure a well maintained library will work better than the sscanf-based method I'm using.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com
#147197 - qw3rky - Sun Dec 16, 2007 4:12 am
Quote: |
don't take this the wrong way, but fun is no excuse for theft |
This is exactly what I'm talking about! People who worry and think about licenses and restrictions more than writing some code and enjoying the beauty of sharing code with others.
This is a homebrew forum. The majority of projects on here are meant as a way to have fun making something cool, using that cool new something on your DS, and sharing with others. If the first thing you think about before you sit down to code is what license the open source libraries you're using are under, I really think you're approaching this the wrong way.
If I was some sort of for-profit, large company (like say, Verizon) and I took some open source code (like say, BusyBox) and put the code in one of my commercial products (like say, a Verizon wireless router), then yeah, I'd be crapping my pants and hoping an open source hacker doesn't find out and tell his lawyer.
But I'm not. This is just for fun, and I'm just sharing a discovery of mine which I thought would be useful. I would never try to pass off someone else's work as my own because that is completely not okay. I always give full credit to the people who build the libraries I use in my projects. But am I going to distribute the object code of my project to everyone who downloads it if I'm using an LGPL library? No! That's just going overboard. Plus I think you may be interpreting the LGPL license a bit too strictly in this specific case.
So, kusma... loosen up a bit, have some fun, and write some code, instead of warning everyone about viral licenses in a scary voice.
I hate to say it, but Tepples, I've noticed you can be prone to doing that too, and I think it's more annoying rather than helpful. Don't get me wrong, for the most part you're a very helpful guy, but instead of warning people about the licensing dangers of using MP3 music in a DS homebrew app, maybe you could focus on being supportive of someone else's useful contribution to the homebrew community? But really, for the most part you're awesome.
Quote: |
I'll have to look into using a SAX-style library |
chishm, this is precisely why I was happy with Mini-XML. TinyXML is limited in that it only provides a very basic DOM API implementation. Mini-XML supports some very nice SAX-style processing and it's a huge boon for the DS when you have major memory constraints. You really should try it out. I'm using SAX processing for an upcoming project of mine, and the memory usage is minimal when you just discard every xml node after you do what you need to do with it.
_________________
I've coded about 17 different implementations of Pong. It's the game dev's "hello, world".
DualScheme - Scheme Interpreter for DS
#147214 - theli - Sun Dec 16, 2007 10:00 am
qw3rky wrote: |
But am I going to distribute the object code of my project to everyone who downloads it if I'm using an LGPL library? No! That's just going overboard. Plus I think you may be interpreting the LGPL license a bit too strictly in this specific case. |
No, Kusma is right and you will be violating a license in such a case(unless library is distributed with some exceptions). And fun is really bad excuse :).
#147218 - masscat - Sun Dec 16, 2007 11:25 am
It is important that kusma pointed out the implications of using a LGPL licensed library with a project as some people (chishm as an example in this thread) may not be aware of the consequences of doing so.
It is also a good education for people developing homebrew and similar to see licenses and the consequences of them as they are a fact of software development. This education could save somebody much time, hassle and money in the future by avoiding the possibility that some party takes exception to, what they see as, non-compliance with a license and deciding to take action.
Nobody on these forum is stopping anybody from using a library for whatever purpose (complying or not with its license).