OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   ANNOUNCE: XMLIO ver 0.3 - nestable C++ XML parser/writer

[ Lists Home | Date Index | Thread Index ]
  • From: Paul Miller <stele@fxtech.com>
  • To: sml-dev@egroups.com, xml-dev <xml-dev@ic.ac.uk>
  • Date: Mon, 20 Dec 1999 20:41:54 -0500

This is my simple nestable, streaming, XML parser for C++ application
data, now layered over expat (thanks to all who provided prods in the
right direction). Version 0.3 also adds chained element handlers and
support for parsing lists.

	http://www.fxtech.com/xmlio/index.html

I've decided to release this under the MIT(X11) license, which I feel is
the least restrictive of the popular licenses. How this will conflict
with James Clark's expat license, I don't know yet (I'm not a lawyer nor
do I try to play one on the internet, and I didn't want to bother trying
to interpret the Mozilla license). If there is a problem, someone please
let me know!

UNICODE isn't support yet, and I'm sure there are still bugs, but I've
tried this on data-files with thousands of elements and it seems fairly
quick. I still have some optimizations to do in the memory department,
to avoid unnecessary allocation/deallocation overhead.

An ANSI C++ compiler with namespaces, exceptions, and the standard
library is required. A vanilla "C" version of this API could be built,
if there is desire.

Please check the sample object implementation (sample.cpp and sample.h)
in the distribution for an example of how this API should be used.

A quick example of how the list-parsing feature mentioned above works.
Lets say I have this class:

class Date
{
public:
	enum Day
	{
		Sunday, Monday, Tuesday, 
		Wednesday, Thursday, Friday, Saturday, Days
	};

	static const char *labels[Days] = 
	{ "Sunday", "Monday", "Tuesday", 
	"Wednesday", "Thursday", "Friday", "Saturday" };

	void Write(XML::Output &out) const;
	void Read(XML::Parser &in);

private:
	int m_day;
};

void Date::Write(XML::Output &out) const
{
	// write out an element with the day as text
	out.WriteElement("Day", labels[m_day]);
}

void Date::Read(XML::Parser &in)
{
	// set up a handler for the date as a list
	XML::Handler handlers[] = {
		XML::Handler("Day", &m_day, labels, Days),
		XML::Handler::END
	};
	in.Parse(handlers, this);
}

Note the handler for the "Day" element above takes a pointer to an int
and an array of character strings and a total. When the "Day" element is
encountered it will automatically compare the element data with the
provided list, and write the index of the day found in the m_day
variable. It will throw an exception if an invalid Day is provided.

--
Paul Miller - stele@fxtech.com

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS