[Interest] [ANN] libstudxml - modern XML API for C++

Constantin Makshin cmakshin at gmail.com
Wed May 21 20:29:58 CEST 2014


Hello, Boris.

I took a look at the API guide and here are my thoughts.

Compatibility of the low-level parser with range-based for loop and
semi-automatic type conversion are nice features, but:
1) your words about libstudxml being free from external dependencies
contradict with the fact that actual parsing is done by Expat. Packaging
two libraries together doesn't make Expat "internal" dependency;
2) looks like the high-level parser will blow up, throwing an exception,
if the input doesn't completely satisfies all of the application's
expectations. Making so strict requirements to the order of child
elements is a questionable idea IMHO (unless they [can] contain
references to each other, of course).

On 05/21/2014 06:48 PM, Boris Kolpackov wrote:
> Hi,
> 
> libstudxml is an XML library for modern, standard C++. It has an API
> that I believe should have already been in Boost or even in the C++
> standard library.
> 
> The API was first presented at the C++Now 2014 conference. Based on
> the positive feedback and encouragement I received during the talk,
> I've decided to make the implementation generally available.
> 
> As an example, we can parse this XML:
> 
>   <person id="123">
>     <name>John Doe</name>
>     <age>23</age>
>     <gender>male</gender>
>   </person>
> 
> With the following C++ code, which performs all the validation
> necessary for this XML vocabulary:
> 
>   enum class gender {...};
> 
>   ifstream ifs (argv[1]);
>   parser p (ifs, argv[1]);
> 
>   p.next_expect (parser::start_element, "person", content::complex);
> 
>   long id = p.attribute<long> ("id");
> 
>   string n = p.element ("name");
>   short a = p.element<short> ("age");
>   gender g = p.element<gender> ("gender");
> 
>   p.next_expect (parser::end_element); // person
> 
> The API has the following interesting features:
> 
>   * Streaming pull parser and streaming serializer
>   * Two-level API: minimum overhead low-level & more convenient high-level
>   * Content model-aware (empty, simple, complex, mixed)
>   * Whitespace processing based on content model
>   * Validation based on content model
>   * Validation of missing/extra attributes
>   * Validation of unexpected events (elements, etc)
>   * Data extraction to value types
>   * Attribute map with extended lifetime (high-level API)
> 
> libstudxml is compact, external dependency-free, and reasonably
> efficient. The XML parser is a conforming, non-validating XML 1.0
> implementation that is based on tested and proven code. The library
> is released under the MIT license.
> 
> More information, documentation, and source code are available from:
> 
> http://www.codesynthesis.com/projects/libstudxml/
> 
> Or, you can jump directly to the API description with examples:
> 
> http://www.codesynthesis.com/projects/libstudxml/doc/intro.xhtml#2
> 
> Enjoy,
> 	Boris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140521/fb9486c3/attachment.sig>


More information about the Interest mailing list