[Libxmlplusplus-general] Multiple Node types
- From: murrayc t-online de (Murray Cumming)
- To: libxml++ <libxmlplusplus-general lists sourceforge net>
- Subject: [Libxmlplusplus-general] Multiple Node types
- Date: 09 Dec 2002 20:47:48 +0100
On Mon, 2002-12-09 at 20:56, Christophe de Vienne wrote:
> I'm thinking of doing a base Node class, from which will herit ElementNode,
> CommentNode, TextNode, and the 4 other possible node types.
Yes, that's what other parsers do, though it will require tedious use of
dynamic_cast<> or get_node_type().
> For the get_content and set_content accessors, I have 2 alternatives :
It's not clear where these 2 alternatives begin and end in this
paragraph:
> - put them in the Node base class, and implement it differently in TextNode /
> CommentNode (here the meaning is obvious) and in ElementNode (here they would
> set/get the content of a child TextNode, and eventually create one if it
> doesn't exists).
That sounds fine. It would allow generic examination of nodes, with
convenience functions for common uses.
> It is the behavior of libxml (see xmlNodeSetContent
> implementation in tree.c).
> - put them only in TextNode and CommentNode.
>
> The first one give the possibility to manipulate Nodes with content without
> having to know about the TextNodes in a basic utilisation.
> The second one avoid the possible mistakes because of mixing the different
> accessor behavior...
>
> A third one would be to do the second one, plus adding another accessor on
> ElementNode with a different name. But which one ?
I'm not sure what you mean here.
>
> I think I prefer the first solution, with a good documentation. For now...
> I'm going to have a closer look to Xerces before making a decision.
>
> Any comment/advise is welcome !
>
> > I noticed that get_content() doesn't seem to work.
>
> ? well in the current CVS version, the dom_parser example shows me some
> contents. What did you mean exactly ?
I think the dom_parser shows comment nodes, not comments from
get_contents(). If get_contents() returned the child text node's data
then it might work. I could be wrong about this analysis - I haven't
looked in detail, and my problem is in a separate app.
--
Murray Cumming
murray usa net
www.murrayc.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]