Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2003-06-02 10:28:21

Stefan Seefeld wrote:

>But providing a different binding may practically be very hard, i.e.
>require a lot of work. Again, don't focus on parsers only. There is
>*much* more...

What I was thinking of in the code I e-mailed previously was something like:

class document
      element root;
      void RecursivelyBuild( IXMLDOMElement *, element & ); // [1]
      document( const char * );

// [2]:
void document::RecursivelyBuild( IXMLDOMElement * tnode, element & dnode )
   for each atrtibute tattr in tnode.attributes
      dnode.attributes[ tattr.nodeName ] = tattr.nodeValue;

   for each child tchild in tnode
      element newElem = createElement();
      RecursivelyBuild( tchild, newElem );
      dnode.insert( newElem );

document::document( const char * fn )
   XMLDOMDocument doc( fn ); // [3]
   RecursivelyBuild( doc, root )

The RecursivelyBuild function would be implementation dependant (outlined
here for MS-XML). This way, only places 1, 2 and 3 need be
implementation-specific. The other stuff, like tree representation,
namespaces, XPath navigation and all that stuff can then be independant of
the implementation.

NOTE: It may be possible to supply a document-loader interface:

class boost::xml::loader
      virtual bool load( boost::xml::document & doc, const char * fn ) = 0;

class boost::xml::libxml2_loader: public boost::xml::loader;
class boost::xml::msxml_loader: public boost::xml::loader;

and these can be implemented like above. This then isolates any
parser-specific information relating to loading an XML document. This can be
facilitated in the document class via templates to simplify usage, possibly.

Doing this, the document and related classes can focus on the XML DOM and
how that interface should be implemented in C++.


It's fast, it's easy and it's free. Get MSN Messenger today!

Boost list run by bdawes at, gregod at, cpdaniel at, john at