5 #include <xercesc/dom/DOMNode.hpp>
6 #include <xercesc/dom/DOM.hpp>
7 #include <xercesc/parsers/XercesDOMParser.hpp>
8 #include <xercesc/util/PlatformUtils.hpp>
9 #include <xercesc/util/XMLString.hpp>
10 #include <xercesc/sax/SAXException.hpp>
11 #include <xercesc/framework/LocalFileFormatTarget.hpp>
18 using namespace XERCES_CPP_NAMESPACE;
28 XMLPlatformUtils::Initialize();
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();
41 std::cout <<
"EcalFloatCondObjectContainerXMLTranslator::Error parsing document" << std::endl;
45 DOMElement* elementRoot = xmlDoc->getDocumentElement();
68 cellnode= cellnode->getNextSibling();
70 while (cellnode&& cellnode->getNodeType( ) != DOMNode::ELEMENT_NODE)
71 cellnode= cellnode->getNextSibling();
78 XMLPlatformUtils::Terminate();
89 readXML(filename,header,record);
100 readXML(filename,header,record);
111 const std::vector<float>& eb,
112 const std::vector<float>& ee){
116 std::cerr<<
"Error in EcalFloatCondObjectContainerXMLTranslator::dumpXML, invalid Barrel array size: "
122 std::cerr<<
"Error in EcalFloatCondObjectContainerXMLTranslator::dumpXML, invalid Endcap array size: "
134 record[rawid] = eb[cellid];
146 record[rawid]=ee[cellid];
163 XMLPlatformUtils::Initialize();
165 DOMImplementation* impl =
166 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
169 static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
170 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
172 DOMDocumentType* doctype =
173 impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
178 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
179 doc->setStandalone(
true);
183 DOMElement*
root = doc->getDocumentElement();
193 if (value_ptr==record.
end())
continue;
195 DOMElement* cellnode=
writeCell(root,rawid);
213 if (value_ptr==record.
end())
continue;
216 DOMElement* cellnode=
writeCell(root,rawid);
235 std::fstream fs(filename.c_str(),
ios::out);
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
static std::vector< float > barrelfromXML(const std::string &filename)
const std::string EcalFloatCondObjectContainer_tag("EcalFloatCondObjectContainer")
const Items & barrelItems() const
static EEDetId unhashIndex(int hi)
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string Value_tag("Value")
static bool validHashIndex(int i)
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
static std::string dumpXML(const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
static const int MIN_HASH
const std::string Cell_tag("cell")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
static std::vector< float > endcapfromXML(const std::string &filename)
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
std::vector< Item >::const_iterator const_iterator
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_iterator end() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const Items & endcapItems() const
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
std::string toNative(const XMLCh *str)
string root
initialization