Abstract
This paper demonstrates how a higher-level, declarative view of XML parsing as folding over XML documents has helped to design and implement a better XML parser. By better we mean a full-featured, algorithmically optimal, pure-functional parser, which can act as a stream processor. By better we mean an efficient SAX parser that is easy to use, a parser that does not burden an application with the maintenance of a global state across several callbacks, a parser that eliminates classes of possible application errors.
This paper describes such better XML parser, SSAX. We demonstrate that SSAX is a better parser by comparing it with several XML parsers written in various (functional) languages, as well as with the reference XML parser Expat. In the experience of the author the declarative approach has greatly helped in the development of SSAX. We argue that the more expressive, reliable and easier to use application interface is the outcome of implementing the parsing engine as an enhanced tree fold combinator, which fully captures the control pattern of the depth- first tree traversal.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Anderson, J.: Common Lisp support for the ‘Extensible Markup Language’ (CL-XML). Version 0.906, June 2, 2001. http://homepage.mac.com/james_anderson/XML/documentation/cl-xml.html
Cooper, C.: Using Expat. xml.com, September 1, 1999. http://www.xml.com/pub/a/1999/09/expat/index.html
Dunford, M.: DOM XML: An Alternative to Expat. http://www.phpbuilder.com/columns/matt20001228.php3
Hutton, G.: A tutorial on the universality and expressiveness of fold. Journal of Functional Programming, 9(4):355–372, July 1999.
Gibbons, J., Jones, G.: The Under-appreciated Unfold. Proc. Intl. Conf. Functional Programming, pp. 273–279, Baltimore, Maryland, September 27-29, 1998.
Kiselyov, O.: Functional XML parsing framework: SAX/DOM and SXML parsers with support for XML Namespaces and validation. Version 4.9, September 5, 2001. http://pobox.com/~oleg/ftp/Scheme/xml.html#XML-parser
Lindig, C.: Tony-a XML Parser and Pretty Printer. Version 0.8. http://www.gaertner.de/~lindig/software/tony.html
van Mourik, H.: XML parser in Scheme. Version: 0.9.23, June 2, 1998. http://student.twi.tudelft.nl/~tw585306/
Neumann, A.: The Functional XML Parser. Version 1.4.4, October 30, 2000. http://WWW.Informatik.Uni-Trier.DE/~aberlea/Fxp/
Sheard T., Fegaras, L.: A fold for all seasons. Proc. Conf. on Functional Programming and Computer Architecture (FPCA’93), pp. 233–242, Copenhagen, Denmark, June 1993.
Wallace M., Runciman, C.: HaXml. Version 1.02 release, May 3, 2001. http://www.cs.york.ac.uk/fp/HaXml/
World Wide Web Consortium. Extensible Markup Language (XML) 1.0 (Second Edition). W3C Recommendation October 6, 2000. http://www.w3.org/TR/REC-xml
World Wide Web Consortium. XML Information Set. W3C Candidate Recommendation. May 14, 2001. http://www.w3.org/TR/xml-infoset
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2002 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Kiselyov, O. (2002). A Better XML Parser through Functional Programming. In: Krishnamurthi, S., Ramakrishnan, C.R. (eds) Practical Aspects of Declarative Languages. PADL 2002. Lecture Notes in Computer Science, vol 2257. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45587-6_14
Download citation
DOI: https://doi.org/10.1007/3-540-45587-6_14
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-43092-6
Online ISBN: 978-3-540-45587-5
eBook Packages: Springer Book Archive