CMS 3D CMS Logo

Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

XMLDocument Class Reference

#include <XMLDocument.h>

List of all members.

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, const bool &defValue)
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 ()
 XMLDocument (const std::string &fileName, bool write=false)
 XMLDocument (const std::string &fileName, const std::string &command)
 ~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.

    : mDoc (0)
  {
    XMLPlatformUtils::Initialize();
    mDom =  DOMImplementationRegistry::getDOMImplementation (transcode ("Core"));
    mDoc = mDom->createDocument(
                                0,                    // root element namespace URI.
                                transcode ("ROOT"),         // root element name
                                0);                   // document type object (DTD).
  }
XMLDocument::XMLDocument ( const std::string &  fileName,
bool  write = false 
)

Definition at line 143 of file XMLDocument.cc.

References openForRead(), and openForWrite().

                                                              :
        platform(new XercesPlatform()), fileName(fileName),
        write(write), impl(0), doc(0), rootNode(0)
{
        if (write)
                openForWrite(fileName);
        else {
                std::auto_ptr<std::istream> inputStream(
                                        new std::ifstream(fileName.c_str()));
                if (!inputStream->good())
                        throw cms::Exception("XMLDocument")
                                << "XML input file \"" << fileName << "\" "
                                   "could not be opened for reading."
                                << std::endl;
                openForRead(inputStream);
        }
}
XMLDocument::XMLDocument ( const std::string &  fileName,
const std::string &  command 
)

Definition at line 161 of file XMLDocument.cc.

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

                                                   :
        platform(new XercesPlatform()), fileName(fileName),
        write(false), impl(0), doc(0), rootNode(0)
{
        FILE *file = popen(command.c_str(), "r");
        if (!file)
                throw cms::Exception("XMLDocument")
                        << "Could not execute XML preprocessing "
                           " command \"" << command << "\"."
                        << std::endl;

        std::auto_ptr<std::istream> inputStream(
                                        new stdio_istream<pclose>(file));
        if (!inputStream->good())
                throw cms::Exception("XMLDocument")
                        << "XML preprocessing command \"" << fileName
                        << "\" stream could not be opened for reading."
                        << std::endl;

        openForRead(inputStream);
}
XMLDocument::~XMLDocument ( )

Definition at line 184 of file XMLDocument.cc.

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

{
        if (!write)
                return;

        std::auto_ptr<DocReleaser> docReleaser(new DocReleaser(doc));

        std::auto_ptr<DOMWriter> writer(static_cast<DOMImplementationLS*>(
                                                impl)->createDOMWriter());
        assert(writer.get());

        writer->setEncoding(XMLUniStr("UTF-8"));
        if (writer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true))
                writer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true);
        if (writer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
                writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);

        try {
                std::auto_ptr<XMLFormatTarget> target(
                                new LocalFileFormatTarget(fileName.c_str()));

                writer->writeNode(target.get(), *doc);
        } catch(...) {
                std::remove(fileName.c_str());
                throw;
        }
}

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().

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

Definition at line 230 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

                                                                         {
    newValue (fData, "CAPACITOR_0_VALUE", fItem.getValue (0));
    newValue (fData, "CAPACITOR_1_VALUE", fItem.getValue (1));
    newValue (fData, "CAPACITOR_2_VALUE", fItem.getValue (2));
    newValue (fData, "CAPACITOR_3_VALUE", fItem.getValue (3));
  }
void XMLDocument::addData ( DOMElement *  fData,
const HcalPedestalWidth fItem 
)

Definition at line 237 of file HcalDbXml.cc.

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

                                                                              {
    // widths
    newValue (fData, "SIGMA_0_0", fItem.getSigma (0, 0));
    newValue (fData, "SIGMA_1_1", fItem.getSigma (1, 1));
    newValue (fData, "SIGMA_2_2", fItem.getSigma (2, 2));
    newValue (fData, "SIGMA_3_3", fItem.getSigma (3, 3));
    newValue (fData, "SIGMA_0_1", fItem.getSigma (0, 1));
    newValue (fData, "SIGMA_0_2", fItem.getSigma (0, 2));
    newValue (fData, "SIGMA_0_3", fItem.getSigma (0, 3));
    newValue (fData, "SIGMA_1_2", fItem.getSigma (1, 2));
    newValue (fData, "SIGMA_1_3", fItem.getSigma (1, 3));
    newValue (fData, "SIGMA_2_3", fItem.getSigma (2, 3));
  }
void XMLDocument::addData ( DOMElement *  fData,
const HcalGain fItem 
)

Definition at line 251 of file HcalDbXml.cc.

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

                                                                     {
    newValue (fData, "CAPACITOR_0_VALUE", fItem.getValue (0));
    newValue (fData, "CAPACITOR_1_VALUE", fItem.getValue (1));
    newValue (fData, "CAPACITOR_2_VALUE", fItem.getValue (2));
    newValue (fData, "CAPACITOR_3_VALUE", fItem.getValue (3));
  }
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().

                                                                        {
    newValue (fData, "VALUE", fItem.getValue ());
    newValue (fData, "ERROR", fItem.getError ());
    newValue (fData, "VOLTAGE", fItem.getVoltage ());
    newValue (fData, "STATUS", fItem.strStatus ());
  }
void XMLDocument::addData ( DOMElement *  fData,
const HcalGainWidth fItem 
)

Definition at line 265 of file HcalDbXml.cc.

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

                                                                         {
    newValue (fData, "CAPACITOR_0_ERROR", fItem.getValue (0));
    newValue (fData, "CAPACITOR_1_ERROR", fItem.getValue (1));
    newValue (fData, "CAPACITOR_2_ERROR", fItem.getValue (2));
    newValue (fData, "CAPACITOR_3_ERROR", fItem.getValue (3));
  }
DOMDocument * XMLDocument::createDocument ( const std::string &  root)

Definition at line 266 of file XMLDocument.cc.

References doc, Exception, impl, and rootNode.

{
        if (doc)
                throw cms::Exception("XMLDocument")
                        << "Document already exists in createDocument."
                        << std::endl;

        doc = impl->createDocument(0, XMLUniStr(root.c_str()), 0);
        rootNode = doc->getDocumentElement();

        return doc;
}
const DOMDocument * XMLDocument::document ( )

Definition at line 295 of file HcalDbXml.cc.

References mDoc.

{return mDoc;}
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* XMLDocument::getDocument ( void  ) const [inline]

Definition at line 22 of file XMLDocument.h.

References doc.

{ return doc; }
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* XMLDocument::getRootNode ( ) const [inline]

Definition at line 25 of file XMLDocument.h.

References rootNode.

{ return rootNode; }
bool XMLDocument::hasAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name 
) [static]

Definition at line 303 of file XMLDocument.cc.

{
        XMLUniStr uniName(name);
        return elem->hasAttribute(uniName);
}
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().

                                                                    {
    DOMElement* channel = newElement (fDataset, "CHANNEL");
    newValue (channel, "EXTENSION_TABLE_NAME", "HCAL_CHANNELS");
    HcalText2DetIdConverter parser (fId);
    newValue (channel, "DETECTOR_NAME", parser.getFlavor ());
    int eta = parser.getField (1);
    newValue (channel, "ETA", abs(eta));
    newValue (channel, "Z", eta > 0 ? 1 : -1);
    newValue (channel, "PHI", parser.getField2 ());
    newValue (channel, "DEPTH", parser.getField3 ());
    newValue (channel, "HCAL_CHANNEL_ID", fId.rawId());
    return channel;
  }
DOMElement * XMLDocument::makeData ( DOMElement *  fDataset)

Definition at line 226 of file HcalDbXml.cc.

References newElement().

                                                         {
    return  newElement (fDataset, "DATA");
  }
DOMElement * XMLDocument::makeData ( DOMElement *  fDataset,
const HcalPedestal fPed,
const HcalPedestalWidth fWidth 
)

Definition at line 273 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

                                                                                                                    {
    DOMElement* data = newElement (fDataset, "DATA");
    // pedestals
    newValue (data, "CAPACITOR_0_VALUE", fPed.getValue (0));
    newValue (data, "CAPACITOR_1_VALUE", fPed.getValue (1));
    newValue (data, "CAPACITOR_2_VALUE", fPed.getValue (2));
    newValue (data, "CAPACITOR_3_VALUE", fPed.getValue (3));
    // widths
    newValue (data, "SIGMA_0_0", fWidth.getSigma (0, 0));
    newValue (data, "SIGMA_1_1", fWidth.getSigma (1, 1));
    newValue (data, "SIGMA_2_2", fWidth.getSigma (2, 2));
    newValue (data, "SIGMA_3_3", fWidth.getSigma (3, 3));
    newValue (data, "SIGMA_0_1", fWidth.getSigma (0, 1));
    newValue (data, "SIGMA_0_2", fWidth.getSigma (0, 2));
    newValue (data, "SIGMA_0_3", fWidth.getSigma (0, 3));
    newValue (data, "SIGMA_1_2", fWidth.getSigma (1, 2));
    newValue (data, "SIGMA_1_3", fWidth.getSigma (1, 3));
    newValue (data, "SIGMA_2_3", fWidth.getSigma (2, 3));
    return data;
  }
DOMElement * XMLDocument::makeDataset ( DOMElement *  fRoot,
const std::string &  fVersion 
)

Definition at line 148 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

                                                                                    {
      DOMElement* dataset =newElement (fRoot, "DATA_SET");
      newValue (dataset, "VERSION", fVersion);
      return dataset;
  }
DOMElement * XMLDocument::makeElement ( DOMElement *  fRoot)

Definition at line 198 of file HcalDbXml.cc.

References newElement().

Referenced by dumpObject_().

                                                         {
    DOMElement* element = newElement (fRoot, "ELEMENTS");
    return element;
  }
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(), AlCaRecoCosmics_cfg::dataset, makeChId(), makeRun(), newElement(), and newValue().

Referenced by dumpObject_().

                                                                                                                                                                    {
    DOMElement* dataset = newElement (fElement, "DATA_SET");
    addAttribute (dataset, "id", fXMLId);
    newValue (newElement (dataset, "KIND_OF_CONDITION"), "NAME", fKind);
    newValue (dataset, "VERSION", fVersion);
    makeRun (dataset, fRun);
    makeChId (dataset, fDetId);
    return dataset;
  }
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_().

                                                                                                                         {
    DOMElement* iov = newElement (fElement, "IOV");
    addAttribute (iov, "id", IOV_ID);
    newValue (iov, "INTERVAL_OF_VALIDITY_BEGIN", fIovBegin);
    if (fIovEnd) {
      newValue (iov, "INTERVAL_OF_VALIDITY_END", fIovEnd);
    }
    return iov;
  }
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_().

                                                                                                                                                     {
    DOMElement* tag = newElement (fElement, "TAG");
    addAttribute (tag, "id", TAG_ID);
    addAttribute (tag, "mode", "create");
    newValue (tag, "TAG_NAME", fTagName);
    newValue (tag, "DETECTOR_NAME", fDetectorName);
    newValue (tag, "COMMENT_DESCRIPTION", fComment);
    return tag;
  }
DOMElement * XMLDocument::makeHeader ( DOMElement *  fRoot,
const std::string &  fExtensionName,
unsigned long  fRun 
)

Definition at line 127 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

                                                                                                             {
    DOMElement* header = newElement (fRoot, "HEADER");
    makeType (header, fExtensionName);
    makeRun (header, fRun);
    return header;
  }
DOMElement * XMLDocument::makeMapDataset ( DOMElement *  fIov,
int  fXMLId 
)

Definition at line 220 of file HcalDbXml.cc.

References addAttribute(), and newElement().

Referenced by dumpObject_().

                                                                       {
    DOMElement* element = newElement (fIov, "DATA_SET");
    addAttribute (element, "idref", fXMLId);
    return element;
  }
DOMElement * XMLDocument::makeMapIOV ( DOMElement *  fTag)

Definition at line 214 of file HcalDbXml.cc.

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

Referenced by dumpObject_().

                                                       {
    DOMElement* iov = newElement (fTag, "IOV");
    addAttribute (iov, "idref", IOV_ID);
    return iov;
  }
DOMElement * XMLDocument::makeMaps ( DOMElement *  fRoot)

Definition at line 203 of file HcalDbXml.cc.

References Association::map, and newElement().

Referenced by dumpObject_().

                                                      {
    DOMElement* map = newElement (fRoot, "MAPS");
    return map;
  }
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_().

                                                       {
    DOMElement* tag = newElement (fMap, "TAG");
    addAttribute (tag, "idref", TAG_ID);
    return tag;
  }
DOMElement * XMLDocument::makeRun ( DOMElement *  fHeader,
unsigned long  fRun 
)

Definition at line 141 of file HcalDbXml.cc.

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

Referenced by makeElementDataset(), and makeHeader().

                                                                           {
      DOMElement* run =newElement (fHeader, "RUN");
      newValue (run, "RUN_TYPE", "HcalDbXml");
      newValue (run, "RUN_NUMBER", fRun);
      return run;
  }
DOMElement * XMLDocument::makeType ( DOMElement *  fHeader,
const std::string &  fExtensionName 
)

Definition at line 134 of file HcalDbXml.cc.

References newElement(), and newValue().

