Recently I spent some time working with XML... and was intrigued by it. I looked up the standards, and was surprised to find that XML is simply a markup metalanguage - a standard for markup languages. I was even more surprised to learn that it is really an "SGML Lite", using DTD - Document Type Definitions - to describe what the tags mean (and that DTDs are optional). Thus it is that I have started considering using XML as a database engine (to replace or compliment my existing C-like database format). It could even be used for player files and other things, as such: <player id=5348 name=FearItself> <description>A warrior stands before you, wielding a large, fearsome C++ handbook!<br> </description> <eq> <object vnum=1358 worn=head><!--more custom/overridden object fields go here--></object> </eq> <carrying> <object vnum=537> <contents> <object vnum = 1449> <!--closing tag optional if no other data present--> </contents> </object> </carrying> </player> What is even more interesting is that using existing parsers, the entire database could be preparsed into memory as text or trees during bootup, and final parsing of individual database elements could be done after all data is loaded in, or as needed... this is a feature needed to implement database inheritance. Example: <room vnum=6848 inherits=7000> <exit direction=north to=6847>This looks like a normal exit.</exit> <exit direction=south to=6849>Yet another exit.</exit> </room> <room vnum=7000> <description>This is a room!<br> </description> <exit direction=north to=6800>This looks like a lethal exit.</exit> </room> Room 6848 would have the description "This is a room!\n" and the exits north to 6847 and south to 6849... now, in the current database situation, inheritance like this is impossible, since everything is read in straightforward and parsed as it is read... thus the end of the record can be hard to detect. However, in this XML situation, the data can be preparsed and stored as a tree! rooms |`room: vnum 6848, inherits 7000 | |`exit: direction north, to 6847 | | `contents: "This looks like a normal exit." | `exit: direction south, to 6849 | `contents: "Yet another exit." `room: vnum 7000 |`description: "This is a room!\n" `exit: direction north, to 6800 `contents: "This looks like a lethal exit." So how is inheritance handled? Well, after everything is parsed into the tree (or even just the individual room trees to the database itself rather than a master room tree), the room data is scanned and filled in. If a room inherits a room, the parser pushes the current room onto the stack, and the room to be inherited is scanned. If this room inherits another room, the parser does the same again (storing all "being scanned" rooms in a stack to review, to prevent looped inheritance). When the parser returns to a room that inherited another, it copies all of the inherited rooms traits to the current room, then scans the data tree and uses the new data to overload existing data and filli n blank fields. The benefits: * The format is human-readable/editable * The format is streamable * Very general system - can be used for all storage information (boards, mail, etc) * preparsable * There are already at least 2 stable, production-ready, open source C library XML parsers Any opinions/comments/flames/nachos? - Chris Jacobson +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST