本文整理汇总了C++中XercesDOMParser::setDoXInclude方法的典型用法代码示例。如果您正苦于以下问题:C++ XercesDOMParser::setDoXInclude方法的具体用法?C++ XercesDOMParser::setDoXInclude怎么用?C++ XercesDOMParser::setDoXInclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XercesDOMParser
的用法示例。
在下文中一共展示了XercesDOMParser::setDoXInclude方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
static void
xsdproc (std::string const &schemadir, std::string const &input, std::string const &output)
{
XercesDOMParser parser;
parser.setExternalSchemaLocation ((
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul " + schemadir + "/xul.xsd "
"http://www.w3.org/1999/xhtml " + schemadir + "/xul-html.xsd "
"http://www.w3.org/2000/10/xlink-ns " + schemadir + "/xml/xlink.xsd "
//"http://www.w3.org/2001/SMIL20/ " + schemadir + "/smil/smil20.xsd "
"http://www.w3.org/2001/XInclude " + schemadir + "/xml/xinclude.xsd "
"http://www.w3.org/2002/07/owl# " + schemadir + "/owl/owl.xsd "
"http://www.w3.org/XML/1998/namespace " + schemadir + "/xml/xml.xsd "
).c_str ());
parser.setCreateEntityReferenceNodes (true);
parser.setDoNamespaces (true);
parser.setDoSchema (true);
parser.setDoXInclude (true);
parser.setHandleMultipleImports (true);
parser.setValidationSchemaFullChecking (true);
parser.setValidationScheme (XercesDOMParser::Val_Always);
error_handler handler;
parser.setErrorHandler (&handler);
parser.parse (input.c_str ());
if (handler.failed)
throw std::runtime_error ("validation failed for " + input);
serialise (parser.getDocument (), output);
}
示例2: read
void XMLRuntime::read(const string& filename, FreeAX25::Runtime::Configuration& config) {
XercesDOMParser parser;
parser.setValidationScheme(XercesDOMParser::Val_Always);
parser.setDoNamespaces(true);
parser.setDoSchema(true);
parser.setDoXInclude(true);
parser.setHandleMultipleImports(true);
parser.setValidationSchemaFullChecking(true);
parser.setCreateEntityReferenceNodes(false);
parser.setIncludeIgnorableWhitespace(false);
DOMTreeErrorReporter errReporter;
parser.setErrorHandler(&errReporter);
parser.parse(filename.c_str());
if (errReporter.getSawErrors())
throw exception();
// Now read configuration from the DOM Tree:
XERCES_CPP_NAMESPACE::DOMDocument* doc = parser.getDocument();
assert(doc != nullptr);
auto rootElement = doc->getDocumentElement();
auto configName = rootElement->getAttribute(toX("name"));
config.setId(fmX(configName));
{ // Get settings:
auto nodeList = rootElement->getElementsByTagName(toX("Settings"));
if (nodeList->getLength() > 0)
readSettings(
"",
static_cast<DOMElement*>(nodeList->item(0)),
config.settings);
}
{ // Get plugins:
auto nodeList = rootElement->getElementsByTagName(toX("Plugins"));
if (nodeList->getLength() > 0)
readPlugins(
"",
static_cast<DOMElement*>(nodeList->item(0)),
config.plugins);
}
}
示例3: resIdentifier
DOMDocument *
XIncludeUtils::doXIncludeXMLFileDOM(const XMLCh *href,
const XMLCh *relativeHref,
DOMNode *includeNode,
DOMDocument *parsedDocument,
XMLEntityHandler* entityResolver){
if (XIncludeUtils::isInCurrentInclusionHistoryStack(href)){
/* including something back up the current history */
XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeCircularInclusionLoop,
href, href);
return NULL;
}
if (XMLString::equals(href, parsedDocument->getBaseURI())){
/* trying to include itself */
XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeCircularInclusionDocIncludesSelf,
href, href);
return NULL;
}
/* Instantiate the DOM parser. */
XercesDOMParser parser;
parser.setDoNamespaces(true);
/* don't want to recurse the xi processing here */
parser.setDoXInclude(false);
/* create the schema info nodes, so that we can detect conflicting notations */
parser.setCreateSchemaInfo(true);
XMLInternalErrorHandler xierrhandler;
parser.setErrorHandler(&xierrhandler);
DOMDocument *includedNode = NULL;
try {
InputSource* is=NULL;
Janitor<InputSource> janIS(is);
if(entityResolver) {
XMLResourceIdentifier resIdentifier(XMLResourceIdentifier::ExternalEntity,
relativeHref,
NULL,
NULL,
includeNode->getBaseURI());
is=entityResolver->resolveEntity(&resIdentifier);
janIS.reset(is);
}
if(janIS.get()!=NULL)
parser.parse(*janIS.get());
else
parser.parse(href);
/* need to be able to release the parser but keep the document */
if (!xierrhandler.getSawError() && !xierrhandler.getSawFatal())
includedNode = parser.adoptDocument();
}
catch (const XMLException& /*toCatch*/)
{
XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeResourceErrorWarning,
href, href);
}
catch (const DOMException& /*toCatch*/)
{
XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeResourceErrorWarning,
href, href);
}
catch (...)
{
XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeResourceErrorWarning,
href, href);
}
//addDocumentURIToCurrentInclusionHistoryStack(href);
if(includedNode != NULL){
/* baseURI fixups - see http://www.w3.org/TR/xinclude/#base for details. */
DOMElement *topLevelElement = includedNode->getDocumentElement();
if (topLevelElement && topLevelElement->getNodeType() == DOMNode::ELEMENT_NODE ){
XMLUri parentURI(includeNode->getBaseURI());
XMLUri includedURI(includedNode->getBaseURI());
/* if the paths differ we need to add a base attribute */
if (!XMLString::equals(parentURI.getPath(), includedURI.getPath())){
if (getBaseAttrValue(topLevelElement) == NULL){
/* need to calculate the proper path difference to get the relativePath */
topLevelElement->setAttribute(fgXIBaseAttrName, relativeHref);
} else {
/* the included node has base of its own which takes precedence */
XIncludeLocation xil(getBaseAttrValue(topLevelElement));
if (getBaseAttrValue(includeNode) != NULL){
/* prepend any specific base modification of the xinclude node */
xil.prependPath(getBaseAttrValue(includeNode));
}
topLevelElement->setAttribute(fgXIBaseAttrName, xil.getLocation());
}
}
}
}
return includedNode;
}
示例4: readServerConfig
bool ServerConfigXMLReader::readServerConfig(const std::string & path) {
this->serverConfig = ServerConfig();
try {
XMLPlatformUtils::Initialize();
} catch (const XMLException& toCatch) {
char * message = XMLString::transcode(toCatch.getMessage());
cout << "Error during initialization! :\n" << message << "\n";
XMLString::release(&message);
return false;
}
XercesDOMParser * parser = new XercesDOMParser();
//parser->setValidationScheme(XercesDOMParser::Val_Auto);
parser->setDoNamespaces(true);
parser->setDoXInclude(true);
//parser->setValidationScheme(XercesDOMParser::Val_Always);
// parser->setDoSchema(true);
// parser->setValidationSchemaFullChecking(true);
XMLParseErrorReporter * xmlParseErrorReporter = new XMLParseErrorReporter();;
parser->setErrorHandler(xmlParseErrorReporter);
try {
parser->parse(path.c_str());
} catch (const XMLException & toCatch) {
char * message = XMLString::transcode(toCatch.getMessage());
cout << "Exception message is: \n" << message << "\n";
XMLString::release(&message);
return false;
}
catch (const DOMException& toCatch) {
char * message = XMLString::transcode(toCatch.msg);
cout << "Exception message is: \n" << message << "\n";
XMLString::release(&message);
return false;
}
catch (...) {
cout << "Unexpected Exception \n" ;
return false;
}
DOMDocument * domDocument = parser->getDocument();
removeBaseAttr(domDocument);
// get a serializer, an instance of DOMLSSerializer
XMLCh tempStr[3] = {chLatin_L, chLatin_S, chNull};
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
DOMLSOutput *theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
// set user specified output encoding
theOutputDesc->setEncoding(0);
XMLDOMErrorReporter * xmlDOMErrorReporter = new XMLDOMErrorReporter();
DOMConfiguration * serializerConfig = theSerializer->getDomConfig();
serializerConfig->setParameter(XMLUni::fgDOMErrorHandler, xmlDOMErrorReporter);
// set feature if the serializer supports the feature/mode
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTSplitCdataSections, true))
serializerConfig->setParameter(XMLUni::fgDOMWRTSplitCdataSections, true);
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTDiscardDefaultContent, true))
serializerConfig->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent, true);
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, false))
serializerConfig->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, false);
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTBOM, false))
serializerConfig->setParameter(XMLUni::fgDOMWRTBOM, false);
/*
XMLFormatTarget * myFormTarget = new StdOutFormatTarget();
theOutputDesc->setByteStream(myFormTarget);
theSerializer->write(domDocument, theOutputDesc);
*/
MemBufFormatTarget * myFormTarget = new MemBufFormatTarget();
theOutputDesc->setByteStream(myFormTarget);
theSerializer->write(domDocument, theOutputDesc);
/*
XMLFormatTarget * myFormTarget2 = new StdOutFormatTarget();
theOutputDesc->setByteStream(myFormTarget2);
theSerializer->write(domDocument, theOutputDesc);
*/
MemBufInputSource * memInput = new MemBufInputSource(myFormTarget->getRawBuffer(), myFormTarget->getLen(), path.c_str());
XercesDOMParser * parser2 = new XercesDOMParser();
parser2->setDoNamespaces(true);
parser2->setDoXInclude(true);
// parser2->setValidationScheme(XercesDOMParser::Val_Always);
// parser2->setDoSchema(true);
// parser2->setValidationSchemaFullChecking(true);
parser2->setErrorHandler(xmlParseErrorReporter);
try {
//.........这里部分代码省略.........