CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::auto_ptr< std::istream > &inputStream)
 
void openForWrite (const std::string &fileName)
 

Private Attributes

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

Detailed Description

Definition at line 55 of file HcalDbXml.cc.

Constructor & Destructor Documentation

XMLDocument::XMLDocument ( )

Definition at line 98 of file HcalDbXml.cc.

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

99  : mDoc (0)
100  {
102  mDom = DOMImplementationRegistry::getDOMImplementation (transcode ("Core"));
103  mDoc = mDom->createDocument(
104  0, // root element namespace URI.
105  transcode ("ROOT"), // root element name
106  0); // document type object (DTD).
107  }
void xercesInitialize()
Definition: Xerces.cc:17
DOMImplementation * mDom
Definition: HcalDbXml.cc:94
DOMDocument * mDoc
Definition: HcalDbXml.cc:95
XMLDocument::XMLDocument ( const std::string &  fileName,
bool  write = false 
)

Definition at line 143 of file XMLDocument.cc.

References openForRead(), and openForWrite().

143  :
144  platform(new XercesPlatform()), fileName(fileName),
145  write(write), impl(0), doc(0), rootNode(0)
146 {
147  if (write)
149  else {
150  std::auto_ptr<std::istream> inputStream(
151  new std::ifstream(fileName.c_str()));
152  if (!inputStream->good())
153  throw cms::Exception("XMLDocument")
154  << "XML input file \"" << fileName << "\" "
155  "could not be opened for reading."
156  << std::endl;
157  openForRead(inputStream);
158  }
159 }
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl
Definition: XMLDocument.h:74
std::auto_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 openForWrite(const std::string &fileName)
Definition: XMLDocument.cc:259
std::string fileName
Definition: XMLDocument.h:69
void openForRead(std::auto_ptr< std::istream > &inputStream)
Definition: XMLDocument.cc:212
XMLDocument::XMLDocument ( const std::string &  fileName,
const std::string &  command 
)

Definition at line 161 of file XMLDocument.cc.

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

162  :
163  platform(new XercesPlatform()), fileName(fileName),
164  write(false), impl(0), doc(0), rootNode(0)
165 {
166  FILE *file = popen(command.c_str(), "r");
167  if (!file)
168  throw cms::Exception("XMLDocument")
169  << "Could not execute XML preprocessing "
170  " command \"" << command << "\"."
171  << std::endl;
172 
173  std::auto_ptr<std::istream> inputStream(
174  new stdio_istream<pclose>(file));
175  if (!inputStream->good())
176  throw cms::Exception("XMLDocument")
177  << "XML preprocessing command \"" << fileName
178  << "\" stream could not be opened for reading."
179  << std::endl;
180 
181  openForRead(inputStream);
182 }
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl
Definition: XMLDocument.h:74
std::auto_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
std::string fileName
Definition: XMLDocument.h:69
void openForRead(std::auto_ptr< std::istream > &inputStream)
Definition: XMLDocument.cc:212
XMLDocument::~XMLDocument ( )

Definition at line 184 of file XMLDocument.cc.

References assert(), doc, fileName, impl, python.multivaluedict::remove(), filterCSVwithJSON::target, and write.

185 {
186  if (!write)
187  return;
188 
189  std::auto_ptr<DocReleaser> docReleaser(new DocReleaser(doc));
190 
191  std::auto_ptr<DOMWriter> writer(static_cast<DOMImplementationLS*>(
192  impl)->createDOMWriter());
193  assert(writer.get());
194 
195  writer->setEncoding(XMLUniStr("UTF-8"));
196  if (writer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true))
197  writer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true);
198  if (writer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
199  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
200 
201  try {
202  std::auto_ptr<XMLFormatTarget> target(
203  new LocalFileFormatTarget(fileName.c_str()));
204 
205  writer->writeNode(target.get(), *doc);
206  } catch(...) {
207  std::remove(fileName.c_str());
208  throw;
209  }
210 }
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl
Definition: XMLDocument.h:74
assert(m_qm.get())
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
std::string fileName
Definition: XMLDocument.h:69

Member Function Documentation

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

Definition at line 122 of file HcalDbXml.cc.

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

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

Definition at line 231 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

231  {
232  newValue (fData, "CAPACITOR_0_VALUE", fItem.getValue (0));
233  newValue (fData, "CAPACITOR_1_VALUE", fItem.getValue (1));
234  newValue (fData, "CAPACITOR_2_VALUE", fItem.getValue (2));
235  newValue (fData, "CAPACITOR_3_VALUE", fItem.getValue (3));
236  }
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:115
void XMLDocument::addData ( DOMElement *  fData,
const HcalPedestalWidth fItem 
)

Definition at line 238 of file HcalDbXml.cc.

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

238  {
239  // widths
240  newValue (fData, "SIGMA_0_0", fItem.getSigma (0, 0));
241  newValue (fData, "SIGMA_1_1", fItem.getSigma (1, 1));
242  newValue (fData, "SIGMA_2_2", fItem.getSigma (2, 2));
243  newValue (fData, "SIGMA_3_3", fItem.getSigma (3, 3));
244  newValue (fData, "SIGMA_0_1", fItem.getSigma (0, 1));
245  newValue (fData, "SIGMA_0_2", fItem.getSigma (0, 2));
246  newValue (fData, "SIGMA_0_3", fItem.getSigma (0, 3));
247  newValue (fData, "SIGMA_1_2", fItem.getSigma (1, 2));
248  newValue (fData, "SIGMA_1_3", fItem.getSigma (1, 3));
249  newValue (fData, "SIGMA_2_3", fItem.getSigma (2, 3));
250  }
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:115
void XMLDocument::addData ( DOMElement *  fData,
const HcalGain fItem 
)

Definition at line 252 of file HcalDbXml.cc.

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

252  {
253  newValue (fData, "CAPACITOR_0_VALUE", fItem.getValue (0));
254  newValue (fData, "CAPACITOR_1_VALUE", fItem.getValue (1));
255  newValue (fData, "CAPACITOR_2_VALUE", fItem.getValue (2));
256  newValue (fData, "CAPACITOR_3_VALUE", fItem.getValue (3));
257  }
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:115
void XMLDocument::addData ( DOMElement *  fData,
const HcalRawGain fItem 
)

Definition at line 259 of file HcalDbXml.cc.

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

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

Definition at line 266 of file HcalDbXml.cc.

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

266  {
267  newValue (fData, "CAPACITOR_0_ERROR", fItem.getValue (0));
268  newValue (fData, "CAPACITOR_1_ERROR", fItem.getValue (1));
269  newValue (fData, "CAPACITOR_2_ERROR", fItem.getValue (2));
270  newValue (fData, "CAPACITOR_3_ERROR", fItem.getValue (3));
271  }
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:115
DOMDocument * XMLDocument::createDocument ( const std::string &  root)

Definition at line 266 of file XMLDocument.cc.

References doc, Exception, impl, and rootNode.

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

Definition at line 296 of file HcalDbXml.cc.

References mDoc.

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

Definition at line 22 of file XMLDocument.h.

References doc.

22 { return doc; }
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* XMLDocument::getRootNode ( ) const
inline

Definition at line 25 of file XMLDocument.h.

References rootNode.

25 { return rootNode; }
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * rootNode
Definition: XMLDocument.h:77
bool XMLDocument::hasAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name 
)
static

Definition at line 303 of file XMLDocument.cc.

305 {
306  XMLUniStr uniName(name);
307  return elem->hasAttribute(uniName);
308 }
DOMElement * XMLDocument::makeChId ( DOMElement *  fDataset,
DetId  fId 
)

Definition at line 155 of file HcalDbXml.cc.

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

Referenced by dumpObject_(), and makeElementDataset().

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

Definition at line 274 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

274  {
275  DOMElement* data = newElement (fDataset, "DATA");
276  // pedestals
277  newValue (data, "CAPACITOR_0_VALUE", fPed.getValue (0));
278  newValue (data, "CAPACITOR_1_VALUE", fPed.getValue (1));
279  newValue (data, "CAPACITOR_2_VALUE", fPed.getValue (2));
280  newValue (data, "CAPACITOR_3_VALUE", fPed.getValue (3));
281  // widths
282  newValue (data, "SIGMA_0_0", fWidth.getSigma (0, 0));
283  newValue (data, "SIGMA_1_1", fWidth.getSigma (1, 1));
284  newValue (data, "SIGMA_2_2", fWidth.getSigma (2, 2));
285  newValue (data, "SIGMA_3_3", fWidth.getSigma (3, 3));
286  newValue (data, "SIGMA_0_1", fWidth.getSigma (0, 1));
287  newValue (data, "SIGMA_0_2", fWidth.getSigma (0, 2));
288  newValue (data, "SIGMA_0_3", fWidth.getSigma (0, 3));
289  newValue (data, "SIGMA_1_2", fWidth.getSigma (1, 2));
290  newValue (data, "SIGMA_1_3", fWidth.getSigma (1, 3));
291  newValue (data, "SIGMA_2_3", fWidth.getSigma (2, 3));
292  return data;
293  }
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:109
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:115
DOMElement * XMLDocument::makeData ( DOMElement *  fDataset)

Definition at line 227 of file HcalDbXml.cc.

References newElement().

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

Definition at line 149 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

149  {
150  DOMElement* dataset =newElement (fRoot, "DATA_SET");
151  newValue (dataset, "VERSION", fVersion);
152  return dataset;
153  }
tuple dataset
Definition: dataset.py:855
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:109
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:115
DOMElement * XMLDocument::makeElement ( DOMElement *  fRoot)

Definition at line 199 of file HcalDbXml.cc.

References newElement().

Referenced by dumpObject_().

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

Definition at line 169 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

169  {
170  DOMElement* dataset = newElement (fElement, "DATA_SET");
171  addAttribute (dataset, "id", fXMLId);
172  newValue (newElement (dataset, "KIND_OF_CONDITION"), "NAME", fKind);
173  newValue (dataset, "VERSION", fVersion);
174  makeRun (dataset, fRun);
175  makeChId (dataset, fDetId);
176  return dataset;
177  }
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:122
DOMElement * makeRun(DOMElement *fHeader, unsigned long fRun)
Definition: HcalDbXml.cc:142
DOMElement * makeChId(DOMElement *fDataset, DetId fId)
Definition: HcalDbXml.cc:155
tuple dataset
Definition: dataset.py:855
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:109
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:115
DOMElement * XMLDocument::makeElementIOV ( DOMElement *  fElement,
unsigned long long  fIovBegin,
unsigned long long  fIovEnd = 0 
)

Definition at line 179 of file HcalDbXml.cc.

References addAttribute(), o2o::iov, newElement(), and newValue().

Referenced by dumpObject_().

179  {
180  DOMElement* iov = newElement (fElement, "IOV");
181  addAttribute (iov, "id", IOV_ID);
182  newValue (iov, "INTERVAL_OF_VALIDITY_BEGIN", fIovBegin);
183  if (fIovEnd) {
184  newValue (iov, "INTERVAL_OF_VALIDITY_END", fIovEnd);
185  }
186  return iov;
187  }
tuple iov
Definition: o2o.py:307
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:122
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:109
DOMElement * newValue(DOMElement *fParent, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:115
DOMElement * XMLDocument::makeElementTag ( DOMElement *  fElement,
const std::string &  fTagName,
const std::string &  fDetectorName,
const std::string &  fComment = "Automatically created by HcalDbXml" 
)

Definition at line 189 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 128 of file HcalDbXml.cc.

References makeRun(), makeType(), and newElement().

Referenced by dumpObject_().

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

Definition at line 221 of file HcalDbXml.cc.

References addAttribute(), and newElement().

Referenced by dumpObject_().

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

Definition at line 215 of file HcalDbXml.cc.

References addAttribute(), o2o::iov, and newElement().

Referenced by dumpObject_().

215  {
216  DOMElement* iov = newElement (fTag, "IOV");
217  addAttribute (iov, "idref", IOV_ID);
218  return iov;
219  }
tuple iov
Definition: o2o.py:307
void addAttribute(DOMElement *fElement, const std::string &fName, const T &fValue)
Definition: HcalDbXml.cc:122
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:109
DOMElement * XMLDocument::makeMaps ( DOMElement *  fRoot)

Definition at line 204 of file HcalDbXml.cc.

References python.multivaluedict::map(), and newElement().

Referenced by dumpObject_().

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

Definition at line 209 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 142 of file HcalDbXml.cc.

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

Referenced by makeElementDataset(), and makeHeader().

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

Definition at line 135 of file HcalDbXml.cc.

References newElement(), and newValue().

Referenced by makeHeader().

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

Definition at line 109 of file HcalDbXml.cc.

References mDoc.

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

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

Definition at line 115 of file HcalDbXml.cc.

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

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

115  {
116  DOMElement* element = newElement (fParent, fName);
117  DOMText* text = mDoc->createTextNode (transcode (fValue));
118  element->appendChild (text);
119  return element;
120  }
tuple text
Definition: runonSM.py:42
DOMDocument * mDoc
Definition: HcalDbXml.cc:95
DOMElement * newElement(DOMElement *fParent, const T &fName)
Definition: HcalDbXml.cc:109
void XMLDocument::openForRead ( std::auto_ptr< std::istream > &  inputStream)
private

Definition at line 212 of file XMLDocument.cc.

References doc, alignCSCRings::e, errHandler, Exception, inputSource, python.Node::node, parser, and rootNode.

Referenced by XMLDocument().

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

Definition at line 259 of file XMLDocument.cc.

References assert(), and impl.

Referenced by XMLDocument().

260 {
261  impl = DOMImplementationRegistry::getDOMImplementation(
262  XMLUniStr("LS"));
263  assert(impl);
264 }
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl
Definition: XMLDocument.h:74
assert(m_qm.get())
template<typename T >
static T XMLDocument::readAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name 
)
static
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 311 of file XMLDocument.cc.

