Opened 12 years ago

Closed 9 years ago

#5211 closed Bugs (wontfix)

XML output of arrays

Reported by: Christian Ceelen <christian.ceelen@…> Owned by: Sebastian Redl
Milestone: To Be Determined Component: property_tree
Version: Boost 1.46.0 Severity: Problem
Keywords: Cc:

Description

The XML writer of the property_tree is not generating valid XML if an attribute in a node is a list of values. {

"numbers" : [

"one", "two", "three", "four"

]

} the xml generated for this looks like: <numbers> <>one</><>two</><>three</><>four</> </numbers>

Change History (2)

comment:1 by Christian Ceelen <christian.ceelen@…>, 12 years ago

sorry for the formating mess above.

The XML writer of the property_tree is not generating valid XML if an attribute in a node is a list of values.

{
    "numbers" : [
        "one", "two", "three", "four"
    ]
}

the xml generated for this looks like:

<numbers> 
<>one</><>two</><>three</><>four</> 
</numbers>

comment:2 by Sebastian Redl, 9 years ago

Resolution: wontfix
Status: newclosed

PTree has no notion of "attribute in a node" or "list of values". It has nodes with data and named children, where the name can be empty.

As such, its match against various existing formats is imperfect.

Your JSON fragment is translated by the JSON parser into a root node with one named child, "numbers", which in turn has four named children, all with the empty name. Neither root nor its child have data; the four leaf nodes have the strings from the JSON array as data.

The XML mapping of PTree generates an element for every named child, with the element name being the name of the child. Since something empty isn't a valid name, nodes with the empty name aren't supported by the PTree XML mapping.

In my ongoing docs improvement project, I will document the restrictions of each mapping more closely, and then implement software checks while writing to make sure nothing invalid is generated. But unnamed children won't be supported for XML writing.

Note: See TracTickets for help on using tickets.