Referenced by makeHeader().

                                                                                {
      DOMElement* type = newElement (fHeader, "TYPE");
      newValue (type, "EXTENSION_TABLE_NAME", extensionTableName (fKind));
      newValue (type, "NAME", fKind);
      return type;
  }
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().

                                                                                             {
    DOMElement* element = mDoc->createElement (transcode (fName));
    fParent->appendChild (element);
    return element;
  }
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().

                                                                                                                    {
    DOMElement* element = newElement (fParent, fName);
    DOMText* text = mDoc->createTextNode (transcode (fValue));
    element->appendChild (text);
    return element;
  }
void XMLDocument::openForRead ( std::auto_ptr< std::istream > &  inputStream) [private]

Definition at line 212 of file XMLDocument.cc.

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

Referenced by XMLDocument().

{
        parser.reset(new XercesDOMParser());
        parser->setValidationScheme(XercesDOMParser::Val_Auto);
        parser->setDoNamespaces(false);
        parser->setDoSchema(false);
        parser->setValidationSchemaFullChecking(false);

        errHandler.reset(new HandlerBase());
        parser->setErrorHandler(errHandler.get());
        parser->setCreateEntityReferenceNodes(false);

        inputSource.reset(new STLInputSource(stream));

        try {
                parser->parse(*inputSource);
                if (parser->getErrorCount())
                        throw cms::Exception("XMLDocument")
                                << "XML parser reported errors."
                                << std::endl;
        } catch(const XMLException &e) {
                throw cms::Exception("XMLDocument")
                        << "XML parser reported DOM error no. "
                        << (unsigned long)e.getCode()
                        << ": " << XMLSimpleStr(e.getMessage()) << "."
                        << std::endl;
        } catch(const SAXException &e) {
                throw cms::Exception("XMLDocument")
                        << "XML parser reported: "
                        << XMLSimpleStr(e.getMessage()) << "."
                        << std::endl;
        }

        doc = parser->getDocument();

        DOMNode *node = doc->getFirstChild();
        while(node && node->getNodeType() != DOMNode::ELEMENT_NODE)
                node = node->getNextSibling();

        if (!node)
                throw cms::Exception("XMLDocument")
                        << "XML document didn't contain a valid "
                        << "root node." << std::endl;

        rootNode = static_cast<DOMElement*>(node);
}
void XMLDocument::openForWrite ( const std::string &  fileName) [private]

Definition at line 259 of file XMLDocument.cc.

References impl.

Referenced by XMLDocument().

{
        impl = DOMImplementationRegistry::getDOMImplementation(
                                                        XMLUniStr("LS"));
        assert(impl);
}
template<typename T >
static T XMLDocument::readAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name,
const T &  defValue 
) [static]
bool XMLDocument::readAttribute ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  elem,
const char *  name 
) [static]

Definition at line 311 of file XMLDocument.cc.

References isBool().

{
        XMLUniStr uniName(name);
        if (!elem->hasAttribute(uniName))
                throw cms::Exception("MVAComputer")
                        << "Missing attribute " << name << " in tag "
                        << XMLSimpleStr(elem->getNodeName())
                        << "." << std::endl;
        const XMLCh *attribute = elem->getAttribute(uniName);
        return isBool(XMLSimpleStr(attribute));
}
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().

{
        XMLUniStr uniName(name);
        if (!elem->hasAttribute(uniName))
                return defValue;
        const XMLCh *attribute = elem->getAttribute(uniName);
        return isBool(XMLSimpleStr(attribute));
}
bool XMLDocument::readContent ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  node) [static]

Definition at line 346 of file XMLDocument.cc.

References isBool().

{
        const XMLCh *content = node->getTextContent();
        return isBool(XMLSimpleStr(content));
}
DOMElement * XMLDocument::root ( )

Definition at line 125 of file HcalDbXml.cc.

References mDoc.

Referenced by dumpObject_(), and streamOut().

{ return mDoc->getDocumentElement();}
void XMLDocument::streamOut ( std::ostream &  fOut)

Definition at line 297 of file HcalDbXml.cc.

References mDoc, mDom, and root().

Referenced by dumpObject_().

                                               {
    StreamOutFormatTarget formTaget (fOut);
    DOMWriter* domWriter = mDom->createDOMWriter();
    domWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
    domWriter->writeNode (&formTaget, *(root()));
    mDoc->release ();
  }
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().

{
        elem->setAttribute(XMLUniStr(name), XMLUniStr(makeBool(value)));
}
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().

{
        node->appendChild(doc->createTextNode(XMLUniStr(makeBool(value))));
}

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().