5 #include <xercesc/dom/DOMNode.hpp>
6 #include <xercesc/dom/DOM.hpp>
7 #include <xercesc/parsers/XercesDOMParser.hpp>
9 #include <xercesc/util/XMLString.hpp>
10 #include <xercesc/sax/SAXException.hpp>
11 #include <xercesc/framework/LocalFileFormatTarget.hpp>
20 using namespace XERCES_CPP_NAMESPACE;
30 XercesDOMParser*
parser =
new XercesDOMParser;
31 parser->setValidationScheme( XercesDOMParser::Val_Never );
32 parser->setDoNamespaces(
false );
33 parser->setDoSchema(
false );
35 parser->parse(filename.c_str());
37 DOMDocument* xmlDoc = parser->getDocument();
39 std::cout <<
"EcalPulseCovariancesXMLTranslator::Error parsing document" << std::endl;
43 DOMElement* elementRoot = xmlDoc->getDocumentElement();
61 pulsecov_tag[
k] = Form(
"samplecov_%d_%d",i,j);
70 cellnode = cellnode->getNextSibling();
72 while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
73 cellnode = cellnode->getNextSibling();
79 std::cout <<
" nb of channels found in xml file " << chan << std::endl;
86 std::fstream fs(filename.c_str(),
ios::out);
95 DOMImplementation* impl =
96 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
98 DOMWriter* writer =
static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
99 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
101 DOMDocumentType* doctype = impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
105 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
106 doc->setStandalone(
true);
109 DOMElement*
root = doc->getDocumentElement();
115 pulsecov_tag[
k] = Form(
"samplecov_%d_%d",i,j);
125 if (record.
find(rawid) == record.
end())
continue;
127 DOMElement* cellnode=
writeCell(root,rawid);
130 WriteNodeWithValue(cellnode,pulsecov_tag[
i*EcalPulseShape::TEMPLATESAMPLES+
j],record[rawid].covval[
i][
j]);
142 if (record.
find(rawid) == record.
end())
continue;
144 DOMElement* cellnode=
writeCell(root,rawid);
147 WriteNodeWithValue(cellnode,pulsecov_tag[
i*EcalPulseShape::TEMPLATESAMPLES+
j],record[rawid].covval[
i][
j]);
static std::string dumpXML(const EcalCondHeader &header, const EcalPulseCovariances &record)
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalPulseCovariances &record)
const Items & barrelItems() const
static const int TEMPLATESAMPLES
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)
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
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
const std::string PulseCovariances_tag("EcalPulseCovariances")
const_iterator find(uint32_t rawId) const
XercesString fromNative(const char *str)
const_iterator end() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
static int readXML(const std::string &filename, EcalCondHeader &header, EcalPulseCovariances &record)
const Items & endcapItems() const
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
std::string toNative(const XMLCh *str)
Power< A, B >::type pow(const A &a, const B &b)
string root
initialization