On Fri, 2003-06-27 at 12:53, Anthony Williams wrote: > It was meant to be a description of semantics, in terms of a sample > implementation. > > A node that is not part of a document is a free-standing subtree that needs > adding to a document. If it is an element, then you can treat it as if it is > the root node of a document. If it is anything else, then you are more limited > in what you can do, but then what does it mean to perform an XPath query on a > PI? > > If the underlying API requires that the document is kept alive to keep the > nodes alive, then the wrapper class must handle this, whilst simulating the > above semantic description.
If you look in one of my other posts you will see a description of just that. The thing that concerns me most about this is doc.find( path ).parent(); // non null (unless it found the root node) BUT... node n( doc.find( path ) ); n.parent(); // User may not expect this to be null n.document(); // or this You could have a node_container (or standalone_node) which had no parent or document methods but otherwise looked like a node. node_container n( doc.find( path ) ); n.parent(); // compile time error n.document(); // compile time error which is good but doesn't really solve the problem... n.first_child().document(); // null My preference is that if you want to make a copy of a node you have to have a new document... document doc2( doc.find( path ) ); doc2.root().parent(); // null but you would expect that (it's the root) doc2.root().document(); // non null as you would expect That way the user can rely on parent() to be non null for all but root nodes and document() can return a reference since it can never be null. > > You could copy the libxml2 tree into your own structure but then you are > > on your own when it comes to higher level things like xpath and xslt. > > I imagined that you would write forwarding functions for the underlying API, > so when you are given an Xpath query, you pass it on to the underlying API and > then wrap the result. Then you would need to keep libxml2 version of the tree too and synchronise any changes (or rebuild it every time you want to call a libxml2 function). -- Hamish Mackenzie <[EMAIL PROTECTED]> _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost