Skip to content

Commit

Permalink
Migrating from Xerces-C++ 2.8.0 to Xerces-C++ 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ianna committed May 24, 2016
1 parent a642f3d commit 7fca0a2
Show file tree
Hide file tree
Showing 55 changed files with 462 additions and 526 deletions.
15 changes: 7 additions & 8 deletions CalibCalorimetry/HcalTPGAlgos/src/XMLProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,11 @@ XMLCh * XMLProcessor::serializeDOM(DOMNode* node, std::string target)
XMLCh tempStr[100];
XMLString::transcode("LS", tempStr, 99);
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMWriter* theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
DOMLSSerializer* theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
DOMConfiguration* dc = theSerializer->getDomConfig();
dc->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent, true);
dc->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);

if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true))
theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true);

if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);

XMLFormatTarget * myFormTarget = 0;
XMLCh * _string = 0;
if ( target == "stdout" || target == "string" )
Expand All @@ -268,7 +265,9 @@ XMLCh * XMLProcessor::serializeDOM(DOMNode* node, std::string target)
_string = theSerializer->writeToString( *node );
}
else{
theSerializer->writeNode(myFormTarget, *node);
DOMLSOutput* outputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
outputDesc->setByteStream(myFormTarget);
theSerializer->write(node, outputDesc);
}
}
catch (const XMLException& toCatch) {
Expand Down
2 changes: 0 additions & 2 deletions Calibration/HcalCalibAlgos/interface/HcalConstantsXMLWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationRegistry.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/util/XMLString.hpp>

#include <fstream>
Expand All @@ -27,7 +26,6 @@ class HcalConstantsXMLWriter

private:
std::string hcalfileOut_;
xercesc::DOMImplementation* mDom;
xercesc::DOMDocument* mDoc;
};

Expand Down
12 changes: 8 additions & 4 deletions Calibration/HcalCalibAlgos/src/HcalConstantsXMLWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void HcalConstantsXMLWriter::writeXML(string& newfile0,const vector<int>& detvec
XMLCh tempStr[100];

XMLString::transcode ("Core",tempStr,99);
mDom = DOMImplementationRegistry::getDOMImplementation (tempStr);
unique_ptr<DOMImplementation> mDom( DOMImplementationRegistry::getDOMImplementation (tempStr));

XMLString::transcode("CalibrationConstants", tempStr, 99);
mDoc = mDom->createDocument(
Expand All @@ -54,8 +54,8 @@ void HcalConstantsXMLWriter::writeXML(string& newfile0,const vector<int>& detvec
0); // document type object (DTD).

StreamOutFormatTarget formTarget (fOut);
DOMWriter* domWriter = mDom->createDOMWriter();
domWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
DOMLSSerializer* domWriter = mDom->createLSSerializer();
domWriter->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
DOMElement* root = mDoc->getDocumentElement();

XMLString::transcode("Hcal", tempStr, 99);
Expand All @@ -73,9 +73,13 @@ void HcalConstantsXMLWriter::writeXML(string& newfile0,const vector<int>& detvec
}

cout<<" Write Doc "<<theDOMVec.size()<<endl;
domWriter->writeNode (&formTarget, *mDoc);
DOMLSOutput* output= mDom->createLSOutput();
output->setByteStream(formTarget);
domWriter->write (mDoc, output);
cout<<" End of Writting "<<endl;
mDoc->release ();
output->release();
domWriter->release();
}

void HcalConstantsXMLWriter::newCellLine(DOMElement* detelem, int det, int eta, int phi, int depth, float scale)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ XERCES_CPP_NAMESPACE_USE
}
virtual void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs) override;
virtual void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) override;
virtual void characters(const XMLCh* const chars, const unsigned int length) override;
virtual void ignorableWhitespace(const XMLCh* chars, const unsigned int length) override;
virtual void characters (const XMLCh *const chars, const XMLSize_t length) override;
virtual void ignorableWhitespace (const XMLCh *const chars, const XMLSize_t length) override;
private:
inline bool cvt2String(const XMLCh* val, std::string& ou) {
if (val==0) return false;
Expand Down Expand Up @@ -155,11 +155,11 @@ XERCES_CPP_NAMESPACE_USE

m_mode=md_Idle;
}
void ConfigurationDBHandler::ignorableWhitespace(const XMLCh* chars, const unsigned int length) {
void ConfigurationDBHandler::ignorableWhitespace(const XMLCh* chars, const XMLSize_t length) {
if (m_mode==md_Idle) return;
m_text+=' ';
}
void ConfigurationDBHandler::characters(const XMLCh* chars, const unsigned int length) {
void ConfigurationDBHandler::characters(const XMLCh* chars, const XMLSize_t length) {
if (m_mode==md_Idle) return;
unsigned int offset=0;
while (offset<length) {
Expand Down
18 changes: 7 additions & 11 deletions CondTools/Ecal/src/ESGainXMLTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,26 @@ std::string ESGainXMLTranslator::dumpXML(const EcalCondHeader& header,

cms::concurrency::xercesInitialize();

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str()));

DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
DOMLSSerializer* writer = impl->createLSSerializer();
if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );

DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
DOMDocument * doc =
impl->createDocument( 0, fromNative(ADCToGeVConstant_tag).c_str(), doctype );


doc->setEncoding(fromNative("UTF-8").c_str() );
doc->setStandalone(true);
doc->setVersion(fromNative("1.0").c_str() );

DOMElement* root = doc->getDocumentElement();

xuti::writeHeader(root,header);

xuti::WriteNodeWithValue(root,ESGain_tag,record.getESGain());

std::string dump= toNative(writer->writeToString(*root));
std::string dump = toNative(writer->writeToString( root ));
doc->release();

doctype->release();
writer->release();
// cms::concurrency::xercesTerminate();

return dump;
Expand Down
18 changes: 7 additions & 11 deletions CondTools/Ecal/src/EcalADCToGeVXMLTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,15 @@ std::string EcalADCToGeVXMLTranslator::dumpXML(const EcalCondHeader& header,

cms::concurrency::xercesInitialize();

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str()));

DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
DOMLSSerializer* writer = impl->createLSSerializer();
if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );

DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
DOMDocument * doc =
impl->createDocument( 0, fromNative(ADCToGeVConstant_tag).c_str(), doctype );


doc->setEncoding(fromNative("UTF-8").c_str() );
doc->setStandalone(true);
doc->setVersion(fromNative("1.0").c_str() );

DOMElement* root = doc->getDocumentElement();

Expand All @@ -105,9 +100,10 @@ std::string EcalADCToGeVXMLTranslator::dumpXML(const EcalCondHeader& header,
xuti::WriteNodeWithValue(root,Barrel_tag,record.getEBValue());
xuti::WriteNodeWithValue(root,Endcap_tag,record.getEEValue());

std::string dump= toNative(writer->writeToString(*root));
std::string dump = toNative(writer->writeToString( root ));
doc->release();

doctype->release();
writer->release();
// cms::concurrency::xercesTerminate();

return dump;
Expand Down
24 changes: 10 additions & 14 deletions CondTools/Ecal/src/EcalAlignmentXMLTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,14 @@ string EcalAlignmentXMLTranslator::dumpXML(const EcalCondHeader& header,

cms::concurrency::xercesInitialize();

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str()));

DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
DOMLSSerializer* writer = impl->createLSSerializer();
if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );

DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
DOMDocument * doc =
impl->createDocument( 0, fromNative(AlignmentConstant_tag).c_str(), doctype );


doc->setEncoding(fromNative("UTF-8").c_str() );
doc->setStandalone(true);
doc->setVersion(fromNative("1.0").c_str() );

DOMDocumentType* doctype = impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
DOMDocument* doc = impl->createDocument( 0, fromNative(AlignmentConstant_tag).c_str(), doctype );
DOMElement* root = doc->getDocumentElement();

xuti::writeHeader(root,header);
Expand Down Expand Up @@ -126,8 +119,11 @@ string EcalAlignmentXMLTranslator::dumpXML(const EcalCondHeader& header,
xuti::WriteNodeWithValue(cellnode, Psi_tag, (*it).rotation().getPsi());
}

string dump = toNative(writer->writeToString(*root));
std::string dump = toNative( writer->writeToString( root ));
doc->release();
doctype->release();
writer->release();

return dump;
}

24 changes: 9 additions & 15 deletions CondTools/Ecal/src/EcalChannelStatusXMLTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,15 @@ std::string EcalChannelStatusXMLTranslator::dumpXML(

cms::concurrency::xercesInitialize();

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());

DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str()));

