CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
XMLDocument Class Reference

#include <XMLDocument.h>

Classes

class  XercesPlatform
 

Public Member Functions

template<class T >
void addAttribute (DOMElement *fElement, const std::string &fName, const T &fValue)
 
void addData (DOMElement *fData, const HcalPedestal &fItem)
 
void addData (DOMElement *fData, const HcalPedestalWidth &fItem)
 
void addData (DOMElement *fData, const HcalGain &fItem)
 
void addData (DOMElement *fData, const HcalRawGain &fItem)
 
void addData (DOMElement *fData, const HcalGainWidth &fItem)
 
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * createDocument (const std::string &root)
 
const DOMDocument * document ()
 
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getDocument () const
 
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getRootNode () const
 
DOMElement * makeChId (DOMElement *fDataset, DetId fId)
 
DOMElement * makeData (DOMElement *fDataset, const HcalPedestal &fPed, const HcalPedestalWidth &fWidth)
 
DOMElement * makeData (DOMElement *fDataset)
 
DOMElement * makeDataset (DOMElement *fRoot, const std::string &fVersion)
 
DOMElement * makeElement (DOMElement *fRoot)
 
DOMElement * makeElementDataset (DOMElement *fElement, int fXMLId, DetId fDetId, const std::string &fVersion, const std::string &fKind, unsigned long fRun)
 
DOMElement * makeElementIOV (DOMElement *fElement, unsigned long long fIovBegin, unsigned long long fIovEnd=0)
 
DOMElement * makeElementTag (DOMElement *fElement, const std::string &fTagName, const std::string &fDetectorName, const std::string &fComment="Automatically created by HcalDbXml")
 
DOMElement * makeHeader (DOMElement *fRoot, const std::string &fExtensionName, unsigned long fRun)
 
DOMElement * makeMapDataset (DOMElement *fIov, int fXMLId)
 
DOMElement * makeMapIOV (DOMElement *fTag)
 
DOMElement * makeMaps (DOMElement *fRoot)
 
DOMElement * makeMapTag (DOMElement *fMap)
 
DOMElement * makeRun (DOMElement *fHeader, unsigned long fRun)
 
DOMElement * makeType (DOMElement *fHeader, const std::string &fExtensionName)
 
template<class T >
DOMElement * newElement (DOMElement *fParent, const T &fName)
 
template<class T >
DOMElement * newValue (DOMElement *fParent, const std::string &fName, const T &fValue)
 
template<>
bool readAttribute (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name)
 
template<>
bool readAttribute (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name, const bool &defValue)
 
template<>
bool readContent (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node)
 
DOMElement * root ()
 
void streamOut (std::ostream &fOut)
 
template<>
void writeAttribute (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name, const bool &value)
 
template<>
void writeContent (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, const bool &value)
 
 XMLDocument (const std::string &fileName, bool write=false)
 
 XMLDocument (const std::string &fileName, const std::string &command)
 
 XMLDocument ()
 
 ~XMLDocument ()
 

Static Public Member Functions

static bool hasAttribute (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name)
 
template<typename T >
static T readAttribute (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name)
 
template<typename T >
static T readAttribute (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name, const T &defValue)
 
template<typename T >
static T readContent (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node)
 
template<typename T >
static void writeAttribute (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name, const T &value)
 
template<typename T >
static void writeContent (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, const T &value)
 

Private Member Functions

void openForRead (std::unique_ptr< std::istream > &inputStream)
 
void openForWrite (const std::string &fileName)
 

Private Attributes

XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
 
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER HandlerBase > errHandler
 
std::string fileName
 
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl
 
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSourceinputSource
 
DOMDocument * mDoc
 
DOMImplementation * mDom
 
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser > parser
 
std::unique_ptr< XercesPlatformplatform
 
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * rootNode
 
bool write
 

Detailed Description

Definition at line 57 of file HcalDbXml.cc.

Constructor & Destructor Documentation

XMLDocument::XMLDocument ( )

Definition at line 100 of file HcalDbXml.cc.

References mDoc, mDom, and cms::concurrency::xercesInitialize().

101  : mDoc (nullptr)
102  {
104  mDom = DOMImplementationRegistry::getDOMImplementation (transcode ("Core"));
105  mDoc = mDom->createDocument(
106  nullptr, // root element namespace URI.
107  transcode ("ROOT"), // root element name
108  nullptr); // document type object (DTD).
109  }
void xercesInitialize()
Definition: Xerces.cc:18
DOMImplementation * mDom
Definition: HcalDbXml.cc:96
DOMDocument * mDoc
Definition: HcalDbXml.cc:97
XMLDocument::XMLDocument ( const std::string &  fileName,
bool  write = false 
)

Definition at line 145 of file XMLDocument.cc.

References openForRead(), and openForWrite().

145  :
146  platform(new XercesPlatform()), fileName(fileName),
147  write(write), impl(nullptr), doc(nullptr), rootNode(nullptr)
148 {
149  if (write)
151  else {
152  std::unique_ptr<std::istream> inputStream(
153  new std::ifstream(fileName.c_str()));
154  if (!inputStream->good())
155  throw cms::Exception("XMLDocument")
156  << "XML input file \"" << fileName << "\" "
157  "could not be opened for reading."
158  << std::endl;
159  openForRead(inputStream);
160  }
161 }
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl
Definition: XMLDocument.h:74
std::unique_ptr< XercesPlatform > platform
Definition: XMLDocument.h:66
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * rootNode
Definition: XMLDocument.h:77
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
void openForRead(std::unique_ptr< std::istream > &inputStream)
Definition: XMLDocument.cc:215
void openForWrite(const std::string &fileName)
Definition: XMLDocument.cc:261
std::string fileName
Definition: XMLDocument.h:69
XMLDocument::XMLDocument ( const std::string &  fileName,
const std::string &  command 
)

Definition at line 163 of file XMLDocument.cc.

References Exception, FrontierConditions_GlobalTag_cff::file, and openForRead().

164  :
165  platform(new XercesPlatform()), fileName(fileName),
166  write(false), impl(nullptr), doc(nullptr), rootNode(nullptr)
167 {
168  FILE *file = popen(command.c_str(), "r");
169  if (!file)
170  throw cms::Exception("XMLDocument")
171  << "Could not execute XML preprocessing "
172  " command \"" << command << "\"."
173  << std::endl;
174 
175  std::unique_ptr<std::istream> inputStream(
176  new stdio_istream<pclose>(file));
177  if (!inputStream->good())
178  throw cms::Exception("XMLDocument")
179  << "XML preprocessing command \"" << fileName
180  << "\" stream could not be opened for reading."
181  << std::endl;
182 
183  openForRead(inputStream);
184 }
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl
Definition: XMLDocument.h:74
std::unique_ptr< XercesPlatform > platform
Definition: XMLDocument.h:66
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * rootNode
Definition: XMLDocument.h:77
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
void openForRead(std::unique_ptr< std::istream > &inputStream)
Definition: XMLDocument.cc:215
std::string fileName
Definition: XMLDocument.h:69
list command
Definition: mps_check.py:24
XMLDocument::~XMLDocument ( )

Definition at line 186 of file XMLDocument.cc.

References doc, fileName, MatrixUtil::remove(), edmPickEvents::target, write, and cscNeutronWriter_cfi::writer.

187 {
188  if (!write)
189  return;
190 
191  std::unique_ptr<DocReleaser> docReleaser(new DocReleaser(doc));
192 
193  std::unique_ptr<DOMLSSerializer> writer(((DOMImplementationLS*)impl)->createLSSerializer());
194  assert(writer.get());
195 
196  if( writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTDiscardDefaultContent,true))
197  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent,true);
198  if( writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
199  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
200 
201  std::unique_ptr<DOMLSOutput> outputDesc(((DOMImplementationLS*)impl)->createLSOutput());
202  assert(outputDesc.get());
203  outputDesc->setEncoding(XMLUniStr("UTF-8"));
204 
205  try {
206  std::unique_ptr<XMLFormatTarget> target(
207  new LocalFileFormatTarget(fileName.c_str()));
208  outputDesc->setByteStream(target.get());
209  writer->write( doc, outputDesc.get());
210  } catch(...) {
211  std::remove(fileName.c_str());
212  }
213 }
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
std::string fileName
Definition: XMLDocument.h:69
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:212

Member Function Documentation

template<class T >
void XMLDocument::addAttribute ( DOMElement *  fElement,
const std::string &  fName,
const T fValue 
)

Definition at line 124 of file HcalDbXml.cc.

Referenced by makeElementDataset(), makeElementIOV(), makeElementTag(), makeMapDataset(), makeMapIOV(), and makeMapTag().

124  {
125  fElement->setAttribute (transcode (fName), transcode (fValue));
126  }
void XMLDocument::addData ( DOMElement *  fData,
const HcalPedestal fItem 
)

Definition at line 233 of file HcalDbXml.cc.

References HcalPedestal::getValue(), and newValue().

Referenced by dumpObject_().

233  {
234  newValue (fData, "CAPACITOR_0_VALUE", fItem.getValue (0));
235  newValue (fData, "CAPACITOR_1_VALUE", fItem.getValue (1));
236  newValue (fData, "CAPACITOR_2_VALUE", fItem.getValue (2));
237  newValue (fData, "CAPACITOR_3_VALUE", fItem.getValue (3));
238  }
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:21
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
void XMLDocument::addData ( DOMElement *  fData,
const HcalPedestalWidth fItem 
)

Definition at line 240 of file HcalDbXml.cc.

References HcalPedestalWidth::getSigma(), and newValue().

240  {
241  // widths
242  newValue (fData, "SIGMA_0_0", fItem.getSigma (0, 0));
243  newValue (fData, "SIGMA_1_1", fItem.getSigma (1, 1));
244  newValue (fData, "SIGMA_2_2", fItem.getSigma (2, 2));
245  newValue (fData, "SIGMA_3_3", fItem.getSigma (3, 3));
246  newValue (fData, "SIGMA_0_1", fItem.getSigma (0, 1));
247  newValue (fData, "SIGMA_0_2", fItem.getSigma (0, 2));
248  newValue (fData, "SIGMA_0_3", fItem.getSigma (0, 3));
249  newValue (fData, "SIGMA_1_2", fItem.getSigma (1, 2));
250  newValue (fData, "SIGMA_1_3", fItem.getSigma (1, 3));
251  newValue (fData, "SIGMA_2_3", fItem.getSigma (2, 3));
252  }
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
void XMLDocument::addData ( DOMElement *  fData,
const HcalGain fItem 
)

Definition at line 254 of file HcalDbXml.cc.

References HcalGain::getValue(), and newValue().

254  {
255  newValue (fData, "CAPACITOR_0_VALUE", fItem.getValue (0));
256  newValue (fData, "CAPACITOR_1_VALUE", fItem.getValue (1));
257  newValue (fData, "CAPACITOR_2_VALUE", fItem.getValue (2));
258  newValue (fData, "CAPACITOR_3_VALUE", fItem.getValue (3));
259  }
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:22
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
void XMLDocument::addData ( DOMElement *  fData,
const HcalRawGain fItem 
)

Definition at line 261 of file HcalDbXml.cc.

References HcalRawGain::getError(), HcalRawGain::getValue(), HcalRawGain::getVoltage(), newValue(), and HcalRawGain::strStatus().

261  {
262  newValue (fData, "VALUE", fItem.getValue ());
263  newValue (fData, "ERROR", fItem.getError ());
264  newValue (fData, "VOLTAGE", fItem.getVoltage ());
265  newValue (fData, "STATUS", fItem.strStatus ());
266  }
std::string strStatus() const
Definition: HcalRawGain.h:22
float getValue() const
Definition: HcalRawGain.h:18
float getError() const
Definition: HcalRawGain.h:19
float getVoltage() const
Definition: HcalRawGain.h:20
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
void XMLDocument::addData ( DOMElement *  fData,
const HcalGainWidth fItem 
)

Definition at line 268 of file HcalDbXml.cc.

References HcalGainWidth::getValue(), and newValue().

268  {
269  newValue (fData, "CAPACITOR_0_ERROR", fItem.getValue (0));
270  newValue (fData, "CAPACITOR_1_ERROR", fItem.getValue (1));
271  newValue (fData, "CAPACITOR_2_ERROR", fItem.getValue (2));
272  newValue (fData, "CAPACITOR_3_ERROR", fItem.getValue (3));
273  }
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGainWidth.h:21
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
DOMDocument * XMLDocument::createDocument ( const std::string &  root)

Definition at line 268 of file XMLDocument.cc.

References doc, Exception, and rootNode.

Referenced by getRootNode().

269 {
270  if (doc)
271  throw cms::Exception("XMLDocument")
272  << "Document already exists in createDocument."
273  << std::endl;
274 
275  doc = impl->createDocument(nullptr, XMLUniStr(root.c_str()), nullptr);
276  rootNode = doc->getDocumentElement();
277 
278  return doc;
279 }
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * rootNode
Definition: XMLDocument.h:77
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
const DOMDocument * XMLDocument::document ( )

Definition at line 298 of file HcalDbXml.cc.

References mDoc.

298 {return mDoc;}
DOMDocument * mDoc
Definition: HcalDbXml.cc:97
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* XMLDocument::getDocument ( void  ) const
inline

Definition at line 22 of file XMLDocument.h.

References doc, and XERCES_CPP_NAMESPACE_QUALIFIER.

22 { return doc; }
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* XMLDocument::getRootNode ( ) const
inline
bool XMLDocument::hasAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name 
)
static

Definition at line 305 of file XMLDocument.cc.

Referenced by getRootNode().

307 {
308  XMLUniStr uniName(name);
309  return elem->hasAttribute(uniName);
310 }
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
DOMElement * XMLDocument::makeChId ( DOMElement *  fDataset,
DetId  fId 
)

Definition at line 157 of file HcalDbXml.cc.

References funct::abs(), PVValHelper::eta, HcalText2DetIdConverter::getField(), HcalText2DetIdConverter::getField2(), HcalText2DetIdConverter::getField3(), HcalText2DetIdConverter::getFlavor(), newElement(), newValue(), parser, and DetId::rawId().

Referenced by dumpObject_(), and makeElementDataset().

157  {
158  DOMElement* channel = newElement (fDataset, "CHANNEL");
159  newValue (channel, "EXTENSION_TABLE_NAME", "HCAL_CHANNELS");
161  newValue (channel, "DETECTOR_NAME", parser.getFlavor ());
162  int eta = parser.getField (1);
163  newValue (channel, "ETA", abs(eta));
164  newValue (channel, "Z", eta > 0 ? 1 : -1);
165  newValue (channel, "PHI", parser.getField2 ());
166  newValue (channel, "DEPTH", parser.getField3 ());
167  newValue (channel, "HCAL_CHANNEL_ID", fId.rawId());
168  return channel;
169  }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser > parser
Definition: XMLDocument.h:72
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
DOMElement * XMLDocument::makeData ( DOMElement *  fDataset,
const HcalPedestal fPed,
const HcalPedestalWidth fWidth 
)

Definition at line 276 of file HcalDbXml.cc.

References data, HcalPedestalWidth::getSigma(), HcalPedestal::getValue(), newElement(), and newValue().

Referenced by dumpObject_().

276  {
277  DOMElement* data = newElement (fDataset, "DATA");
278  // pedestals
279  newValue (data, "CAPACITOR_0_VALUE", fPed.getValue (0));
280  newValue (data, "CAPACITOR_1_VALUE", fPed.getValue (1));
281  newValue (data, "CAPACITOR_2_VALUE", fPed.getValue (2));
282  newValue (data, "CAPACITOR_3_VALUE", fPed.getValue (3));
283  // widths
284  newValue (data, "SIGMA_0_0", fWidth.getSigma (0, 0));
285  newValue (data, "SIGMA_1_1", fWidth.getSigma (1, 1));
286  newValue (data, "SIGMA_2_2", fWidth.getSigma (2, 2));
287  newValue (data, "SIGMA_3_3", fWidth.getSigma (3, 3));
288  newValue (data, "SIGMA_0_1", fWidth.getSigma (0, 1));
289  newValue (data, "SIGMA_0_2", fWidth.getSigma (0, 2));
290  newValue (data, "SIGMA_0_3", fWidth.getSigma (0, 3));
291  newValue (data, "SIGMA_1_2", fWidth.getSigma (1, 2));
292  newValue (data, "SIGMA_1_3", fWidth.getSigma (1, 3));
293  newValue (data, "SIGMA_2_3", fWidth.getSigma (2, 3));
294  return data;
295  }
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:21
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
DOMElement * XMLDocument::makeData ( DOMElement *  fDataset)

