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 54 of file HcalDbXml.cc.

Constructor & Destructor Documentation

XMLDocument::XMLDocument ( )

Definition at line 97 of file HcalDbXml.cc.

References mDoc, and mDom.

98  : mDoc (0)
99  {
100  XMLPlatformUtils::Initialize();
101  mDom = DOMImplementationRegistry::getDOMImplementation (transcode ("Core"));
102  mDoc = mDom->createDocument(
103  0, // root element namespace URI.
104  transcode ("ROOT"), // root element name
105  0); // document type object (DTD).
106  }
DOMImplementation * mDom
Definition: HcalDbXml.cc:93
DOMDocument * mDoc
Definition: HcalDbXml.cc:94
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 edm::hlt::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 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
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 121 of file HcalDbXml.cc.

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

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

Definition at line 230 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 237 of file HcalDbXml.cc.

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

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

Definition at line 251 of file HcalDbXml.cc.

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

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

Definition at line 258 of file HcalDbXml.cc.

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

258  {
259  newValue (fData, "VALUE", fItem.getValue ());
260  newValue (fData, "ERROR", fItem.getError ());
261  newValue (fData, "VOLTAGE", fItem.getVoltage ());
262  newValue (fData, "STATUS", fItem.strStatus ());
263  }
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:114
void XMLDocument::addData ( DOMElement *  fData,
const HcalGainWidth fItem 
)

Definition at line 265 of file HcalDbXml.cc.

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

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

Definition at line 266 of file XMLDocument.cc.

References doc, edm::hlt::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:125
const DOMDocument * XMLDocument::document ( )

Definition at line 295 of file HcalDbXml.cc.

References mDoc.

295 {return mDoc;}
DOMDocument * mDoc
Definition: HcalDbXml.cc:94
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 154 of file HcalDbXml.cc.

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

Referenced by dumpObject_(), and makeElementDataset().

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

Definition at line 273 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 226 of file HcalDbXml.cc.

References newElement().

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

Definition at line 148 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 198 of file HcalDbXml.cc.

References newElement().

Referenced by dumpObject_().

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

Definition at line 168 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 178 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 188 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 127 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 220 of file HcalDbXml.cc.

References addAttribute(), and newElement().

Referenced by dumpObject_().

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

Definition at line 214 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 203 of file HcalDbXml.cc.

References Association::map, and newElement().

Referenced by dumpObject_().

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

Definition at line 208 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

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

Definition at line 141 of file HcalDbXml.cc.

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

Referenced by makeElementDataset(), and makeHeader().

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

Definition at line 134 of file HcalDbXml.cc.

References newElement(), and newValue().

Referenced by makeHeader().

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

Definition at line 108 of file HcalDbXml.cc.

References mDoc.

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

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

Definition at line 114 of file HcalDbXml.cc.

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

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

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

Definition at line 212 of file XMLDocument.cc.

References doc, alignCSCRings::e, errHandler, edm::hlt::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 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
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 125 of file HcalDbXml.cc.

References mDoc.

Referenced by dumpObject_(), and streamOut().

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

Definition at line 297 of file HcalDbXml.cc.

References mDoc, mDom, and root().

Referenced by dumpObject_().

297  {
298  StreamOutFormatTarget formTaget (fOut);
299  DOMWriter* domWriter = mDom->createDOMWriter();
300  domWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
301  domWriter->writeNode (&formTaget, *(root()));
302  mDoc->release ();
303  }
DOMImplementation * mDom
Definition: HcalDbXml.cc:93
DOMDocument * mDoc
Definition: HcalDbXml.cc:94
DOMElement * root()
Definition: HcalDbXml.cc:125
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 94 of file HcalDbXml.cc.

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

DOMImplementation* XMLDocument::mDom
private

Definition at line 93 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 ~XMLDocument().