Bhr Xml Parser. This is a partial XML parser with a SAX-like event-driven interface. It does not validate or handle entities (other than the standard ones) or Unicode; it is probably not very fast. However, it is relatively small and useful for setting up fixtures for unit tests etc. "Bhr Xml Parser.pac" contains what you need to use the parser. "Bhr Xml Parser Test.pac" contains some unit tests and requires SUnit.pac. The packages were written for Dolphin Smalltalk 3.06 and are probably not very portable. When I started, I couldn't find a reasonable standard lightweight parser for Dolphin. That will probably change with Camp Smalltalk (14th March 2000) and this code will probably not be supported after that date. I am publishing it under the GNU LGPL. Contact me if you wish to discuss other licensing options, at brangdon@cix.co.uk or drh@bhresearch.co.uk. ---- I have included a class called XmlBuilder which wraps the SAX interface with something a bit more Smalltalk-friendly. You provide it with a dictionary which maps XML element names onto message selectors. The Builder keeps a stack of element-objects. When it sees a #startElement:attributes event, it looks up the name, sends the corresponding message to the top-of-stack, and pushes its result onto the stack so that it will receive subsequent events. On #endElement the stack is popped. XML text is forwarded to the top-of-stack and other SAX messages are quietly ignored. The idea is to have domain data structures that build themselves. Objects correspond to elements and know how to deal with the elements they contain: typically either by creating a new object for the contents and returning it; by returning self and dealing with its contents themselves; or returning a DeafObject to ignore part of the tree. For XML output you would have the objects write themselves with messages like #printXmlOn:. This approach mixes XML knowledge into the domain objects. The alternative is to use a SAX-like "application" to build the objects from the outside, in which case you should also use the Visitor pattern to render them as XML from the outside. Sometimes it's simpler to just accept XML as a core format and read/write it directly, with the minimum of extra support classes. I find the Builder's mix of context (in the form of the element stack) and the element->message dictionary provides a good mix of assistance and flexibility. ---- Brh Xml Parser. Copyright (C) 2000 Dave Harris. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2, as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.