Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-07-10 22:20:06


on Fri Jul 06 2007, Stefan Seefeld <seefeld-AT-sympatico.ca> wrote:

> over the last couple of years we have discussed possible XML APIs
> for inclusion into boost. As I already had an early prototype for
> such an API, I kept evolving it, based on feedback from those
> discussions.
> A couple of weeks ago I actually checked it into the sandbox
> (http://svn.boost.org/trac/boost/browser/sandbox/xml). Today,
> I adjusted the source layout to conform to the sandbox layout
> we agreed on, including a boost.build - based build-system.
>
> I would appreciate if anybody interested into a future boost.xml
> submission would have a look, provide feedback, or even get
> involved into the (ongoing) development.
>

Okay, this is going to sound very opinionated:

  I find XML horrible to read, however I find most of the procedural
  code I've seen for manipulating it even more horrible.

I would like to see a more declarative syntax for much of this stuff.

    element_ptr info = root->insert_element(root->begin_children(), "articleinfo");
    if (title)
    {
      info->insert(info->begin_children(), title);
      info->insert_comment(info->begin_children(), "This title was moved");
    }
    element_ptr author = info->append_element("author");
    element_ptr firstname = author->append_element("firstname");
    firstname->set_content("Joe");
    element_ptr surname = author->append_element("surname");
    surname->set_content("Random");

could be something like:

    root.push_front(
        tag("articleinfo")[
             title ? (comment("This title was moved"), title) : NULL
           , tag("author")[
                 tag("firstname")["Joe"],
                 tag("surname")["Random"]
             ]
        ]
    )

You could use Boost.Parameter to do attributes, or use runtime
attributes like

       tag("div", attr("class") = "someclass")[
             ...
       ]
               
You might be familiar with Nevow's STAN, which I had a hand in. This
suggestion is reminiscent of that.

> PS: The current scope of the project is described in
> http://svn.boost.org/trac/boost/browser/sandbox/xml/README

Another suggestion: use the .rst extension for ReST documents -- Trac
will preview them formatted via ReST

[Oh, and I suggest you get the tab characters out of your code)

Cheers,

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

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