本文整理汇总了C++中XmlDocument::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlDocument::getName方法的具体用法?C++ XmlDocument::getName怎么用?C++ XmlDocument::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlDocument
的用法示例。
在下文中一共展示了XmlDocument::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidateDocument
void MgResourceDefinitionManager::ValidateDocument(XmlDocument& xmlDoc)
{
MG_RESOURCE_SERVICE_TRY()
MgResourceIdentifier resource(MgUtil::MultiByteToWideChar(xmlDoc.getName()));
// Skip XML schema validation on runtime resources.
if (!resource.IsRuntimeResource())
{
std::string xmlContent;
MgXmlUtil xmlUtil(xmlDoc.getContent(xmlContent));
DOMElement* rootNode = xmlUtil.GetRootNode();
if(NULL != rootNode)
{
assert(NULL != rootNode);
STRING rootName;
const XMLCh* tag = rootNode->getTagName();
if (NULL != tag)
{
rootName = X2W(tag);
assert(!rootName.empty());
}
STRING schemaName;
const XMLCh* attr = rootNode->getAttribute(X("xsi:noNamespaceSchemaLocation"));
if (NULL != attr)
{
schemaName = X2W(attr);
}
ValidateDocument(resource, rootName, schemaName);
}
}
MG_RESOURCE_CONTAINER_CATCH_AND_THROW(L"MgResourceDefinitionManager.ValidateDocument")
}
示例2: doContextQuery
void doContextQuery( XmlTransaction &txn, XmlManager &mgr, const std::string cname,
const std::string &query, XmlQueryContext &context )
{
////////////////////////////////////////////////////////////////////////
////// Performs a simple query (with context) against the ///////
////// provided container. ///////
////////////////////////////////////////////////////////////////////////
///// some defensive code eliminated for clarity //
// Perform the query. Result type is by default Result Document
std::string fullQuery = "collection('" + cname + "')" + query;
try {
std::cout << "Exercising query '" << fullQuery << "' " << std::endl;
std::cout << "Return to continue: ";
getc(stdin);
std::cout << "\n";
XmlResults results( mgr.query(txn, fullQuery, context ) );
XmlValue value;
while(results.next(value)) {
// Get the document's name and print it to the console
XmlDocument theDocument = value.asDocument();
std::cout << "Document name: " << theDocument.getName() << std::endl;
std::cout << value.asString() << std::endl;
}
std::cout << (unsigned int)results.size()
<< " objects returned for expression '" << fullQuery
<< "'\n" << std::endl;
}
//Catches XmlException
catch(std::exception &e) {
std::cerr << "Query " << fullQuery << " failed\n";
std::cerr << e.what() << "\n";
txn.abort();
exit( -1 );
}
}
示例3: doGetDocument
//Get a document from the container using the document name
void doGetDocument( XmlTransaction &txn, XmlContainer &container, const std::string docname)
{
try {
std::cout << "Getting document '" << docname << "' from the container." << std::endl;
std::cout << "Return to continue: ";
getc(stdin);
std::cout << "\n";
//Get the document from the container using the document name
XmlDocument theDocument = container.getDocument(txn, docname);
std::string content;
std::cout << "Document name: " << theDocument.getName() << std::endl;
std::cout << theDocument.getContent(content) << std::endl;
}
//Catches XmlException
catch(std::exception &e) {
std::cerr << "Get document from container failed.\n";
std::cerr << e.what() << "\n";
txn.abort();
exit( -1 );
}
}
示例4: DeleteResource
void MgResourceDefinitionManager::DeleteResource(
MgResourceIdentifier* resource, bool strict)
{
assert(NULL != resource);
MG_RESOURCE_SERVICE_TRY()
string resourcePathname;
MgUtil::WideCharToMultiByte(resource->ToString(), resourcePathname);
// Set up an XQuery.
string query;
if (resource->IsFolder())
{
query = "for $i in collection('";
query += m_container.getName();
query += "')";
query += "/*[starts-with(dbxml:metadata('dbxml:name'),'";
query += resourcePathname;
query += "')]";
query += " order by dbxml:metadata('dbxml:name', $i) descending return $i";
}
else
{
query = "collection('";
query += m_container.getName();
query += "')";
query += "/*[dbxml:metadata('dbxml:name')='";
query += resourcePathname;
query += "']";
}
// Execute the XQuery.
XmlManager& xmlManager = m_container.getManager();
XmlQueryContext queryContext = xmlManager.createQueryContext();
queryContext.setNamespace(MgResourceInfo::sm_metadataPrefix,
MgResourceInfo::sm_metadataUri);
XmlResults results = IsTransacted() ?
xmlManager.query(GetXmlTxn(), query, queryContext, 0) :
xmlManager.query(query, queryContext, 0);
if (0 == results.size())
{
if (!strict || (IsResourceContentManager() && resource->IsFolder()))
{
return;
}
else
{
m_repositoryMan.ThrowResourceNotFoundException(*resource,
L"MgResourceDefinitionManager.DeleteResource",
__LINE__, __WFILE__);
}
}
// Delete the resources.
MgResourceIdentifier currResource;
XmlUpdateContext updateContext = xmlManager.createUpdateContext();
XmlValue xmlValue;
while (results.next(xmlValue))
{
XmlDocument xmlDoc = xmlValue.asDocument();
currResource.SetResource(MgUtil::MultiByteToWideChar(xmlDoc.getName()));
if (!currResource.IsRoot())
{
DeleteDocument(currResource, xmlDoc, updateContext);
}
}
if (!resource->IsRoot())
{
m_repositoryMan.UpdateDateModifiedResourceSet(resource->GetFullPath(true));
}
MG_RESOURCE_CONTAINER_CATCH_AND_THROW(L"MgResourceDefinitionManager.DeleteResource")
}