
I would do it over templates - than it's type safe and a part of the xml validation can be done at compile time.
typedef tag< mpl::vector< title, author > // tags mpl::vector< isbn > // atributes
article_info;
I hadn't considered compile-time type safety when I wrote my above example. However, I feel an example like this might also preclude XML features like comments. If we were to parse an existing article:
<article_info isbn="foo"> <!--Article information goes here--> <title>bar</title> <author>Testy McTest</author> </article_info>
your definition doesn't immediately make it clear that the comment, when parsed, ends up in the document tree. I may, however, just be missing something. Complicating matters, according to the standard, they can also appear within the document type declaration, so comments significantly complicate the matter: http://www.w3.org/TR/REC-xml/#sec-prolog-dtd
And the standard also lists retrieval of comment text as optional: http://www.w3.org/TR/REC-xml/#sec-comments
But I think that a Boost.XML library should support the retrieval of the text of comments.
I believe that comments could be supported with a typesafe implementation. I don't know where you see problems with comments - article_info could contain optional instances of comment-class. Oliver