17 #include <sys/types.h> 20 #include <xercesc/parsers/XercesDOMParser.hpp> 21 #include <xercesc/dom/DOM.hpp> 22 #include <xercesc/sax/HandlerBase.hpp> 23 #include <xercesc/util/XMLString.hpp> 25 #include <xercesc/dom/DOMNode.hpp> 26 #include <xercesc/framework/StdOutFormatTarget.hpp> 27 #include <xercesc/framework/LocalFileFormatTarget.hpp> 56 extention_table_name =
"HCAL_TRIG_PRIM_LOOKUP_TABLES";
57 name =
"HCAL trigger primitive lookup table";
65 tag_name =
"dummy tag";
66 detector_name =
"HCAL";
67 comment_description =
"empty comment";
73 create_timestamp =
time(
nullptr);
74 created_by_user = getpwuid(getuid())->pw_name;
82 loader->getElementsByTagName(_toXMLCh(
"NAME"))
85 ->setNodeValue(_toXMLCh(
"HCAL LMAP for HB, HE, HF"));
94 DOMElement*
root = loader->getDocumentElement();
100 dataSet->getElementsByTagName(_toXMLCh(
"SIDE"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
side));
101 dataSet->getElementsByTagName(_toXMLCh(
"ETA"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
eta));
102 dataSet->getElementsByTagName(_toXMLCh(
"PHI"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
phi));
103 dataSet->getElementsByTagName(_toXMLCh(
"DELTA_PHI"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
dphi));
105 dataSet->getElementsByTagName(_toXMLCh(
"DEPTH"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
depth));
106 dataSet->getElementsByTagName(_toXMLCh(
"SUBDETECTOR"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
det));
107 dataSet->getElementsByTagName(_toXMLCh(
"RBX_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rbx));
108 dataSet->getElementsByTagName(_toXMLCh(
"WEDGE"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
wedge));
110 dataSet->getElementsByTagName(_toXMLCh(
"RM_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rm));
111 dataSet->getElementsByTagName(_toXMLCh(
"HPD_PIXEL"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
pixel));
112 dataSet->getElementsByTagName(_toXMLCh(
"QIE_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
qie));
113 dataSet->getElementsByTagName(_toXMLCh(
"ADC"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
adc));
114 dataSet->getElementsByTagName(_toXMLCh(
"RM_FIBER"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rm_fi));
116 dataSet->getElementsByTagName(_toXMLCh(
"FIBER_CHANNEL"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
fi_ch));
117 dataSet->getElementsByTagName(_toXMLCh(
"CRATE"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
crate));
118 dataSet->getElementsByTagName(_toXMLCh(
"HTR_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
htr));
119 dataSet->getElementsByTagName(_toXMLCh(
"HTR_FPGA"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
fpga));
121 dataSet->getElementsByTagName(_toXMLCh(
"HTR_FIBER"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
htr_fi));
122 dataSet->getElementsByTagName(_toXMLCh(
"DCC_SL"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
dcc_sl));
123 dataSet->getElementsByTagName(_toXMLCh(
"SPIGOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
spigo));
124 dataSet->getElementsByTagName(_toXMLCh(
"DCC_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
dcc));
125 dataSet->getElementsByTagName(_toXMLCh(
"SLB_SITE"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
slb));
126 dataSet->getElementsByTagName(_toXMLCh(
"SLB_CHANNEL"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
slbin));
127 dataSet->getElementsByTagName(_toXMLCh(
"SLB_CHANNEL2"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
slbin2));
129 dataSet->getElementsByTagName(_toXMLCh(
"SLB_CABLE"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
slnam));
130 dataSet->getElementsByTagName(_toXMLCh(
"RCT_CRATE"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rctcra));
131 dataSet->getElementsByTagName(_toXMLCh(
"RCT_CARD"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rctcar));
132 dataSet->getElementsByTagName(_toXMLCh(
"RCT_CONNECTOR"))
135 ->setNodeValue(_toXMLCh(row->
rctcon));
136 dataSet->getElementsByTagName(_toXMLCh(
"RCT_NAME"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rctnam));
137 dataSet->getElementsByTagName(_toXMLCh(
"FED_ID"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
fedid));
140 DOMNode* cloneDataSet = loader->importNode(dataSet->getDocumentElement(),
true);
141 root->appendChild(cloneDataSet);
151 loader->getElementsByTagName(_toXMLCh(
"NAME"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(
"HCAL LMAP for HO"));
160 DOMElement*
root = loader->getDocumentElement();
166 dataSet->getElementsByTagName(_toXMLCh(
"SIDE"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
sideO));
167 dataSet->getElementsByTagName(_toXMLCh(
"ETA"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
etaO));
168 dataSet->getElementsByTagName(_toXMLCh(
"PHI"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
phiO));
169 dataSet->getElementsByTagName(_toXMLCh(
"DELTA_PHI"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
dphiO));
171 dataSet->getElementsByTagName(_toXMLCh(
"DEPTH"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
depthO));
172 dataSet->getElementsByTagName(_toXMLCh(
"SUBDETECTOR"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
detO));
173 dataSet->getElementsByTagName(_toXMLCh(
"RBX_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rbxO));
174 dataSet->getElementsByTagName(_toXMLCh(
"SECTOR"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
sectorO));
176 dataSet->getElementsByTagName(_toXMLCh(
"RM_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rmO));
177 dataSet->getElementsByTagName(_toXMLCh(
"HPD_PIXEL"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
pixelO));
178 dataSet->getElementsByTagName(_toXMLCh(
"QIE_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
qieO));
179 dataSet->getElementsByTagName(_toXMLCh(
"ADC"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
adcO));
180 dataSet->getElementsByTagName(_toXMLCh(
"RM_FIBER"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
rm_fiO));
181 dataSet->getElementsByTagName(_toXMLCh(
"FIBER_CHANNEL"))
184 ->setNodeValue(_toXMLCh(row->
fi_chO));
186 dataSet->getElementsByTagName(_toXMLCh(
"LETTER_CODE"))
189 ->setNodeValue(_toXMLCh(row->
let_codeO));
190 dataSet->getElementsByTagName(_toXMLCh(
"CRATE"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
crateO));
191 dataSet->getElementsByTagName(_toXMLCh(
"HTR_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
htrO));
192 dataSet->getElementsByTagName(_toXMLCh(
"HTR_FPGA"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
fpgaO));
194 dataSet->getElementsByTagName(_toXMLCh(
"HTR_FIBER"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
htr_fiO));
195 dataSet->getElementsByTagName(_toXMLCh(
"DCC_SL"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
dcc_slO));
196 dataSet->getElementsByTagName(_toXMLCh(
"SPIGOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
spigoO));
197 dataSet->getElementsByTagName(_toXMLCh(
"DCC_SLOT"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
dccO));
198 dataSet->getElementsByTagName(_toXMLCh(
"FED_ID"))->item(0)->getFirstChild()->setNodeValue(_toXMLCh(row->
fedidO));
201 DOMNode* cloneDataSet = loader->importNode(dataSet->getDocumentElement(),
true);
202 root->appendChild(cloneDataSet);
212 _t = serializeDOM(loader, target);
221 XMLDOMBlock dataBlock(
"HCAL_TRIG_PRIM_LOOKUP_TABLE.datablock.template");
223 DOMDocument* dataBlockDocument = dataBlock.
getDocument();
225 std::cout <<
"===> Tag length: " << dataBlockDocument->getElementsByTagName(_toXMLCh(
"CREATED_BY_USER"))->getLength()
228 << XMLString::transcode(
229 dataBlockDocument->getElementsByTagName(_toXMLCh(
"CREATED_BY_USER"))->item(0)->getNodeName())
231 dataBlockDocument->getElementsByTagName(_toXMLCh(
"CREATED_BY_USER"))
234 ->setNodeValue(_toXMLCh(
"kukarzev test"));
237 _t = serializeDOM(dataBlockDocument);
247 XMLString::transcode(
"LS", tempStr, 99);
248 DOMImplementation*
impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
249 DOMLSSerializer* theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
250 DOMConfiguration* dc = theSerializer->getDomConfig();
251 dc->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent,
true);
252 dc->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
254 XMLFormatTarget* myFormTarget =
nullptr;
255 XMLCh* _string =
nullptr;
256 if (target ==
"stdout" || target ==
"string") {
257 myFormTarget =
new StdOutFormatTarget();
264 myFormTarget =
new LocalFileFormatTarget(_toXMLCh(target));
268 if (target ==
"string") {
269 _string = theSerializer->writeToString(node);
271 DOMLSOutput* outputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
272 outputDesc->setByteStream(myFormTarget);
273 theSerializer->write(node, outputDesc);
275 }
catch (
const XMLException& toCatch) {
276 char* message = XMLString::transcode(toCatch.getMessage());
277 std::cout <<
"Exception message is: \n" << message <<
"\n";
280 }
catch (
const DOMException& toCatch) {
281 char* message = XMLString::transcode(toCatch.msg);
282 std::cout <<
"Exception message is: \n" << message <<
"\n";
290 theSerializer->release();
304 }
catch (
const XMLException& toCatch) {
305 std::cout <<
" FAILED! Exiting..." << std::endl;
XMLCh * serializeDOM(XERCES_CPP_NAMESPACE::DOMNode *node, std::string target="stdout")
XMLDOMBlock * createLMapHBEFXMLBase(std::string templateFileName)
int addLMapHBEFDataset(XMLDOMBlock *doc, LMapRowHBEF *row, std::string templateFileName)
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
int addLMapHODataset(XMLDOMBlock *doc, LMapRowHO *row, std::string templateFileName)
XMLDOMBlock * createLMapHOXMLBase(std::string templateFileName)
int write(XMLDOMBlock *doc, std::string target="stdout")
static XMLProcessor * instance