Definition at line 229 of file HcalDbXml.cc.

References newElement().

229  {
230  return newElement (fDataset, "DATA");
231  }
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * XMLDocument::makeDataset ( DOMElement *  fRoot,
const std::string &  fVersion 
)

Definition at line 151 of file HcalDbXml.cc.

References createfilelist::dataset, newElement(), and newValue().

Referenced by dumpObject_().

151  {
152  DOMElement* dataset =newElement (fRoot, "DATA_SET");
153  newValue (dataset, "VERSION", fVersion);
154  return dataset;
155  }
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
DOMElement * XMLDocument::makeElement ( DOMElement *  fRoot)

Definition at line 201 of file HcalDbXml.cc.

References newElement().

Referenced by dumpObject_().

201  {
202  DOMElement* element = newElement (fRoot, "ELEMENTS");
203  return element;
204  }
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * XMLDocument::makeElementDataset ( DOMElement *  fElement,
int  fXMLId,
DetId  fDetId,
const std::string &  fVersion,
const std::string &  fKind,
unsigned long  fRun 
)

Definition at line 171 of file HcalDbXml.cc.

References addAttribute(), createfilelist::dataset, makeChId(), makeRun(), newElement(), and newValue().

Referenced by dumpObject_().

171  {
172  DOMElement* dataset = newElement (fElement, "DATA_SET");
173  addAttribute (dataset, "id", fXMLId);
174  newValue (newElement (dataset, "KIND_OF_CONDITION"), "NAME", fKind);
175  newValue (dataset, "VERSION", fVersion);
176  makeRun (dataset, fRun);
177  makeChId (dataset, fDetId);
178  return dataset;
179  }
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:124
DOMElement * makeRun(DOMElement *fHeader, unsigned long fRun)
Definition: HcalDbXml.cc:144
DOMElement * makeChId(DOMElement *fDataset, DetId fId)
Definition: HcalDbXml.cc:157
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
DOMElement * XMLDocument::makeElementIOV ( DOMElement *  fElement,
unsigned long long  fIovBegin,
unsigned long long  fIovEnd = 0 
)

Definition at line 181 of file HcalDbXml.cc.

References addAttribute(), newElement(), and newValue().

Referenced by dumpObject_().

181  {
182  DOMElement* iov = newElement (fElement, "IOV");
183  addAttribute (iov, "id", IOV_ID);
184  newValue (iov, "INTERVAL_OF_VALIDITY_BEGIN", fIovBegin);
185  if (fIovEnd) {
186  newValue (iov, "INTERVAL_OF_VALIDITY_END", fIovEnd);
187  }
188  return iov;
189  }
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:124
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
DOMElement * XMLDocument::makeElementTag ( DOMElement *  fElement,
const std::string &  fTagName,
const std::string &  fDetectorName,
const std::string &  fComment = "Automatically created by HcalDbXml" 
)

Definition at line 191 of file HcalDbXml.cc.

References addAttribute(), newElement(), newValue(), and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by dumpObject_().

191  {
192  DOMElement* tag = newElement (fElement, "TAG");
193  addAttribute (tag, "id", TAG_ID);
194  addAttribute (tag, "mode", "create");
195  newValue (tag, "TAG_NAME", fTagName);
196  newValue (tag, "DETECTOR_NAME", fDetectorName);
197  newValue (tag, "COMMENT_DESCRIPTION", fComment);
198  return tag;
199  }
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:124
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
DOMElement * XMLDocument::makeHeader ( DOMElement *  fRoot,
const std::string &  fExtensionName,
unsigned long  fRun 
)

