C++ namespaces in XML files

From: Alexander Voigt <Alexander.Voigt_at_cern.ch>
Date: Tue, 20 Jul 2010 21:11:39 +0200


Dear ROOT developers,

I had problems writing correct XML files, which contain objects, that are in another C++ namespace (for example TMVA::). For example the following simple (naive) code creates a non-valid XML file:

#inlude "TXMLFile.h"
#inlude "TMVA/PDEFoam.h"
{

// create TMVA::PDEFoam object

    TMVA::PDEFoam *foam = new TMVA::PDEFoam();
// create XML file

    TXMLFile *file = new TXMLFile("myfoam.xml", "RECREATE", "foamfile");
// save PDEFoam object to XML file

    foam->Write("MyFoam");
    file->Close();
    delete file;
    delete foam;
}

The output XML file contains tags of the form

   <TMVA::PDEFoam version="3"> ... </TMVA::PDEFoam>

which are not valid because of the double colons in the tag name. I found that using the ROOT XML coding "3xoo", i.e.

   TXMLFile *file = new TXMLFile("myfoam.xml", "3xoo", "foamfile");

generates valid a XML file.

Since it took me long to spot this, I would like to make a proposal/ recommendation for a small note in the class description of TXMLFile and/or TXMLSetup about the usage "3xoo" in the XML settings to prevent non-valid XML output.

Many thanks in advance,
Alexander Voigt Received on Tue Jul 20 2010 - 21:11:41 CEST

This archive was generated by hypermail 2.2.0 : Wed Jul 21 2010 - 23:50:02 CEST