Boost logo

Boost :

Subject: Re: [boost] xml?
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2010-04-08 13:23:02


Maarten L. Hekkelman wrote:
> Op 08-04-10 17:22, Phil Endecott schreef:
>> Just one observation for now. I see that you have a node class that
>> points to its neighbours and parent. I think this is quite a common
>> pattern for XML, but it differs from e.g. the standard containers. So
>> it's not possible to use standard algorithms to iterate through your
>> XML structure.
>>
> I started with containers, but ended up with the current structure since
> it is so much more practical.
>
> You can still iterate in container style over children though. The
> member 'children()' of a node returns a std::list of pointers to
> children nodes. Therefore you can write code like:
>
> foreach (xml::element* e, node->children<xml::element>())
> ;

Ah, I missed that.

> As I said, I started with simply nodes that had children in a member STL
> list. This seemed the /right/ way to do it. But then I ran into problems
> when I had to create processing instruction nodes, comment nodes and
> even attribute nodes. These are needed for a correct (and
> straightforward) xpath implementation. So I had to create a common base
> class, node, and element now is a subclass of node.
>
> Fortunately, not all is lost. The children method above can be used for
> traversal, but it is even more convenient to use xpath.evaluate() to
> create a selection and iterate that:
>
> foreach (xml::element* e, xpath("//my-node").evaluate<xml::element*>(n))
> ;

So could your XPath implementation be decoupled? What interface does
it use to traverse the XML tree? Could it be used on top of a
different XML tree implementation, such as a lazy one that stores the
text of the XML document, if it provided a similar interface?

Regards, Phil.


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