Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2008-07-03 18:02:46


Hey,

This is not a new issue, but a quick search sees it not reported.

Each of the XML parsers that are available for property_tree has a
problem, with the exception of the TinyXML version (which is annoying
because it requires an external lib).

- RapidXML (the default)

Lines 95 and 98 of xml_parser_read_rapidxml.hpp need to be changed from this:
            if (flags & no_comments)
                doc.parse<parse_normalize_whitespace>(&v.front());
            else
                doc.parse<parse_normalize_whitespace | parse_comment_nodes>(&v.front());

to this:
            if (flags & no_comments)
                doc.template parse<parse_normalize_whitespace>(&v.front());
            else
                doc.template parse<parse_normalize_whitespace | parse_comment_nodes>(&v.front());

Without this change gcc 4.2 won't compile them (not sure about other
versions of gcc).

- PugXML
Line 1827 of pugxml.hpp looks like:
class xml_iterator : public std::_Ranit<_Ty,_Diff,_Pointer,_Reference>

I don't know about anyone else, but my STL doesn't have a _Ranit class, and
depending on non-standard components is a bad idea for portable code.

- Spirit

It fails to parse some XML that is perfectly valid under the RapidXML and
and TinyXML versions. On the plus side, it compiles out of the box ;)

I'm not 100% sure what it is, I get this error:

terminate called after throwing an instance of 'boost::property_tree::xml_parser::xml_parser_error'
  what(): <unspecified file>: invalid character entity
Aborted

Here is a trimmed down XML file that should work fine, and does under rapid
and tiny:
<log>
        <formatter type="literal" name="BEGIN">
                <string>TEMP</string>
        </formatter>

        <appender type="file" name="FILE">
                <filename>test.log</filename>
                <formatter>BEGIN</formatter>
                <truncate>true</truncate>
        </appender>

        <logger name="test">
                <threshold>10</threshold>
                <appender>FILE</appender>
        </logger>

        <fallback>test</fallback>
</log>

I don't see anything specifically wrong with this. Note however, that using
spirit on a DIFFERENT xml file that imho is significantly more complex and larger
parses just fine with spirit (I would paste it, but it >2.5k).

PreZ :)


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