Definition at line 130 of file HcalDbXml.cc.

References RecoTauValidation_cfi::header, makeRun(), makeType(), and newElement().

Referenced by dumpObject_().

130  {
131  DOMElement* header = newElement (fRoot, "HEADER");
132  makeType (header, fExtensionName);
133  makeRun (header, fRun);
134  return header;
135  }
DOMElement * makeRun(DOMElement *fHeader, unsigned long fRun)
Definition: HcalDbXml.cc:144
DOMElement * makeType(DOMElement *fHeader, const std::string &fExtensionName)
Definition: HcalDbXml.cc:137
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * XMLDocument::makeMapDataset ( DOMElement *  fIov,
int  fXMLId 
)

Definition at line 223 of file HcalDbXml.cc.

References addAttribute(), and newElement().

Referenced by dumpObject_().

223  {
224  DOMElement* element = newElement (fIov, "DATA_SET");
225  addAttribute (element, "idref", fXMLId);
226  return element;
227  }
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:124
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * XMLDocument::makeMapIOV ( DOMElement *  fTag)

Definition at line 217 of file HcalDbXml.cc.

References addAttribute(), and newElement().

Referenced by dumpObject_().

217  {
218  DOMElement* iov = newElement (fTag, "IOV");
219  addAttribute (iov, "idref", IOV_ID);
220  return iov;
221  }
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:124
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * XMLDocument::makeMaps ( DOMElement *  fRoot)

Definition at line 206 of file HcalDbXml.cc.

References genParticles_cff::map, and newElement().

Referenced by dumpObject_().

206  {
207  DOMElement* map = newElement (fRoot, "MAPS");
208  return map;
209  }
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * XMLDocument::makeMapTag ( DOMElement *  fMap)

Definition at line 211 of file HcalDbXml.cc.

References addAttribute(), newElement(), and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by dumpObject_().

211  {
212  DOMElement* tag = newElement (fMap, "TAG");
213  addAttribute (tag, "idref", TAG_ID);
214  return tag;
215  }
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:124
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * XMLDocument::makeRun ( DOMElement *  fHeader,
unsigned long  fRun 
)

Definition at line 144 of file HcalDbXml.cc.

References newElement(), newValue(), and findQualityFiles::run.

Referenced by makeElementDataset(), and makeHeader().

144  {
145  DOMElement* run =newElement (fHeader, "RUN");
146  newValue (run, "RUN_TYPE", "HcalDbXml");
147  newValue (run, "RUN_NUMBER", fRun);
148  return run;
149  }
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
DOMElement * XMLDocument::makeType ( DOMElement *  fHeader,
const std::string &  fExtensionName 
)

Definition at line 137 of file HcalDbXml.cc.

References newElement(), and newValue().

Referenced by makeHeader().

137  {
138  DOMElement* type = newElement (fHeader, "TYPE");
139  newValue (type, "EXTENSION_TABLE_NAME", extensionTableName (fKind));
140  newValue (type, "NAME", fKind);
141  return type;
142  }
type
Definition: HCALResponse.h:21
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:117
template<class T >
DOMElement * XMLDocument::newElement ( DOMElement *  fParent,
const T fName 
)

Definition at line 111 of file HcalDbXml.cc.

References mDoc.

Referenced by makeChId(), makeData(), makeDataset(), makeElement(), makeElementDataset(), makeElementIOV(), makeElementTag(), makeHeader(), makeMapDataset(), makeMapIOV(), makeMaps(), makeMapTag(), makeRun(), makeType(), and newValue().

111  {
112  DOMElement* element = mDoc->createElement (transcode (fName));
113  fParent->appendChild (element);
114  return element;
115  }
DOMDocument * mDoc
Definition: HcalDbXml.cc:97
template<class T >
DOMElement * XMLDocument::newValue ( DOMElement *  fParent,
const std::string &  fName,
const T fValue 
)

Definition at line 117 of file HcalDbXml.cc.

References mDoc, newElement(), and RecoTauValidation_cfi::text.

Referenced by addData(), makeChId(), makeData(), makeDataset(), makeElementDataset(), makeElementIOV(), makeElementTag(), makeRun(), and makeType().

