Introduction
From my previous article the Expat XML parser was chosen as my reference platform for an XML parser implementation on the Symbian platform.
Now, the criteria and requirements can be examined to see how well they stand up to the metrics:
How well does Expat standup to the criteria:
Expat stands up very well to the criteria. This parser has been ported to numerous platforms. Furthermore there is active development, a mailing list and forum on Sourceforge.net, so support should not be a problem.
There are numerous addons and documentation and the parser was written by one of the founders of the XML language, James Clark.
Whilst the codebase is slightly larger than hoped for, and is C based, it has been ported to a wide number of compilers and operating systems and there is fairly clear documentation on how to port it to other operating systems
and compilers.
How well does Expat stand up to the requirements
The default parser meets most of the requirements out of the box.
As the parser supports incremental parsing and holds little state. Becuase it is not recursive; a small amount of stack is used, a real boon for Symbian as it only has 8k per thread.
The code is also relatively small (just over 11000 lines) is packs in support for entities, DTD's, namespaces and encodings, though not validation of DTD's.
With the exception of validatiom, as far as I am aware it is W3C compliant, as there are regression tests supplied to run against the standard XML test suite.
So the two remaining requirements, vis a Symbian standard API and being able to have the parser exist as a Symbian DLL are no yet satisified.
Doing the port
It was decided that port should be done in two stages. The first stage was to just get the DLL to build as a plain old dll, the only export being the E32Dll which creates an instance of the parser. This helps the linker not eliminate
the instance.
The most visible thing is that the parser is written in C, not C++, so problems with STL, templates, exception handling, inheritance, operator overloading all become irrelevant, however the problem with static writeable data infesting most C applications will still remain.
The project was started by looking at the settings in expat_config_h.in which lists all the configuration compiler defines required. The easiest way forward is to model this on the vms port so a new folder called Symbian was created and the expat_conf_h.in file was copied to this folder and renamed expat_config.h
The compiler defines in this were then examined and most of them are solved by examining the header file in libc, with the following exceptions:
XML_CONTEXT_BYTES
Setting this flag will allow the parser to hold some information so when an error is encountered the text could be displayed to provide a more contextual error.
For the DLL I decided that we would not support context bytes.
XML_DTD and XML_NS
We will support both DTD's and namespaces, though external entities will not be supported.
BYTEORDER and WORDS_BIGENDIAN
Symbian on ARM processors is little endian,we define the byte order to be 1234 and undefine big endian.
XML_UNICODE
We also want to have unicode strings passed to the document handlers as Symbian is Unicode based.
The next stage was to build the MMP file and add the relevant c files, remembering to including estlib which is the standard ANSI C++ library for Symbian.
Just as the port was getting going issues with writeable static data hit. After a few days work I had isolated the relevant bits that were causing the linker error in PETRAN. The process used has been fully documented in this link
It is suffice to say as in a comment posted previously that the issue has more to do with incorrect use of const than with any global variables.
Download
The download has been provided as a zip file and this just has the patch file containing the differences between Expat 1.95.8 and the version that builds for Symbian
Expat-1.95.8.diff.zip
Other References
There is a really good intoductory article on xml.com that explains how to use the parser.
One of the articles off of this article is the benchmark which
shows just how fast expat is relative to other parsers!
Conclusion
This concludes the second part of the tutorial. What we now have is a DLL that has an implementation of the Expat parser. This parser can now be linked into any executable or dll as a static library.
In the next installment we will finish the DLL by providing a C++ class in a statically linked DLL that will provide a generic interface to the parser for use by other people. The DLL will then be shareable in other applications.
True,
But the site appears to be down (13 Oct 2004),
I looked at it a while back, and no source code was provided, only binaries and it was missing some of the functionality was not implemented or accessible.
Later this week I will post the port and you can compare the two versions.
I also see this an older version of expat.
Hi Paul,
I didn't get your explanation on Dll Stuff. Please let me know in detail how to get the dll from expat 1.95.8 . Where the source code has to be compiled to get the E32dll.
HI Paul,
I had read that artical but i dint got any thing out of it.... even the code what they had provided is not understood.... did they developed for symbianos7.os of series60 or it is developeed for another version.
one more question is that suppose if we have an xml document how do we run it on symbian device is there is any API which handle the xml code and retrieve the information from that xml code....
kindly suggest .....