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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: SAX/C++: First interface draft

[ Lists Home | Date Index | Thread Index ]
  • From: "Didier PH Martin" <martind@netfolder.com>
  • To: "David Megginson" <david@megginson.com>,"XMLDev list" <xml-dev-digest@ic.ac.uk>
  • Date: Sun, 12 Dec 1999 16:29:18 -0500

Hi David,

Why not implement the document handler also as an interface? thus we we
woudl have:

class IDocumentHandler
{
public:
  virtual void setDocumentLocator (const Locator &locator) = 0;
  virtual void startDocument (void) = 0;
  virtual void endDocument (void) = 0;
  virtual void startElement (const char * name, const AttributeList &atts) =
0;
  virtual void endElement (const char * name) = 0;
  virtual void characters (const char * ch, size_t length) = 0;
  virtual void ignorableWhitespace (const char * ch, size_t length) = 0;
  virtual void processingInstruction (const char * target, const char *
data) = 0;
}

class MyDocHandlerImp : public IDocumentHandler
{
  MyDocHandlerImp();
  ~MyDocHandlerImp();
  void setDocumentLocator (const Locator &locator);
  void startDocument (void);
  void endDocument (void);
  void startElement (const char * name, const AttributeList &atts);
  void endElement (const char * name);
  void characters (const char * ch, size_t length);
  void ignorableWhitespace (const char * ch, size_t length);
  void processingInstruction (const char * target, const char * data);
protected:
  Locator * _locator;
}

PRO and CON:
------------
The event generator talks to a generic interface not to a particular
implementation. However this reauires that the interface.h to be included
and that interfaces are inherited by implementations.

Other point of view:
--------------------
SP uses an event record which tend to reduce the number of interface
members. In the OpenJade project, we are thinking to remake the C++
interface of OpenSP as follow:

class IDocumentHandler
{
  virtual void startElement(const StartElementEvent &event) = 0;
  virtual void endElement(const EndElementEvent &) = 0;
}

class parser: public IDocumentHandler, public SGML_XML_Application
{
	void startElement((const StartElementEvent &event);
	void endElement(const EndElementEvent &);
}
note: the usage of an interface also allows the class implementation to use
multiple inheritence and still be able to be interfaced with the client
without problems, this may not be the case for an ordinary class.

This is the event record which provide description of the event type. I
understand that SAX saw its origins as a set of Java classes. Would it be to
alien to SAX to use structs intead of methods? (just asking with curiosity
and trying to make these world compatible and useful to developers)

Cheers
Didier PH Martin
mailto:martind@netfolder.com
http://www.netfolder.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