117  {
118  DOMElement* element = newElement (fParent, fName);
119  DOMText* text = mDoc->createTextNode (transcode (fValue));
120  element->appendChild (text);
121  return element;
122  }
DOMDocument * mDoc
Definition: HcalDbXml.cc:97
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:111
void XMLDocument::openForRead ( std::unique_ptr< std::istream > &  inputStream)
private

Definition at line 215 of file XMLDocument.cc.

References doc, MillePedeFileConverter_cfg::e, errHandler, Exception, inputSource, parser, and rootNode.

Referenced by XMLDocument().

216 {
217  parser.reset(new XercesDOMParser());
218  parser->setValidationScheme(XercesDOMParser::Val_Auto);
219  parser->setDoNamespaces(false);
220  parser->setDoSchema(false);
221  parser->setValidationSchemaFullChecking(false);
222  errHandler.reset(new HandlerBase());
223  parser->setErrorHandler(errHandler.get());
224  parser->setCreateEntityReferenceNodes(false);
225 
226  inputSource.reset(new STLInputSource(stream));
227 
228  try {
229  parser->parse(*inputSource);
230  if (parser->getErrorCount())
231  throw cms::Exception("XMLDocument")
232  << "XML parser reported errors."
233  << std::endl;
234  } catch(const XMLException &e) {
235  throw cms::Exception("XMLDocument")
236  << "XML parser reported DOM error no. "
237  << (unsigned long)e.getCode()
238  << ": " << XMLSimpleStr(e.getMessage()) << "."
239  << std::endl;
240  } catch(const SAXException &e) {
241  throw cms::Exception("XMLDocument")
242  << "XML parser reported: "
243  << XMLSimpleStr(e.getMessage()) << "."
244  << std::endl;
245  }
246 
247  doc = parser->getDocument();
248 
249  DOMNode *node = doc->getFirstChild();
250  while(node && node->getNodeType() != DOMNode::ELEMENT_NODE)
251  node = node->getNextSibling();
252 
253  if (!node)
254  throw cms::Exception("XMLDocument")
255  << "XML document didn't contain a valid "
256  << "root node." << std::endl;
257 
258  rootNode = static_cast<DOMElement*>(node);
259 }
XMLInputSourceWrapper< STLInputStream > STLInputSource
Definition: XMLUtils.h:202
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > inputSource
Definition: XMLDocument.h:67
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * rootNode
Definition: XMLDocument.h:77
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER HandlerBase > errHandler
Definition: XMLDocument.h:73
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser > parser
Definition: XMLDocument.h:72
void XMLDocument::openForWrite ( const std::string &  fileName)
private

Definition at line 261 of file XMLDocument.cc.

Referenced by XMLDocument().

262 {
263  impl = DOMImplementationRegistry::getDOMImplementation(
264  XMLUniStr("LS"));
265  assert(impl);
266 }
template<typename T >
static T XMLDocument::readAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name 
)
static

Referenced by getRootNode().

template<typename T >
static T XMLDocument::readAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name,
const T defValue 
)
static
template<>
bool XMLDocument::readAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name 
)

Definition at line 313 of file XMLDocument.cc.

References isBool().

316 {
317  XMLUniStr uniName(name);
318  if (!elem->hasAttribute(uniName))
319  throw cms::Exception("MVAComputer")
320  << "Missing attribute " << name << " in tag "
321  << XMLSimpleStr(elem->getNodeName())
322  << "." << std::endl;
323  const XMLCh *attribute = elem->getAttribute(uniName);
324  return isBool(XMLSimpleStr(attribute));
325 }
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
static bool isBool(std::string value)
Definition: XMLDocument.cc:283
template<>
bool XMLDocument::readAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name,
const bool &  defValue 
)

Definition at line 328 of file XMLDocument.cc.

References isBool().

331 {
332  XMLUniStr uniName(name);
333  if (!elem->hasAttribute(uniName))
334  return defValue;
335  const XMLCh *attribute = elem->getAttribute(uniName);
336  return isBool(XMLSimpleStr(attribute));
337 }
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
static bool isBool(std::string value)
Definition: XMLDocument.cc:283
template<typename T >
static T XMLDocument::readContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node)
static

