lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] change file formats to XML


From: Greg Chicares
Subject: Re: [lmi] change file formats to XML
Date: Mon, 15 Mar 2010 14:47:59 +0000
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

On 2010-03-08 14:45Z, Vaclav Slavik wrote:
> 
> On Mon, 2010-03-08 at 14:07 +0000, Greg Chicares wrote:
>> Assuming we want to make the distinction at all, wouldn't it be
>> more precise to use xml::element in all these (and similar) cases?
> 
> On one hand, it does make sense to use xml::element here, as we know
> that elements are used. On the other hand, xml_serialize::type_io<>
> interface must use xml::node, because it sometimes serializes into plain
> text nodes.

I keep staring at this, but I just don't see it. Can you show me a
concrete example where type_io<> serializes into a plain text node?

For example:

<?xml version="1.0"?>
<product>
  <DatabaseFilename>sample.xdb4</DatabaseFilename>

Obviously "sample.xdb4" is text, but it's contained in a element-node,
and that <DatabaseFilename> element is what's added to the <product>
element here in 'ihs_proddata.cpp':

    #define ADD_PROP(name) xml_serialize::add_property(root, #name, name)
    ADD_PROP(DatabaseFilename);

And, in 'xml_serialize.hpp', that calls:

    template<typename T>
    void add_property
        (xml::element& root
        ,const char* prop
        ,T const& value)
    {
        xml::element node(prop);
        to_xml(node, value);
        root.push_back(node);
    }

which calls:

        static void to_xml(xml::node& out, T const& in)
        {
        ...
            out.set_content(s.str().c_str());
        }

At first, I thought that line was setting the content of a non-element
node; however, this message
  http://lists.nongnu.org/archive/html/lmi/2010-03/msg00010.html
patches it as follows:

-            out.set_content(s.str().c_str());
+            out.push_back(xml::node(xml::node::text(s.str().c_str())));

and if 'out' has a child node, then it has to be an element AIUI.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]