Cover Pages Logo SEARCH
Advanced Search
ABOUT
Site Map
CP RSS Channel
Contact Us
Sponsoring CP
About Our Sponsors

NEWS
Cover Stories
Articles & Papers
Press Releases

CORE STANDARDS
XML
SGML
Schemas
XSL/XSLT/XPath
XLink
XML Query
CSS
SVG

TECHNOLOGY REPORTS
XML Applications
General Apps
Government Apps
Academic Apps

EVENTS
LIBRARY
Introductions
FAQs
Bibliography
Technology and Society
Semantics
Tech Topics
Software
Related Standards
Historic

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


Date:     Mon, 20 Dec 1999 20:41:54 -0500
From:     Paul Miller <stele@fxtech.com>
To:       sml-dev@egroups.com, xml-dev <xml-dev@ic.ac.uk>
Subject:  ANNOUNCE: XMLIO ver 0.3 - nestable C++ XML parser/writer

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

Prepared by Robin Cover for the The SGML/XML Web Page archive.


Globe Image

Document URL: http://xml.coverpages.org/xmlIO-03.html