References isBool().

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

Definition at line 326 of file XMLDocument.cc.

References isBool().

329 {
330  XMLUniStr uniName(name);
331  if (!elem->hasAttribute(uniName))
332  return defValue;
333  const XMLCh *attribute = elem->getAttribute(uniName);
334  return isBool(XMLSimpleStr(attribute));
335 }
static bool isBool(std::string value)
Definition: XMLDocument.cc:281
template<typename T >
static T XMLDocument::readContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node)
static
template<>
bool XMLDocument::readContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node)

Definition at line 346 of file XMLDocument.cc.

References ws_sso_content_reader::content, and isBool().

348 {
349  const XMLCh *content = node->getTextContent();
350  return isBool(XMLSimpleStr(content));
351 }
tuple node
Definition: Node.py:50
static bool isBool(std::string value)
Definition: XMLDocument.cc:281
DOMElement * XMLDocument::root ( )

Definition at line 126 of file HcalDbXml.cc.

References mDoc.

Referenced by dumpObject_(), and streamOut().

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

Definition at line 298 of file HcalDbXml.cc.

References mDoc, mDom, and root().

Referenced by dumpObject_().

298  {
299  StreamOutFormatTarget formTaget (fOut);
300  DOMWriter* domWriter = mDom->createDOMWriter();
301  domWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
302  domWriter->writeNode (&formTaget, *(root()));
303  mDoc->release ();
304  }
DOMImplementation * mDom
Definition: HcalDbXml.cc:94
DOMDocument * mDoc
Definition: HcalDbXml.cc:95
DOMElement * root()
Definition: HcalDbXml.cc:126
template<typename T >
static void XMLDocument::writeAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name,
const T value 
)
static
template<>
void XMLDocument::writeAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name,
const bool &  value 
)

Definition at line 338 of file XMLDocument.cc.

References makeBool().

341 {
342  elem->setAttribute(XMLUniStr(name), XMLUniStr(makeBool(value)));
343 }
static const char * makeBool(bool value)
Definition: XMLDocument.cc:298
template<typename T >
static void XMLDocument::writeContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
const T value 
)
static
template<>
void XMLDocument::writeContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
const bool &  value 
)

Definition at line 354 of file XMLDocument.cc.

References makeBool().

358 {
359  node->appendChild(doc->createTextNode(XMLUniStr(makeBool(value))));
360 }
static const char * makeBool(bool value)
Definition: XMLDocument.cc:298
tuple node
Definition: Node.py:50
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76

Member Data Documentation

XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* XMLDocument::doc
private

Definition at line 76 of file XMLDocument.h.

Referenced by createDocument(), getDocument(), openForRead(), and ~XMLDocument().

std::auto_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.

Referenced by createDocument(), openForWrite(), and ~XMLDocument().

std::auto_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 95 of file HcalDbXml.cc.

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

DOMImplementation* XMLDocument::mDom
private

Definition at line 94 of file HcalDbXml.cc.

Referenced by streamOut(), and XMLDocument().

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

Definition at line 72 of file XMLDocument.h.

Referenced by makeChId(), and openForRead().

std::auto_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

Definition at line 70 of file XMLDocument.h.

Referenced by pkg.AbstractPkg::generate(), and ~XMLDocument().