ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Ws Wiki] Update of "Tuscany/TuscanyCpp/DesignNotes" by GeoffWinn
Date Fri, 27 Oct 2006 13:49:16 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.

The following page has been changed by GeoffWinn:
http://wiki.apache.org/ws/Tuscany/TuscanyCpp/DesignNotes

------------------------------------------------------------------------------
  
  = Debugging the XML parser =
  
- SDO uses the SAX parser provided by libxml2 to parse XML documents (and therefore XSD documents
also). The SAX parser uses a callback mechanism to report XML events to its caller. These
callback routines are supplied to the parser using a struct of type xmlSAXHandler, called
SDOSAX2``Handler that is defined in SAX2``Parser.cpp
+ SDO uses the SAX parser provided by libxml2 (http://xmlsoft.org/index.html) to parse XML
documents (and therefore XSD documents also). The SAX parser uses a callback mechanism to
report XML events to its caller. These callback routines are supplied to the parser using
a struct of type xmlSAXHandler, called SDOSAX2``Handler that is defined in SAX2``Parser.cpp.
However, since libxml2 is written in C and operates with no knowledge of objects or classes,
it is necessary to bridge the gap between libxml2's C-style call back mechanism and the objects
that comprise SDO. This is done as follows.
+ 
+ The file SAX2``Parser.cpp defines (C style) functions for all the callback routines required
by libxml2. Looking through that file, it is clear that many of those functions, such as sdo_internalSubset(),
are empty, meaning that SDO will simply ignore that particular event if it is reported by
libxml2. Where a callback function is not empty, the active contents usually take the form
of a call such as
+ 
+ (SAX2``Parser*) ctx)->startDocument()
+ 
+ This call is forwarding the event reported by libxml2 to a method within a parser object
created by SDO.
+ 
+ To understand this, we have to step back a little. A client of libxml2 initiates the parse
of an XML instance by calling the xmlSAXUserParseFile function. This function takes three
parameters. The first is the struct containing the list of callback functions (ie SDOSAX2``Handler)
and the third is the name of the XML file to parse. The second parameter is of type '''void*'''
and is not used by libxml2 directly. However, it is passed to every callback functon that
libxml2 calls as part of this parse to spply them with whatever context information it represents.
In Tucant SDO that context is in fact a pointer to an object that implements the appropriate
parsing of the file.
  
  To watch the parsing of a file as it unfolds it is usually easiest to place breakpoints
on the routines named in that struct.
  

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@ws.apache.org
For additional commands, e-mail: general-help@ws.apache.org


Mime
View raw message