// --------------------------------------------------------------------------- // MemParseHandlers: Overrides of the SAX ErrorHandler interface // --------------------------------------------------------------------------- void MemParseHandlers::error(const SAXParseException& e) { XERCES_STD_QUALIFIER cerr << "\nError at (file " << StrX(e.getSystemId()) << ", line " << e.getLineNumber() << ", char " << e.getColumnNumber() << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl; }
void DOMTreeErrorReporter::error(const SAXParseException& toCatch) { fSawErrors = true; XERCES_STD_QUALIFIER cerr << "Error at file \"" << StrX(toCatch.getSystemId()) << "\", line " << toCatch.getLineNumber() << ", column " << toCatch.getColumnNumber() << "\n Message: " << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; }
// overrides SAX fatalError Handler void CommonReadHandler::fatalError(const SAXParseException& e) { cerr << "\nFatal Error parsing the XML input file:" << endl; cerr << "\nFatal Error in file " << StrX(e.getSystemId()) << ", at line " << e.getLineNumber() << ", char " << e.getColumnNumber() << ": " << StrX(e.getMessage()) << endl; throw "\nFix the input file and retry."; }
// --------------------------------------------------------------------------- // SAX2CountHandlers: Overrides of the SAX ErrorHandler interface // --------------------------------------------------------------------------- void SAX2CountHandlers::error(const SAXParseException& e) { fSawErrors = true; XERCES_STD_QUALIFIER cerr << "\nError at file " << StrX(e.getSystemId()) << ", line " << e.getLineNumber() << ", char " << e.getColumnNumber() << "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl; }
void BaseHarnessHandlers::fatalError(const SAXParseException& e) { fSawErrors = true; XERCES_STD_QUALIFIER cout << "\nFatal Error at file " << StrX(e.getSystemId()) << ", line " << e.getLineNumber() << ", char " << e.getColumnNumber() << "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl; }
void InitTermTestErrorHandler::fatalError(const SAXParseException& e) { fSawErrors = true; XERCES_STD_QUALIFIER cerr << "\nFatal Error at file " << StrX(e.getSystemId()) << ", line " << e.getLineNumber() << ", char " << e.getColumnNumber() << "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl; }
void DOMTreeErrorReporter::fatalError(const SAXParseException& toCatch) { fSawErrors = true; cerr << "Fatal Error at file \"" << StrX(toCatch.getSystemId()) << "\", line " << toCatch.getLineNumber() << ", column " << toCatch.getColumnNumber() << "\n Message: " << StrX(toCatch.getMessage()) << endl; }
void printBasic(XSObject *xsObject, const char *type) { XERCES_STD_QUALIFIER cout << "Name:\t\t\t"; const XMLCh *nameSpace = xsObject->getNamespace(); if (nameSpace && *nameSpace) { XERCES_STD_QUALIFIER cout << StrX(nameSpace) << ", "; } XERCES_STD_QUALIFIER cout << StrX(xsObject->getName()) << "\n"; XERCES_STD_QUALIFIER cout << "Component Type:\t" << type << XERCES_STD_QUALIFIER endl; }
void LoadSchemaErrorHandler::warning(const XERCES_CPP_NAMESPACE::SAXParseException& e) { XERCES_STD_QUALIFIER cerr << "\nWarning at file " << StrX(e.getSystemId()) << ", line " << e.getLineNumber() << ", char " << e.getColumnNumber() << "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl; //XQueryDiagnostics xqueryDiagnostics; //ZORBA_WARNING(&xqueryDiagnostics, XQST0059, StrX(e.getMessage()), _loc); }
bool Module::AddDOMattribute (const string attribute, const string value){ if (HasDOMattribute(attribute)) return false; ((DOMElement*) m_node)->setAttribute( StrX(attribute).XMLchar(), StrX(value).XMLchar() ); return true; }
int deCommand(void * *mObject,const void * paramNode){ DOMNode * node=(DOMNode *)paramNode; node=node->getFirstChild(); if(!node) //err log here return AXIS_FAIL; if(node->getNodeType()!=DOMNode::NodeType::ELEMENT_NODE) node=SoapParser::getNextSiblingNotNull(node,DOMNode::NodeType::ELEMENT_NODE); if(!node) //err log here return AXIS_FAIL; if(0!=strcmp("Statement",StrX(node->getLocalName()).localForm())) //err log here return AXIS_FAIL; //if there is next element node,err! DOMNode * nextnode=node->getNextSibling(); if(nextnode){ if(nextnode->getNodeType()==DOMNode::NodeType::ELEMENT_NODE) //err log here return AXIS_FAIL; else nextnode=SoapParser::getNextSiblingNotNull(node,DOMNode::NodeType::ELEMENT_NODE); if(nextnode) //err log here return AXIS_FAIL; } node=node->getFirstChild(); if(!node) //err log here return AXIS_FAIL; if(node->getNodeType()!=DOMNode::NodeType::TEXT_NODE) node=SoapParser::getNextSiblingNotNull(node,DOMNode::NodeType::TEXT_NODE); if(!node) //err log here return AXIS_FAIL; string value=StrX(node->getNodeValue()).localForm(); Command *cmd=new Command(value); if(!*mObject) *mObject=cmd; else{ delete cmd; //err log here return AXIS_FAIL; } return AXIS_SUCCESS; }
// --------------------------------------------------------------------------- // Program entry point // --------------------------------------------------------------------------- int main(int argC, char* argV[]) { // cannot return out of catch-blocks lest exception-destruction // result in calls to destroyed memory handler! int errorCode = 0; // Initialize the XML4C system try { XMLPlatformUtils::Initialize(); } catch (const XMLException& toCatch) { XERCES_STD_QUALIFIER cerr << "Error during initialization! Message:\n" << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; errorCode = 1; } if(errorCode) { XMLPlatformUtils::Terminate(); return errorCode; } // Check command line and extract arguments. // We only have one required parameter, which is the file to process if ((argC != 2) || (*(argV[1]) == '-')) { usage(); XMLPlatformUtils::Terminate(); return 2; } try { process(argV[1]); } catch (const OutOfMemoryException&) { XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl; errorCode = 5; } catch (const XMLException& e) { XERCES_STD_QUALIFIER cerr << "\nError during parsing: '" << argV[1] << "'\n" << "Exception message is: \n" << StrX(e.getMessage()) << "\n" << XERCES_STD_QUALIFIER endl; errorCode = 3; } XMLPlatformUtils::Terminate(); return errorCode; }
//--------------------------------------------------------------------- // Prints the Attribute's properties //--------------------------------------------------------------------- void processAttributes( XMLAttDefList& attList, bool margin ) { if ( attList.isEmpty() ) { return; } if ( margin ) { XERCES_STD_QUALIFIER cout << "\t"; } XERCES_STD_QUALIFIER cout << "Attributes:\n"; for (unsigned int i=0; i<attList.getAttDefCount(); i++) { // Name SchemaAttDef& curAttDef = (SchemaAttDef&)attList.getAttDef(i); XERCES_STD_QUALIFIER cout << "\tName:\t\t\t" << StrX(curAttDef.getFullName()) << "\n"; // Type XERCES_STD_QUALIFIER cout << "\tType:\t\t\t"; XERCES_STD_QUALIFIER cout << StrX(XMLAttDef::getAttTypeString(curAttDef.getType())); XERCES_STD_QUALIFIER cout << "\n"; // Default Type XERCES_STD_QUALIFIER cout << "\tDefault Type:\t"; XERCES_STD_QUALIFIER cout << StrX(XMLAttDef::getDefAttTypeString(curAttDef.getDefaultType())); XERCES_STD_QUALIFIER cout << "\n"; // Value if( curAttDef.getValue() ) { XERCES_STD_QUALIFIER cout << "\tValue:\t\t\t"; XERCES_STD_QUALIFIER cout << StrX(curAttDef.getValue()); XERCES_STD_QUALIFIER cout << "\n"; } // Enum. values if( curAttDef.getEnumeration() ) { XERCES_STD_QUALIFIER cout << "\tEnumeration:\t"; XERCES_STD_QUALIFIER cout << StrX(curAttDef.getEnumeration()); XERCES_STD_QUALIFIER cout << "\n"; } const DatatypeValidator* dv = curAttDef.getDatatypeValidator(); processDatatypeValidator( dv, true ); XERCES_STD_QUALIFIER cout << "\n"; } }
bool serializeDOM(std::ostream& output, bool) { XMLCh tempStr[100]; XMLString::transcode("LS", tempStr, 99); DOMImplementationLS *impl = dynamic_cast<DOMImplementationLS *>(DOMImplementationRegistry::getDOMImplementation(tempStr)); DOMLSSerializer *theSerializer = impl->createLSSerializer(); DOMLSOutput *theOutputDesc = impl->createLSOutput(); bool rc = false; try { MemBufFormatTarget *myFormTarget = new MemBufFormatTarget(); /* do the serialization through DOMLSSerializer::write(); */ theOutputDesc->setByteStream(myFormTarget); theSerializer->write(inputFileDOM, theOutputDesc); const XMLByte * data = myFormTarget->getRawBuffer(); XMLSize_t len = myFormTarget->getLen(); output.write( reinterpret_cast<const char *>(data), len ); delete myFormTarget; rc = true; } catch (IOException& e ) { cerr << StrX(e.getMessage()); cerr << " Code is " << e.getCode(); if ( errno != 0 ) { cerr << ": " << strerror( errno ); } } catch (XMLException& e) { cerr << "An error occurred during creation of output transcoder. Msg is:" << endl << StrX(e.getMessage()); if ( errno != 0 ) { cerr << ": " << strerror( errno ); } cerr << endl; rc = false; } delete theSerializer; return rc; }
void Coil::Initialize (DOMNode* node) { //m_sens_mag = NULL; //m_sens_pha = NULL; m_node = node; string s = StrX(((DOMElement*) node)->getAttribute (StrX("Name").XMLchar() )).std_str() ; if (s.empty()) { ((DOMElement*) node)->setAttribute(StrX("Name").XMLchar(),node->getNodeName()); SetName( StrX(node->getNodeName()).std_str() ); } }
/** * Constructor. * * @param xmlFile the character string containing XML representation of the parameter set data. */ ParameterSet::ParameterSet(const char* xmlFile) { // Initialize the XML4C2 system try { XMLPlatformUtils::Initialize(); std::cout << "initialized XML platform\n"; PARAMETER_TAG_NAME = XMLString::transcode("parameter"); NAME_TAG_NAME = XMLString::transcode("name"); VALUE_TAG_NAME = XMLString::transcode("value"); UNITS_TAG_NAME = XMLString::transcode("units"); INT_PARAM_TYPE = XMLString::transcode("IntParamType"); DOUBLE_PARAM_TYPE = XMLString::transcode("DoubleParamType"); STRING_PARAM_TYPE = XMLString::transcode("StringParamType"); BOOL_PARAM_TYPE = XMLString::transcode("BoolParamType"); INT_ARRAY_PARAM_TYPE = XMLString::transcode("IntArrayParamType"); DOUBLE_ARRAY_PARAM_TYPE = XMLString::transcode("DoubleArrayParamType"); STRING_ARRAY_PARAM_TYPE = XMLString::transcode("StringArrayParamType"); parseInputString(xmlFile); } catch (const XMLException& toCatch) { std::cerr << "Error during initialization! Message:\n" << StrX(toCatch.getMessage()) << std::endl; } catch (const std::invalid_argument argError) { std::cerr << "****** Error validating against the parameter set definition! ******* \n\nMessage: \n\n" << argError.what() << "*********************************************************************" << std::endl << std::endl; } }
void TestParser::TextDecl( const XMLCh* const versionStr , const XMLCh* const encodingStr) { if (fOutputType == OutputType_Debug) { XERCES_STD_QUALIFIER cout << "Got TEXTDECL:\n "; if (XMLString::stringLen(versionStr)) XERCES_STD_QUALIFIER cout << "Version: " << StrX(versionStr); if (XMLString::stringLen(encodingStr)) XERCES_STD_QUALIFIER cout << "Encoding: " << StrX(encodingStr); XERCES_STD_QUALIFIER cout << "\n" << XERCES_STD_QUALIFIER endl; } }
XMLIO::XMLIO () { try { XMLPlatformUtils::Initialize(); } catch (const XMLException& e) { XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n" << " Exception message:" << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl; } m_parser = new XercesDOMParser; m_err_reporter = new DOMTreeErrorReporter; XercesDOMParser::ValSchemes valScheme = XercesDOMParser::Val_Auto; doNamespaces = false; doSchema = false; schemaFullChecking = false; doCreate = false; m_parser->setValidationScheme (valScheme); m_parser->setDoNamespaces (doNamespaces); m_parser->setDoSchema (doSchema); m_parser->setValidationSchemaFullChecking (schemaFullChecking); m_parser->setCreateEntityReferenceNodes (doCreate); m_parser->setErrorHandler (m_err_reporter); }
void processElements(XSNamedMap<XSObject> *xsElements) { if (!xsElements || xsElements->getLength() == 0) { XERCES_STD_QUALIFIER cout << "no elements\n\n" << XERCES_STD_QUALIFIER endl; return; } for (XMLSize_t i=0; i < xsElements->getLength(); i++) { XSElementDeclaration *xsElement = (XSElementDeclaration *)xsElements->item(i); printBasic(xsElement, "Element"); // Content Model XSTypeDefinition *xsTypeDef = xsElement->getTypeDefinition(); XERCES_STD_QUALIFIER cout << "Content Model" << "\n"; XERCES_STD_QUALIFIER cout << "\tType:\t"; if (xsTypeDef->getTypeCategory() == XSTypeDefinition::SIMPLE_TYPE) { XERCES_STD_QUALIFIER cout << "Simple\n"; } else { XERCES_STD_QUALIFIER cout << "Complex\n"; } XERCES_STD_QUALIFIER cout << "\tName:\t" << StrX(xsTypeDef->getName()) << "\n"; XERCES_STD_QUALIFIER cout << "\n--------------------------------------------" << XERCES_STD_QUALIFIER endl; } }
void Module::Initialize (DOMNode* node) { //if node has no "Name" attribute, insert it and use the node name for its value string s = StrX(((DOMElement*) node)->getAttribute (StrX("Name").XMLchar() )).std_str() ; if (s.empty()) ((DOMElement*) node)->setAttribute(StrX("Name").XMLchar(),node->getNodeName()); //set the module name to the node name as well SetName( StrX(node->getNodeName()).std_str() ); //set the instances of this node and the sequence tree m_node = node; m_seq_tree = SequenceTree::instance(); m_parameters = m_seq_tree->GetParameters(); }
void processParticle(XSParticle *xsParticle) { if (!xsParticle) { XERCES_STD_QUALIFIER cout << "xsParticle is NULL"; return; } XSParticle::TERM_TYPE termType = xsParticle->getTermType(); if (termType == XSParticle::TERM_ELEMENT) { XSElementDeclaration *xsElement = xsParticle->getElementTerm(); XERCES_STD_QUALIFIER cout << StrX(xsElement->getName()); } else if (termType == XSParticle::TERM_MODELGROUP) { XERCES_STD_QUALIFIER cout << "("; XSModelGroup *xsModelGroup = xsParticle->getModelGroupTerm(); XSModelGroup::COMPOSITOR_TYPE compositorType = xsModelGroup->getCompositor(); XSParticleList *xsParticleList = xsModelGroup->getParticles(); for (unsigned i = 0; i < xsParticleList->size()-1; i++) { processParticle(xsParticleList->elementAt(i)); printCompositorTypeConnector(compositorType); } processParticle(xsParticleList->elementAt(xsParticleList->size()-1)); XERCES_STD_QUALIFIER cout << ")"; } else if (termType == XSParticle::TERM_WILDCARD) { XERCES_STD_QUALIFIER cout << "* (wildcard)"; } }
void TestParser::startAttList(const DTDElementDecl& elemDecl) { if (fOutputType == OutputType_Debug) { XERCES_STD_QUALIFIER cout << "Got STARTATTLIST:\n " << "Name: " << StrX(elemDecl.getFullName()) << "\n" << XERCES_STD_QUALIFIER endl; } else if (fOutputType != OutputType_None) { if (fInExtSubset) return; if (fIntDTDOutput) XERCES_STD_QUALIFIER cout << "<!ATTLIST " << StrX(elemDecl.getFullName()); } }
void TestParser::showIds(const XMLCh* const publicId, const XMLCh* const systemId) { if (XMLString::stringLen(publicId) || XMLString::stringLen(systemId)) { if (!XMLString::stringLen(publicId)) { XERCES_STD_QUALIFIER cout << " SYSTEM '" << StrX(systemId) << "'"; } else { XERCES_STD_QUALIFIER cout << " PUBLIC '" << StrX(publicId) << "'"; if (systemId) XERCES_STD_QUALIFIER cout << " '" << StrX(systemId) << "'"; } } }
void TestParser::startEntityReference(const XMLEntityDecl& entDecl) { if (fOutputType == OutputType_Debug) { XERCES_STD_QUALIFIER cout << "Got STARTENTITY:\n " << "Name: " << StrX(entDecl.getName()) << "\n" << XERCES_STD_QUALIFIER endl; } }
// --------------------------------------------------------------------------- // DOMCountHandlers: Overrides of the DOM ErrorHandler interface // --------------------------------------------------------------------------- bool DOMCountErrorHandler::handleError(const DOMError& domError) { fSawErrors = true; if (domError.getSeverity() == DOMError::DOM_SEVERITY_WARNING) XERCES_STD_QUALIFIER cerr << "\nWarning at file "; else if (domError.getSeverity() == DOMError::DOM_SEVERITY_ERROR) XERCES_STD_QUALIFIER cerr << "\nError at file "; else XERCES_STD_QUALIFIER cerr << "\nFatal Error at file "; XERCES_STD_QUALIFIER cerr << StrX(domError.getLocation()->getURI()) << ", line " << domError.getLocation()->getLineNumber() << ", char " << domError.getLocation()->getColumnNumber() << "\n Message: " << StrX(domError.getMessage()) << XERCES_STD_QUALIFIER endl; return true; }
void TestParser::XMLDecl(const XMLCh* const versionStr , const XMLCh* const encodingStr , const XMLCh* const standaloneStr , const XMLCh* const autoEncStr) { if (fOutputType == OutputType_Debug) { XERCES_STD_QUALIFIER cout << "Got XMLDECL:\n " << "Version:\"" << StrX(versionStr) << "\"" << " Encoding:\"" << StrX(encodingStr) << "\"" << " Standalone:\"" << StrX(standaloneStr) << "\"" << " Auto Encoding:\"" << StrX(autoEncStr) << "\"" << "\n" << " SrcOfs: " << fScanner->getSrcOffset() << "\n" << XERCES_STD_QUALIFIER endl; } else if (fOutputType == OutputType_XML) { XERCES_STD_QUALIFIER cout << "<?xml"; if (XMLString::stringLen(versionStr)) XERCES_STD_QUALIFIER cout << " version=\"" << StrX(versionStr) << '"'; if (XMLString::stringLen(encodingStr)) XERCES_STD_QUALIFIER cout << " encoding=\"" << StrX(encodingStr) << '"'; if (XMLString::stringLen(standaloneStr)) XERCES_STD_QUALIFIER cout << " standlone=\"" << StrX(standaloneStr) << '"'; XERCES_STD_QUALIFIER cout << " ?>"; } }
void XMLConfigErrorHandler::error(const SAXParseException &toCatch) { m_lstrErrors.push_back( QString("XML parsing error: %1, line %2, column %3").arg(StrX(toCatch.getMessage()).char_str()) .arg(toCatch.getLineNumber()) .arg(toCatch.getColumnNumber())); m_bSawErrors = true; }
void TestParser::doctypeComment(const XMLCh* const comment) { if (fOutputType == OutputType_Debug) { XERCES_STD_QUALIFIER cout << "Got DTD COMMENT:\n " << "Text: \"" << StrX(comment) << "\"\n" << " SrcOfs: " << fScanner->getSrcOffset() << "\n" << XERCES_STD_QUALIFIER endl; } else if (fOutputType != OutputType_None) { if (fInExtSubset) return; if (fIntDTDOutput) XERCES_STD_QUALIFIER cout << "<!--" << StrX(comment) << "-->"; } }
Module* ModulePrototypeFactory::CloneModule (DOMNode* node) { string name = StrX(node->getNodeName()).std_str() ; transform(name.begin(), name.end(), name.begin(), (int(*)(int)) toupper); Module* toClone = GetModule(name); if (!toClone) return NULL; return toClone->Clone(); }
////////////////////////////////////////////////////////////////////////////// /// \brief /// \param str /// \return string ////////////////////////////////////////////////////////////////////////////// string XMLUtil::WideCharToString(const XMLCh * wstr, int wstrlen) { // return StrX(wstr ).c_str(); /* if (wstrlen == -1 ) { wstrlen = (int)wcslen(wstr); }*/ // test korean with WideCharToMultiByte // int WideCharToMultiByte( // UINT CodePage, // code page // DWORD dwFlags, // performance and mapping flags // LPCWSTR lpWideCharStr, // wide-character string // int cchWideChar, // number of chars in string // LPSTR lpMultiByteStr, // buffer for new string // int cbMultiByte, // size of buffer // LPCSTR lpDefaultChar, // default for unmappable chars // LPBOOL lpUsedDefaultChar // set when default char used // ); // //lpDefaultChar // [in] Points to the character used if a wide character cannot be represented in the specified code page. // If this parameter is NULL, a system default value is used. // The function is faster when both lpDefaultChar and lpUsedDefaultChar are NULL. // For the code pages mentioned in dwFlags, lpDefaultChar must be NULL, // otherwise the function fails with ERROR_INVALID_PARAMETER. // lpUsedDefaultChar // [in] Points to a flag that indicates whether a default character was used. // The flag is set to TRUE if one or more wide characters in the source string // cannot be represented in the specified code page. Otherwise, the flag is set to FALSE. // This parameter may be NULL. The function is faster when both lpDefaultChar and lpUsedDefaultChar are NULL. // For the code pages mentioned in dwFlags, lpUsedDefaultChar must be NULL, // otherwise the function fails with ERROR_INVALID_PARAMETER. // 최소한의 복사를 줄이기 위해서 스트링을 준비. /* string strBuffer; strBuffer.reserve(wstrlen * 2 + 1); // capacity 를 충분하게.. int nCopied = WideCharToMultiByte( CP_OEMCP, WC_COMPOSITECHECK, wstr, // wide string wstrlen, // length of wide string const_cast<LPSTR>(strBuffer.data()), // mbcs string (unicode) (int)strBuffer.capacity(), // length of mbcs string NULL, // NULL 이 빠르다는데? NULL); strBuffer[nCopied] = 0; strBuffer._Mysize = nCopied; // 수동으로 지정해야 한다. return strBuffer;*/ return StrX(wstr).toString(); }