Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2003-06-13 10:58:03


Hamish Mackenzie wrote:

>How about this for reading an input stream...

>xml::dom::document doc( parse_stream( std::cin.rdbuf() ) );

I like this facility. You could also make it accept an istream like this:

class parse_stream
{
   public:
      parse_stream( istream & is ): sb( is.rdbuf()){...}
      ...
};

or something similar, making the above the simpler:
   xml::dom::document doc( parse_stream( std::cin ));

-----

Stefan Seefeld wrote:

>Yes, but is that a problem ? Of course it has to be written in bold
>strokes:
>"Don't delete a document while operating on its content !", but I think the
>main idea to get across is that nodes *can only* exist in the context
>of a document. That's not only because of memory ownership issues, but also
>for a
>variety of other contextual data associated with a node, such as
>namespaces.

Any node can define namespaces:

<h:html xmlns:h = "html4" xmlns:h = "html4">
   <body>
      <m:math xmlns:m = "mathml2">...</m:math>
      <h:span>...</h:span>
      <mml:math xmlns:m = "mathml2">...</mml:math>
   </body>
</h:html>

so namespace lookup would propagate along the parents of each node until a
matching namespace is found. This would mean that each node must store a
(smart) pointer to a namespace mapping, in order to facilitate lookup (done
during node construction). The node will also have a pointer to a namespace
information object that looks something like:

class namespaceInfo
{
   std::string url;
   std::string name;
};

Have I got this wrong?

-----

I also like the
   xml::dom::document document = xml::dom::parse_file(argv[1]);
style usage. Also:
   xml::dom::element e = doc.documentElement();
   xml::dom::node n = e;

This is just my preferred style/usage, and does not have to be adopted. This
would, however, allow the implementation to be adapted to when memory
management needs to be used and to switch between different management
policies for the various implementations.

_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection
http://www.msn.co.uk/specials/btbroadband


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk