|
Boost : |
From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2003-06-13 11:22:49
Reece Dunn wrote:
> 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?
no, it's correct...on a conceptual level.
The point I'm trying to make is that libxml2 does all this for me
already. The node itself doesn't store all the active namespaces, as
that would be a horrible waste. You have to query them (and therefor
you'll access the document and parent nodes).
For example, if a node is moved from one place to another, its context
will change and therefor some necessary adjustments have to be made
notably concerning the namespaces. A look into the libxml2 source code
convinced me that it's quite a tricky job...
> 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.
you mean you vote for the 'nodes-are-references' style ?
> 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.
Can you elaborate ?
Regards,
Stefan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk