SAX-C

Peter Murray-Rust peter at ursus.demon.co.uk
Tue Jan 13 15:57:33 GMT 1998


I am forwarding this on behalf of Stefan Wagner because he has e-mail
problems. From a very quick glance this looks very exciting Stefan - many
thanks. 
[... mail stuff deleted ...]

>Date: Tue, 13 Jan 1998 00:25:58 +0100
>To: xml-dev at ic.ac.uk
>From: Stefan Wagner <h8625330 at obelix.wu-wien.ac.at>
>Subject: SAX-C
>
>----------------------------------------------------------------
>
>Today, David Megginson (dmeggins at microstar.com) with the help of many
>others announced the first draft for SAX for Java.
>Unfortunately Java is currently no option for me, only C.
>To speed up the implementation of a common basic event based API for
>parsers written in C  (like rxp or xmltok) I have converted the Java
>interfaces to C. I have tried to change the names as little as necessary.
>Still there will be things which should get changed.
>Some candidates for a change:
>- replacing  sax_ with xml_
>- result type of getAttributeName()
>
>Anyone adapting a C parser or writiing a driver (instead of writing good
>documentation for the parser API)?
>
>Stefan Wagner
>
>(st.wagner at ieee.org)
>
>
>(Read the Java draft for an explanation of the functions)
>
>/* --------------------------------------------------------------------- */
>
>/*
>    SAX-C Simple API for XML - C Language Interface
>
>    Proposal 1998-01-12
>*/
>
>
>
>/* --------------------------------------------------------------------- */
>/*  basic types */
>/* --------------------------------------------------------------------- */
>
>#define false   0
>#define true    1
>typedef int     bool;
>
>typedef char *  String;
>
>/* --------------------------------------------------------------------- */
>/*  Attribut Map
>/* --------------------------------------------------------------------- */
>
>/*
>  sax_AttributeMap_struct gets defined in the parser source code.
>  The definition is not needed by the application
>*/
>
>typedef struct sax_AttributeMap_struct *sax_AttributeMap;
>
>
>/* --------------------------------------------------------------------- */
>/*  typedefs for all the handlers */
>/* --------------------------------------------------------------------- */
>
>typedef void ( sax_EntityHandler ) ( String systemID );
>
>/* --------------------------------------------------------------------- */
>
>typedef struct
>{
>    void ( *startDocumentHandler ) ( void );
>    void ( *endDocumentHandler ) ( void );
>    void ( *doctypeHandler ) ( String name, String publicID, String
systemID );
>    void ( *startElementHandler ) ( String name, sax_AttributeMap
attributes );
>    void ( *endElementHandler ) ( String name );
>    void ( *charactersHandler ) ( char ch[], int start, int length );
>    void ( *ignorableHandler ) ( char ch[], int start, int length );
>    void ( *processingInstruction ) ( String target, String remainder );
>} sax_DocumentHandler;
>
>/* --------------------------------------------------------------------- */
>
>typedef struct
>{
>    void ( *warningHandler ) ( String message, String systemID, int line,
>int column );
>    void ( *fatalHandler )    ( String message, String systemID, int line,
>int column );
>} sax_ErrorHandler;
>
>
>/* --------------------------------------------------------------------- */
>/*  Parser Interface */
>/* --------------------------------------------------------------------- */
>
>void    sax_new_parser              ( void );
>void    sax_delete_parser           ( void );
>
>/* Default implementation will be used if never called or if called with
>handler = NULL */
>/* copies function pointers to internal table */
>void    sax_setEntityHandler        ( sax_EntityHandler   handler );
>void    sax_setDocumentHandler      ( sax_DocumentHandler handler );
>void    sax_setErrorHandler         ( sax_ErrorHandler    handler );
>
>void    sax_parse                   ( String publicID, String systemID );
>
>
>/* --------------------------------------------------------------------- */
>/*  EntityHandler Callbacks */
>/* --------------------------------------------------------------------- */
>
>void    sax_changeEntity            ( String systemID );
>
>
>/* --------------------------------------------------------------------- */
>/*  DocumentHandler Callbacks */
>/* --------------------------------------------------------------------- */
>
>void    sax_startDocument           ( void );
>void    sax_endDocument             ( void );
>
>void    sax_doctype                 ( String name, String publicID, String
>systemID );
>
>void    sax_startElement            ( String name, sax_AttributeMap
>attributes );
>void    sax_endElement              ( String name );
>
>void    sax_characters              ( char ch[], int start, int length );
>void    sax_ignorable               ( char ch[], int start, int length );
>void    sax_processingInstruction   ( String target, String remainder );
>
>
>/* --------------------------------------------------------------------- */
>/*  ErrorHandler Callbacks */
>/* --------------------------------------------------------------------- */
>
>void    sax_warning                 ( String message, String systemID, int
>line, int column );
>void    sax_fatal                   ( String message, String systemID, int
>line, int column );
>
>
>/* --------------------------------------------------------------------- */
>/*  AttributeMap Interface */
>/* --------------------------------------------------------------------- */
>
>/* returns an array of String Pointers and the number of Attribut names */
>void    sax_getAttributeNames       ( sax_AttributeMap map, int *count,
>String *atts );
>
>/* a replacement for Enumeration */
>String  sax_firstAttributeName      ( sax_AttributeMap map );
>String  sax_nextAttributeName       ( sax_AttributeMap map );
>bool    sax_hasMoreAttributeNames   ( sax_AttributeMap map );
>
>String  sax_getValue                ( sax_AttributeMap map, String
>attributeName );
>
>bool    sax_isEntity                ( sax_AttributeMap map, String
>attributeName );
>bool    sax_isNotation              ( sax_AttributeMap map, String
>attributeName );
>bool    sax_isId                    ( sax_AttributeMap map, String
>attributeName );
>bool    sax_isIdref                 ( sax_AttributeMap map, String
>attributeName );
>
>String  sax_getEntityPublicID       ( sax_AttributeMap map, String
>attributeName );
>String  sax_getEntitySystemID       ( sax_AttributeMap map, String
>attributeName );
>
>String  sax_getNotationNameID       ( sax_AttributeMap map, String
>attributeName );
>String  sax_getNotationPublicID     ( sax_AttributeMap map, String
>attributeName );
>String  sax_getNotationSystemID     ( sax_AttributeMap map, String
>attributeName );
>
>/* --------------------------------------------------------------------- */
>
>
>
>
>
>
>
>
>
>---------------------------------------------------------------------------
---
>  Stefan Wagner
>  Internet: h8625330 at obelix.wu-wien.ac.at                st.wagner at ieee.org
>  Fax: +43-1-607 71 57
>---------------------------------------------------------------------------
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The real poster :-)


-
>
>
	P.

>
Peter Murray-Rust, Director Virtual School of Molecular Sciences, domestic
net connection
VSMS http://www.nottingham.ac.uk/vsms, Virtual Hyperglossary
http://www.venus.co.uk/vhg

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list