Skip to content
Snippets Groups Projects
Commit 9a0279cf authored by Rene Brun's avatar Rene Brun
Browse files

Introduce new package xml.

  Originally proposed by Hans Essel from GSI.
  Main implementation by Sergey Linev from GSI.
  Adaptation to ROOT framework by Rene Brun.

"xml" is an optional package that can be used to write file.xml
instead of file.root. XML files do not have any advantages
compared to the normal ROOT files, except that the information
in these files can be edited via a normal editor.
The main motivation for this new format is to facilitate the
communication with other non ROOT applications. Currently
writing and reading XML files is limited to ROOT applications.
It is our intention to develop a simple reader independent
of the ROOT libraries that could be used as an example for
real applications.
The XML format should be used only for small data volumes,
typically histogram files, pictures, geometries, calibrations.
The XML file is built in memory before being dumped to disk.

Like for normal ROOT files, XML files use the same I/O mechanism
exploiting the ROOT/CINT dictionary. Any class having a dictionary
can be saved in XML format.

This first implementation does not support subdirectories
or Trees.

The shared library libRXML.so may be loaded dynamically
via gSystem->Load("libRXML"). This library is automatically
loaded by the plugin manager as soon as a XML file is created
via, eg
  TFile::Open("file.xml","recreate");
TFile::Open returns a TXMLFile object. When a XML file is open in write mode,
one can use the normal TObject::Write to write an object in the file.
Alternatively one can use the new functions TDirectory::WriteObject and
TDirectory::WriteObjectAny to write a TObject* or any class not deriving
from TObject.

example of a session saving a histogram to a XML file
=====================================================
  TFile *f = TFile::Open("Example.xml","recreate");
  TH1F *h = new TH1F("h","test",1000,-2,2);
  h->FillRandom("gaus");
  h->Write();
  delete f;

example of a session reading the histogram from the file
========================================================
  TFile *f = TFile::Open("Example.xml");
  TH1F *h = (TH1F*)f->Get("h");
  h->Draw();

A new option in the canvas "File" menu is available to save
a TCanvas as a XML file. One can also do
  canvas->Print("Example.xml");

Configuring ROOT with the option "xml"
======================================
The XML package uses the public XML parser and toolkit
from Gnome. You should download the latest version 2-6.9
from http://www.xmlsoft.org/downloads.html.

On Unix systems dowload "libxml2-2.6.9.tar.gz" and create
XMLDIR pointing to the directory libxml2-2.6.9. in the XMLDIR
directory, run the normal
  ./configure
  make

On Windows, from the same web site download
  libxml2-2.6.9.win32.zip
  iconv-1.9.1.win32.zip
unzip the two files, then copy the file iconv.h from the iconv/include file
to $XMLDIR/include. Also copy iconv.dll, iconv.lib and iconv_a.lib
from the iconv/lib directory to $XMLDIR/lib.

You are now ready to configure ROOT with the XML option. do:
  ./configure -enable-xml -enable-xxxxx, etc

documentation
=============
The "xml" package is currently under development. A more complete
documentation will be provided shortly in the classes reference guide.
See classes TXMLFile, TXMLKey, TXMLBuffer, TXMLEngine, TXMLSetup
and TXMLDtdGenerator.
An example of XML file corresponding to the small example below
can be found at http://root.cern.ch/root/Example.xml.


git-svn-id: http://root.cern.ch/svn/root/trunk@8860 27541ba8-7e3a-0410-8455-c3a389f83636
parent 0e2f6896
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment