7 #include <xercesc/dom/DOMNode.hpp> 8 #include <xercesc/dom/DOM.hpp> 9 #include <xercesc/parsers/XercesDOMParser.hpp> 10 #include <xercesc/util/XMLString.hpp> 11 #include <xercesc/sax/SAXException.hpp> 12 #include <xercesc/framework/LocalFileFormatTarget.hpp> 37 XercesDOMParser*
parser =
new XercesDOMParser;
38 parser->setValidationScheme( XercesDOMParser::Val_Never );
39 parser->setDoNamespaces(
false );
40 parser->setDoSchema(
false );
42 parser->parse(filename.c_str());
44 DOMDocument* xmlDoc = parser->getDocument();
46 std::cout <<
"EcalLaserAPDPNRatiosXMLTranslator::Error parsing document" << std::endl;
50 DOMElement* elementRoot = xmlDoc->getDocumentElement();
94 cellnode = cellnode->getNextSibling();
96 while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
97 cellnode = cellnode->getNextSibling();
113 std::fstream fs(filename.c_str(),
ios::out);
125 unique_ptr<DOMImplementation>
impl( DOMImplementationRegistry::getDOMImplementation(
cms::xerces::uStr(
"LS").ptr()));
127 DOMLSSerializer*
writer = impl->createLSSerializer();
128 if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint,
true ))
129 writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint,
true );
131 DOMDocumentType* doctype = impl->createDocumentType(
cms::xerces::uStr(
"XML").ptr(),
nullptr,
nullptr );
133 DOMElement*
root = doc->getDocumentElement();
137 string Lasertag =
"Laser", LMtag =
"LM";
138 for(
int cellid = 0; cellid < (
int)record.
getTimeMap().size(); cellid++) {
140 DOMElement* cellnode = doc->createElement(
cms::xerces::uStr(Lasertag.c_str()).ptr());
141 root->appendChild(cellnode);
142 stringstream value_s;
148 t123[0]=(record.
getTimeMap())[cellid].t1.value();
149 t123[1]=(record.
getTimeMap())[cellid].t2.value();
150 t123[2]=(record.
getTimeMap())[cellid].t3.value();
151 string Laser_t_tag[3] = {
"t1",
"t2",
"t3"};
152 for(
int i = 0;
i < 3;
i++) {
153 time_t
t = t123[
i] >> 32;
156 localtime_r(&t, <);
157 strftime(buf,
sizeof(buf),
"%F %R:%S", <);
158 buf[
sizeof(buf)-1] = 0;
159 DOMDocument* subdoc = cellnode->getOwnerDocument();
160 DOMElement* new_node = subdoc->createElement(
cms::xerces::uStr(Laser_t_tag[
i].c_str()).ptr());
161 cellnode->appendChild(new_node);
162 std::stringstream value_ss;
164 string newstr = value_ss.str() +
" [" +
string(buf) +
"]";
167 new_node->appendChild(tvalue);
178 DOMElement* cellnode=
writeCell(root,rawid);
203 DOMElement* cellnode=
writeCell(root,rawid);
static int readXML(const std::string &filename, EcalCondHeader &header, EcalLaserAPDPNRatios &record)
static std::string dumpXML(const EcalCondHeader &header, const EcalLaserAPDPNRatios &record)
const std::string Laser_p3_tag("p3")
static EEDetId unhashIndex(int hi)
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
static bool validHashIndex(int i)
std::string toString(XMLCh const *toTranscode)
const EcalLaserAPDPNRatiosMap & getLaserMap() const
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
static const int MIN_HASH
const std::string Cell_tag("cell")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
const std::string Laser_p1_tag("p1")
ZStr< XMLCh > uStr(char const *str)
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalLaserAPDPNRatios &record)
const std::string WeightGroups_tag("EcalWeightGroups")
const EcalLaserTimeStampMap & getTimeMap() const
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
const std::string Laser_p2_tag("p2")
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const DetId readCellId(xercesc::DOMElement *node)
Assuming.