Referenced by getRootNode().

template<>
bool XMLDocument::readContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node)

Definition at line 348 of file XMLDocument.cc.

References ws_sso_content_reader::content, and isBool().

350 {
351  const XMLCh *content = node->getTextContent();
352  return isBool(XMLSimpleStr(content));
353 }
static bool isBool(std::string value)
Definition: XMLDocument.cc:283
DOMElement * XMLDocument::root ( )

Definition at line 128 of file HcalDbXml.cc.

References mDoc.

Referenced by dumpObject_(), and streamOut().

128 { return mDoc->getDocumentElement();}
DOMDocument * mDoc
Definition: HcalDbXml.cc:97
void XMLDocument::streamOut ( std::ostream &  fOut)

Definition at line 300 of file HcalDbXml.cc.

References mDoc, mDom, and root().

Referenced by dumpObject_().

300  {
301  StreamOutFormatTarget formTarget (fOut);
302  DOMLSSerializer* domWriter = mDom->createLSSerializer();
303  DOMConfiguration* dc = domWriter->getDomConfig();
304  dc->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
305 
306  DOMLSOutput* outputDesc = ((DOMImplementationLS*)mDom)->createLSOutput();
307  outputDesc->setByteStream(&formTarget);
308 
309  domWriter->write (root(), outputDesc);
310  mDoc->release ();
311  }
DOMImplementation * mDom
Definition: HcalDbXml.cc:96
DOMDocument * mDoc
Definition: HcalDbXml.cc:97
DOMElement * root()
Definition: HcalDbXml.cc:128
template<typename T >
static void XMLDocument::writeAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name,
const T value 
)
static

Referenced by getRootNode().

template<>
void XMLDocument::writeAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name,
const bool &  value 
)

Definition at line 340 of file XMLDocument.cc.

References makeBool().

343 {
344  elem->setAttribute(XMLUniStr(name), XMLUniStr(makeBool(value)));
345 }
static const char * makeBool(bool value)
Definition: XMLDocument.cc:300
Definition: value.py:1
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
template<typename T >
static void XMLDocument::writeContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
const T value 
)
static

Referenced by getRootNode().

template<>
void XMLDocument::writeContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
const bool &  value 
)

Definition at line 356 of file XMLDocument.cc.

References makeBool().

360 {
361  node->appendChild(doc->createTextNode(XMLUniStr(makeBool(value))));
362 }
static const char * makeBool(bool value)
Definition: XMLDocument.cc:300
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
Definition: value.py:1

Member Data Documentation

XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* XMLDocument::doc
private
std::unique_ptr<XERCES_CPP_NAMESPACE_QUALIFIER HandlerBase> XMLDocument::errHandler
private

Definition at line 73 of file XMLDocument.h.

Referenced by openForRead().

std::string XMLDocument::fileName
private

Definition at line 69 of file XMLDocument.h.

Referenced by ~XMLDocument().

XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation* XMLDocument::impl
private

Definition at line 74 of file XMLDocument.h.

std::unique_ptr<XERCES_CPP_NAMESPACE_QUALIFIER InputSource> XMLDocument::inputSource
private

Definition at line 67 of file XMLDocument.h.

Referenced by openForRead().

DOMDocument* XMLDocument::mDoc
private

Definition at line 97 of file HcalDbXml.cc.

Referenced by document(), newElement(), newValue(), root(), streamOut(), and XMLDocument().

DOMImplementation* XMLDocument::mDom
private

Definition at line 96 of file HcalDbXml.cc.

Referenced by streamOut(), and XMLDocument().

std::unique_ptr<XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser> XMLDocument::parser
private

Definition at line 72 of file XMLDocument.h.

Referenced by makeChId(), and openForRead().

std::unique_ptr<XercesPlatform> XMLDocument::platform
private

Definition at line 66 of file XMLDocument.h.

XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* XMLDocument::rootNode
private

Definition at line 77 of file XMLDocument.h.

Referenced by createDocument(), getRootNode(), and openForRead().

bool XMLDocument::write
private