18 #include <sys/types.h>
21 #include <xercesc/parsers/XercesDOMParser.hpp>
22 #include <xercesc/dom/DOM.hpp>
23 #include <xercesc/sax/HandlerBase.hpp>
24 #include <xercesc/util/XMLString.hpp>
25 #include <xercesc/util/PlatformUtils.hpp>
26 #include <xercesc/dom/DOMNode.hpp>
27 #include <xercesc/framework/StdOutFormatTarget.hpp>
28 #include <xercesc/framework/LocalFileFormatTarget.hpp>
37 XERCES_CPP_NAMESPACE_USE
60 extention_table_name =
"HCAL_TRIG_PRIM_LOOKUP_TABLES";
61 name =
"HCAL trigger primitive lookup table";
69 tag_name =
"dummy tag";
70 detector_name =
"HCAL";
71 comment_description =
"empty comment";
79 created_by_user = getpwuid( getuid() ) -> pw_name;
85 DOMDocument * loader = result -> getDocument();
88 loader -> getElementsByTagName( _toXMLCh(
"NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh(
"HCAL LMAP for HB, HE, HF" ) );
97 DOMDocument * loader = doc -> getDocument();
98 DOMElement *
root = loader -> getDocumentElement();
101 DOMDocument * dataSet = dataSetDoc . getDocument();
104 dataSet -> getElementsByTagName( _toXMLCh(
"SIDE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> side ) );
105 dataSet -> getElementsByTagName( _toXMLCh(
"ETA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
eta) );
106 dataSet -> getElementsByTagName( _toXMLCh(
"PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
phi ) );
107 dataSet -> getElementsByTagName( _toXMLCh(
"DELTA_PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dphi ) );
109 dataSet -> getElementsByTagName( _toXMLCh(
"DEPTH" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> depth ) );
110 dataSet -> getElementsByTagName( _toXMLCh(
"SUBDETECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> det ) );
111 dataSet -> getElementsByTagName( _toXMLCh(
"RBX_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rbx ) );
112 dataSet -> getElementsByTagName( _toXMLCh(
"WEDGE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> wedge ) );
114 dataSet -> getElementsByTagName( _toXMLCh(
"RM_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
rm ) );
115 dataSet -> getElementsByTagName( _toXMLCh(
"HPD_PIXEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> pixel ) );
116 dataSet -> getElementsByTagName( _toXMLCh(
"QIE_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> qie ) );
117 dataSet -> getElementsByTagName( _toXMLCh(
"ADC" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
adc ) );
118 dataSet -> getElementsByTagName( _toXMLCh(
"RM_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rm_fi ) );
120 dataSet -> getElementsByTagName( _toXMLCh(
"FIBER_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fi_ch));
121 dataSet -> getElementsByTagName( _toXMLCh(
"CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> crate ) );
122 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> htr ) );
123 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_FPGA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fpga ) );
125 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> htr_fi ));
126 dataSet -> getElementsByTagName( _toXMLCh(
"DCC_SL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dcc_sl ) );
127 dataSet -> getElementsByTagName( _toXMLCh(
"SPIGOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> spigo ) );
128 dataSet -> getElementsByTagName( _toXMLCh(
"DCC_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dcc ) );
129 dataSet -> getElementsByTagName( _toXMLCh(
"SLB_SITE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> slb ) );
130 dataSet -> getElementsByTagName( _toXMLCh(
"SLB_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> slbin ));
131 dataSet -> getElementsByTagName( _toXMLCh(
"SLB_CHANNEL2" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> slbin2));
133 dataSet -> getElementsByTagName( _toXMLCh(
"SLB_CABLE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> slnam ) );
134 dataSet -> getElementsByTagName( _toXMLCh(
"RCT_CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rctcra ) );
135 dataSet -> getElementsByTagName( _toXMLCh(
"RCT_CARD" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rctcar ) );
136 dataSet -> getElementsByTagName( _toXMLCh(
"RCT_CONNECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->rctcon));
137 dataSet -> getElementsByTagName( _toXMLCh(
"RCT_NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rctnam ) );
138 dataSet -> getElementsByTagName( _toXMLCh(
"FED_ID" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fedid ) );
142 DOMNode * cloneDataSet = loader -> importNode( dataSet -> getDocumentElement(),
true );
143 root -> appendChild( cloneDataSet );
151 DOMDocument * loader = result -> getDocument();
154 loader -> getElementsByTagName( _toXMLCh(
"NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh(
"HCAL LMAP for HO" ) );
163 DOMDocument * loader = doc -> getDocument();
164 DOMElement *
root = loader -> getDocumentElement();
167 DOMDocument * dataSet = dataSetDoc . getDocument();
170 dataSet -> getElementsByTagName( _toXMLCh(
"SIDE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> sideO ) );
171 dataSet -> getElementsByTagName( _toXMLCh(
"ETA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> etaO ) );
172 dataSet -> getElementsByTagName( _toXMLCh(
"PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> phiO ) );
173 dataSet -> getElementsByTagName( _toXMLCh(
"DELTA_PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dphiO ) );
175 dataSet -> getElementsByTagName( _toXMLCh(
"DEPTH" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> depthO ) );
176 dataSet -> getElementsByTagName( _toXMLCh(
"SUBDETECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> detO ) );
177 dataSet -> getElementsByTagName( _toXMLCh(
"RBX_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rbxO ) );
178 dataSet -> getElementsByTagName( _toXMLCh(
"SECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> sectorO ) );
180 dataSet -> getElementsByTagName( _toXMLCh(
"RM_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rmO ) );
181 dataSet -> getElementsByTagName( _toXMLCh(
"HPD_PIXEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> pixelO ) );
182 dataSet -> getElementsByTagName( _toXMLCh(
"QIE_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> qieO ) );
183 dataSet -> getElementsByTagName( _toXMLCh(
"ADC" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> adcO ) );
184 dataSet -> getElementsByTagName( _toXMLCh(
"RM_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rm_fiO ) );
185 dataSet -> getElementsByTagName( _toXMLCh(
"FIBER_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->fi_chO));
187 dataSet -> getElementsByTagName( _toXMLCh(
"LETTER_CODE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh(row ->let_codeO));
188 dataSet -> getElementsByTagName( _toXMLCh(
"CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> crateO ) );
189 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> htrO ) );
190 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_FPGA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fpgaO ) );
192 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> htr_fiO ) );
193 dataSet -> getElementsByTagName( _toXMLCh(
"DCC_SL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dcc_slO ) );
194 dataSet -> getElementsByTagName( _toXMLCh(
"SPIGOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> spigoO ) );
195 dataSet -> getElementsByTagName( _toXMLCh(
"DCC_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dccO ) );
196 dataSet -> getElementsByTagName( _toXMLCh(
"FED_ID" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fedidO ) );
200 DOMNode * cloneDataSet = loader -> importNode( dataSet -> getDocumentElement(),
true );
201 root -> appendChild( cloneDataSet );
208 DOMDocument * loader = doc -> getDocument();
212 _t = serializeDOM( loader, target );
222 XMLDOMBlock dataBlock(
"HCAL_TRIG_PRIM_LOOKUP_TABLE.datablock.template" );
224 DOMDocument * dataBlockDocument = dataBlock . getDocument();
226 std::cout <<
"===> Tag length: " << dataBlockDocument -> getElementsByTagName( _toXMLCh(
"CREATED_BY_USER" ) ) -> getLength() << std::endl;
227 std::cout <<
"===> Tag name: " << XMLString::transcode( dataBlockDocument -> getElementsByTagName( _toXMLCh(
"CREATED_BY_USER" ) ) -> item(0) -> getNodeName() ) << std::endl;
228 dataBlockDocument -> getElementsByTagName( _toXMLCh(
"CREATED_BY_USER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh(
"kukarzev test" ) );
231 _t = serializeDOM( dataBlockDocument );
242 XMLString::transcode(
"LS", tempStr, 99);
243 DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
244 DOMWriter* theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
246 if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
true))
247 theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
true);
249 if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true))
250 theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
252 XMLFormatTarget * myFormTarget = 0;
254 if ( target ==
"stdout" || target ==
"string" )
256 myFormTarget =
new StdOutFormatTarget();
264 myFormTarget =
new LocalFileFormatTarget( _toXMLCh( target ) );
268 if ( target ==
"string" ){
269 _string = theSerializer->writeToString( *node );
272 theSerializer->writeNode(myFormTarget, *node);
275 catch (
const XMLException& toCatch) {
276 char*
message = XMLString::transcode(toCatch.getMessage());
282 catch (
const DOMException& toCatch) {
283 char*
message = XMLString::transcode(toCatch.msg);
294 theSerializer->release();
295 if ( myFormTarget )
delete myFormTarget;
303 XMLPlatformUtils::Initialize();
309 catch (
const XMLException& toCatch) {
310 std::cout <<
" FAILED! Exiting..." << std::endl;
328 XMLPlatformUtils::Terminate();
int adc(sample_type sample)
get the ADC sample (12 bits)
XMLDOMBlock * createLMapHBEFXMLBase(std::string templateFileName)
int addLMapHBEFDataset(XMLDOMBlock *doc, LMapRowHBEF *row, std::string templateFileName)
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
XMLCh * serializeDOM(DOMNode *node, std::string target="stdout")
string root
initialization