It appears that boost/property_tree xml writer doesn't have a support for xml stylesheets processing instructions. First line (xml version) is simply hardcoded in the write_xml_internal function.
So I've just written my own write xml function, which is doing exactly the same, plus adds xml stylesheet.
void WriteXML(std::ostream &output, ptree &root)
{
boost::property_tree::xml_writer_settings<char> settings('', 1);
output << "<?xml version="1.0" encoding="";
output << settings.encoding;
output << ""?>
";
output << "<?xml-stylesheet type="text/xsl" href="report.xsl"?>
";
write_xml_element(output, std::basic_string<ptree::key_type::value_type>(), root, -1, settings);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…