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>
21 using namespace XERCES_CPP_NAMESPACE;
29 std::cout <<
" TPGStripStatus should not be filled out from an xml file ..." << std::endl;
32 XercesDOMParser*
parser =
new XercesDOMParser;
33 parser->setValidationScheme( XercesDOMParser::Val_Never );
34 parser->setDoNamespaces(
false );
35 parser->setDoSchema(
false );
37 parser->parse(filename.c_str());
39 DOMDocument* xmlDoc = parser->getDocument();
41 std::cout <<
"EcalTPGStripStatusXMLTranslator::Error parsing document" << std::endl;
45 DOMElement* elementRoot = xmlDoc->getDocumentElement();
57 std::fstream fs(filename.c_str(),
ios::out);
66 DOMImplementation* impl =
67 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
69 DOMWriter* writer =
static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
70 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
72 DOMDocumentType* doctype = impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
76 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
77 doc->setStandalone(
true);
80 DOMElement*
root = doc->getDocumentElement();
87 std::cout <<
"EcalTPGStripStatusXMLTranslator::dumpXML strip map size " << stripMap.size() << std::endl;
89 for(itSt = stripMap.begin(); itSt != stripMap.end(); ++itSt) {
90 if(itSt->second > 0) {
91 int tccid = itSt->first/8192 & 0x7F;
92 int tt = itSt->first/64 & 0x7F;
93 int pseudostrip = itSt->first/8 & 0x7;
97 DOMElement* cell_node =
101 cell_node->setAttribute(
fromNative(TCC_tag).c_str(),
105 cell_node->setAttribute(
fromNative(TT_tag).c_str(),
108 value_s << pseudostrip;
109 cell_node->setAttribute(
fromNative(ST_tag).c_str(),
111 root->appendChild(cell_node);
const std::map< uint32_t, uint16_t > & getMap() const
static int readXML(const std::string &filename, EcalCondHeader &header, EcalTPGStripStatus &record)
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGStripStatus &record)
const std::string TPGStripStatus_tag("EcalTPGStripStatus")
XercesString fromNative(const char *str)
std::map< uint32_t, uint16_t > EcalTPGStripStatusMap
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalTPGStripStatus &record)
std::string toNative(const XMLCh *str)
std::map< uint32_t, uint16_t >::const_iterator EcalTPGStripStatusMapIterator