DOMLSSerializer* writer = impl->createLSSerializer();
if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );

DOMDocumentType* doctype = impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
DOMDocument * doc =
impl->createDocument( 0, fromNative(ChannelStatus_tag).c_str(), doctype );


doc->setEncoding(fromNative("UTF-8").c_str() );
doc->setStandalone(true);
doc->setVersion(fromNative("1.0").c_str() );


DOMElement* root = doc->getDocumentElement();

Expand Down Expand Up @@ -154,11 +148,11 @@ std::string EcalChannelStatusXMLTranslator::dumpXML(

}


std::string dump= toNative(writer->writeToString(*root));
doc->release();
std::string dump = toNative(writer->writeToString( root ));
doc->release();
doctype->release();
writer->release();
// cms::concurrency::xercesTerminate();

return dump;

}
19 changes: 8 additions & 11 deletions CondTools/Ecal/src/EcalClusterCrackCorrXMLTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,17 @@ EcalClusterCrackCorrXMLTranslator::dumpXML(

cms::concurrency::xercesInitialize();

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str()));

DOMWriter* writer =
static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
DOMLSSerializer* writer = impl->createLSSerializer();
if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );

DOMDocumentType* doctype =
impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
const std::string EcalClusterCrackCorr_tag("EcalClusterCrackCorr");
DOMDocument * doc =
impl->createDocument( 0, fromNative(EcalClusterCrackCorr_tag).c_str(), doctype );


doc->setEncoding(fromNative("UTF-8").c_str() );
doc->setStandalone(true);
doc->setVersion(fromNative("1.0").c_str() );

DOMElement* root = doc->getDocumentElement();
xuti::writeHeader(root, header);
Expand All @@ -99,8 +93,11 @@ EcalClusterCrackCorrXMLTranslator::dumpXML(
num++;
}

std::string dump= toNative(writer->writeToString(*root));
std::string dump = toNative(writer->writeToString( root ));
doc->release();
doctype->release();
writer->release();

return dump;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,18 @@ EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::dumpXML(

cms::concurrency::xercesInitialize();

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str()));

DOMWriter* writer =
static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
DOMLSSerializer* writer = impl->createLSSerializer();
if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );

DOMDocumentType* doctype =
impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
const std::string ECECOS_tag("EcalClusterEnergyCorrectionObjectSpecific");
DOMDocument * doc =
impl->createDocument( 0, fromNative(ECECOS_tag).c_str(), doctype );


doc->setEncoding(fromNative("UTF-8").c_str() );
doc->setStandalone(true);
doc->setVersion(fromNative("1.0").c_str() );


DOMElement* root = doc->getDocumentElement();
xuti::writeHeader(root, header);

Expand Down Expand Up @@ -106,8 +99,11 @@ EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::dumpXML(
}
std::cout << "\n";

std::string dump= toNative(writer->writeToString(*root));
std::string dump = toNative(writer->writeToString( root ));
doc->release();
doctype->release();
writer->release();

return dump;
}

Expand Down
20 changes: 8 additions & 12 deletions CondTools/Ecal/src/EcalClusterEnergyCorrectionXMLTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,18 @@ EcalClusterEnergyCorrectionXMLTranslator::dumpXML(

cms::concurrency::xercesInitialize();

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str()));

DOMWriter* writer =
static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
DOMLSSerializer* writer = impl->createLSSerializer();
if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );

DOMDocumentType* doctype =
impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
const std::string EcalClusterEnergyCorrection_tag("EcalClusterEnergyCorrection");
DOMDocument * doc =
impl->createDocument( 0, fromNative(EcalClusterEnergyCorrection_tag).c_str(), doctype );


doc->setEncoding(fromNative("UTF-8").c_str() );
doc->setStandalone(true);
doc->setVersion(fromNative("1.0").c_str() );


DOMElement* root = doc->getDocumentElement();
xuti::writeHeader(root, header);

Expand All @@ -90,8 +83,11 @@ EcalClusterEnergyCorrectionXMLTranslator::dumpXML(
WriteNodeWithValue(ECEC,Value_tag,*it);
}

std::string dump= toNative(writer->writeToString(*root));
std::string dump = toNative(writer->writeToString( root ));
doc->release();
doctype->release();
writer->release();

return dump;
}

Expand Down
Loading

0 comments on commit 7fca0a2

Please sign in to comment.