test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelConfigWriter.cc
Go to the documentation of this file.
2 
3 
5 
6 using namespace xercesc;
7 using namespace std;
8 //
9 // -- Constructor
10 //
12 }
13 //
14 // -- Destructor
15 //
17 
18 }
19 //
20 // -- Initialize XML
21 //
23  try {
25  }
26  catch (const XMLException& toCatch) {
27  cout << "Problem to initialise XML !!! " << endl;
28  return false;
29  }
30  DOMImplementation* domImpl = DOMImplementationRegistry::getDOMImplementation(qtxml::_toDOMS("Range"));
31  domWriter = (dynamic_cast<DOMImplementation*>(domImpl))->createDOMWriter();
32  domWriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
33  theDoc = domImpl->createDocument(0,qtxml::_toDOMS("Layouts"), 0);
34  theTopElement = theDoc->getDocumentElement();
35  theTopElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
36  return true;
37 }
38 //
39 // -- Add an Element
40 //
42  lastLayout = theDoc->createElement(qtxml::_toDOMS("layout"));
43  lastLayout->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name));
44  theTopElement->appendChild(lastLayout);
45 }
46 //
47 // -- Add an Element
48 //
50  lastLayout->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
51 
52  lastRow = theDoc->createElement(qtxml::_toDOMS("row"));
53  lastLayout->appendChild(lastRow);
54  lastLayout->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
55 }
56 //
57 // -- Add an Element with Children
58 //
59 void SiPixelConfigWriter::createColumn(string& element, string& name) {
60 
61  lastRow->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
62  DOMElement* e1 = theDoc->createElement(qtxml::_toDOMS("column"));
63  lastRow->appendChild(e1);
64 
65 
66  DOMElement* e2 = theDoc->createElement(qtxml::_toDOMS(element));
67  e2->setAttribute(qtxml::_toDOMS("name"),qtxml::_toDOMS(name));
68  e1->appendChild(e2);
69  }
70 //
71 // -- Write to File
72 //
74  XMLFormatTarget* formTarget = new LocalFileFormatTarget(fname.c_str());
75  domWriter->writeNode(formTarget, *theTopElement);
76  delete formTarget;
77  theDoc->release();
78 
79 
80 }
bool init()
Write XML file.
~SiPixelConfigWriter()
Destructor.
void write(std::string &fname)
void createColumn(std::string &element, std::string &name)
void xercesInitialize()
Definition: Xerces.cc:17
Float e1
Definition: deltaR.h:20
Float e2
Definition: deltaR.h:21
XMLCh * _toDOMS(std::string temp)
string fname
main script
void createLayout(std::string &name)
tuple cout
Definition: gather_cfg.py:145