4 #include <xercesc/dom/DOMNode.hpp>
5 #include <xercesc/dom/DOM.hpp>
6 #include <xercesc/parsers/XercesDOMParser.hpp>
8 #include <xercesc/util/XMLString.hpp>
9 #include <xercesc/sax/SAXException.hpp>
10 #include <xercesc/framework/LocalFileFormatTarget.hpp>
19 using namespace XERCES_CPP_NAMESPACE;
29 XercesDOMParser*
parser =
new XercesDOMParser;
30 parser->setValidationScheme( XercesDOMParser::Val_Never );
31 parser->setDoNamespaces(
false );
32 parser->setDoSchema(
false );
34 parser->parse(filename.c_str());
36 DOMDocument* xmlDoc = parser->getDocument();
38 std::cout <<
"EcalPedestalsXMLTranslator::Error parsing document" << std::endl;
42 DOMElement* elementRoot = xmlDoc->getDocumentElement();
85 record[detid].mean_x12 = mean12;
86 record[detid].mean_x6 = mean6;
87 record[detid].mean_x1 = mean1;
88 record[detid].rms_x12 = rms12;
89 record[detid].rms_x6 = rms6;
90 record[detid].rms_x1 = rms1;
92 cellnode = cellnode->getNextSibling();
94 while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
95 cellnode = cellnode->getNextSibling();
101 std::cout <<
" nb of channels found in xml file " << chan << std::endl;
108 std::fstream fs(filename.c_str(),
ios::out);
117 DOMImplementation* impl =
118 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
120 DOMWriter* writer =
static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
121 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
123 DOMDocumentType* doctype = impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
127 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
128 doc->setStandalone(
true);
131 DOMElement*
root = doc->getDocumentElement();
140 if (record.
find(rawid) == record.
end())
continue;
141 if(!record[rawid].mean_x12 && !record[rawid].rms_x12)
continue;
143 DOMElement* cellnode=
writeCell(root,rawid);
161 if (record.
find(rawid) == record.
end())
continue;
162 if(!record[rawid].mean_x12 && !record[rawid].rms_x12)
continue;
164 DOMElement* cellnode=
writeCell(root,rawid);
const std::string mean12_tag("mean_x12")
static int readXML(const std::string &filename, EcalCondHeader &header, EcalPedestals &record)
const Items & barrelItems() const
static EEDetId unhashIndex(int hi)
const std::string mean1_tag("mean_x1")
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
static bool validHashIndex(int i)
static std::string dumpXML(const EcalCondHeader &header, const EcalPedestals &record)
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
static const int MIN_HASH
const std::string Cell_tag("cell")
const std::string Pedestals_tag("EcalPedestals")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
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
const std::string mean6_tag("mean_x6")
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
const_iterator find(uint32_t rawId) const
XercesString fromNative(const char *str)
const std::string rms12_tag("rms_x12")
const std::string rms6_tag("rms_x6")
const_iterator end() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const Items & endcapItems() const
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalPedestals &record)
const std::string rms1_tag("rms_x1")
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
std::string toNative(const XMLCh *str)