本文整理汇总了C++中DOMElement::getParentNode方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMElement::getParentNode方法的具体用法?C++ DOMElement::getParentNode怎么用?C++ DOMElement::getParentNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::getParentNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// ---------------------------------------------------------------------------
// This method assumes that currentNode is an xinclude element and parses
// it accordingly, acting on what it finds.
// ---------------------------------------------------------------------------
bool
XIncludeUtils::doDOMNodeXInclude(DOMNode *xincludeNode, DOMDocument *parsedDocument, XMLEntityHandler* entityResolver){
bool modifiedNode = false;
/* the relevant attributes to look for */
const XMLCh *href = NULL;
const XMLCh *parse = NULL;
const XMLCh *xpointer = NULL;
const XMLCh *encoding = NULL;
const XMLCh *accept = NULL;
const XMLCh *acceptlanguage = NULL;
DOMNode *includeParent = xincludeNode->getParentNode();
if(xincludeNode->hasAttributes()) {
/* get all the attributes of the node */
DOMNamedNodeMap *pAttributes = xincludeNode->getAttributes();
XMLSize_t nSize = pAttributes->getLength();
for(XMLSize_t i=0;i<nSize;++i) {
DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
const XMLCh *attrName = pAttributeNode->getName();
/* check each attribute against the potential useful names */
if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeHREFAttrName)){
href = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeParseAttrName)){
parse = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeXPointerAttrName)){
xpointer = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeEncodingAttrName)){
encoding = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeAcceptAttrName)){
accept = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeAcceptLanguageAttrName)){
acceptlanguage = pAttributeNode->getValue();
} else {
/* if any other attribute is in the xi namespace, it's an error */
const XMLCh *attrNamespaceURI = pAttributeNode->getNamespaceURI();
if (attrNamespaceURI && XMLString::equals(attrNamespaceURI, XIncludeUtils::fgXIIIncludeNamespaceURI)){
} else {
/* ignore - any other attribute is allowed according to spec,
and must be ignored */
}
}
}
}
// 3.1 xi:include Element
// The children property of the xi:include element may include a single xi:fallback element;
// the appearance of more than one xi:fallback element, an xi:include element,
// or any other element from the XInclude namespace is a fatal error.
DOMNode *child;
DOMElement *fallback = NULL;
for (child = xincludeNode->getFirstChild(); child != 0; child=child->getNextSibling()){
if(child->getNodeType()!=DOMNode::ELEMENT_NODE)
continue;
if ( isXIFallbackDOMNode(child) ){
if (fallback != NULL){
/* fatal error - there are more than one fallback children */
XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeMultipleFallbackElems,
parsedDocument->getDocumentURI(), parsedDocument->getDocumentURI());
return false;
}
fallback = (DOMElement*)child;
}
else if(isXIIncludeDOMNode(child) || XMLString::equals(child->getNamespaceURI(), XIncludeUtils::fgXIIIncludeNamespaceURI)) {
/* fatal error - an xi element different from xi:fallback is a child of xi:include */
XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeDisallowedChild,
child->getNodeName(), parsedDocument->getDocumentURI());
return false;
}
}
if (href == NULL){
/* this is an unrecoverable error until we have xpointer support -
if there is an xpointer, the current document is assumed
however, there is no xpointer support yet */
XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeNoHref,
NULL, parsedDocument->getDocumentURI());
return false;
}
/* set up the accept and accept-language values */
if (accept != NULL){
}
if (parse == NULL){
/* use the default, as specified */
parse = XIncludeUtils::fgXIIncludeParseAttrXMLValue;
}
if (xpointer != NULL){
/* not supported yet */
/* Note that finding an xpointer attr along with parse="text" is a Fatal Error
* - http://www.w3.org/TR/xinclude/#include-location */
XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeXPointerNotSupported,
NULL, href);
return false;
//.........这里部分代码省略.........
示例2: if
DOMElement*
SchemaInfo::getTopLevelComponent(const unsigned short compCategory,
const XMLCh* const compName,
const XMLCh* const name) {
if (compCategory >= C_Count)
return 0;
DOMElement* child = XUtil::getFirstChildElement(fSchemaRootElement);
if (!child)
return 0;
RefHashTableOf<DOMElement>* compList = fTopLevelComponents[compCategory];
if (fTopLevelComponents[compCategory] == 0) {
compList= new (fMemoryManager) RefHashTableOf<DOMElement>(17, false, fMemoryManager);
fTopLevelComponents[compCategory] = compList;
}
else {
DOMElement* cachedChild = compList->get(name);
if(cachedChild)
return cachedChild;
child = fLastTopLevelComponent[compCategory];
}
DOMElement* redefParent = (DOMElement*) child->getParentNode();
// Parent is not "redefine"
if (!XMLString::equals(redefParent->getLocalName(),SchemaSymbols::fgELT_REDEFINE))
redefParent = 0;
while (child != 0) {
fLastTopLevelComponent[compCategory]=child;
if (XMLString::equals(child->getLocalName(), compName)) {
const XMLCh* cName=child->getAttribute(SchemaSymbols::fgATT_NAME);
compList->put((void*)cName, child);
if (XMLString::equals(cName, name))
return child;
}
else if (XMLString::equals(child->getLocalName(),SchemaSymbols::fgELT_REDEFINE)
&& (!fFailedRedefineList || !fFailedRedefineList->containsElement(child))) { // if redefine
DOMElement* redefineChild = XUtil::getFirstChildElement(child);
while (redefineChild != 0) {
fLastTopLevelComponent[compCategory]=redefineChild;
if ((!fFailedRedefineList || !fFailedRedefineList->containsElement(redefineChild))
&& XMLString::equals(redefineChild->getLocalName(), compName)) {
const XMLCh* rName=redefineChild->getAttribute(SchemaSymbols::fgATT_NAME);
compList->put((void*)rName, redefineChild);
if (XMLString::equals(rName, name))
return redefineChild;
}
redefineChild = XUtil::getNextSiblingElement(redefineChild);
}
}
child = XUtil::getNextSiblingElement(child);
if (child == 0 && redefParent) {
child = XUtil::getNextSiblingElement(redefParent);
redefParent = 0;
}
}
return child;
}
示例3: load
Override::Override(const DOMElement* e, Category& log, const Override* base) : m_base(base), m_acl(NULL)
{
try {
// Load the property set.
load(e,log,this);
// Load any AccessControl provider.
loadACL(e,log);
// Handle nested Paths.
DOMElement* path = XMLHelper::getFirstChildElement(e,Path);
for (int i=1; path; ++i, path=XMLHelper::getNextSiblingElement(path,Path)) {
const XMLCh* n=path->getAttributeNS(NULL,name);
// Skip any leading slashes.
while (n && *n==chForwardSlash)
n++;
// Check for empty name.
if (!n || !*n) {
log.warn("skipping Path element (%d) with empty name attribute", i);
continue;
}
// Check for an embedded slash.
int slash=XMLString::indexOf(n,chForwardSlash);
if (slash>0) {
// Copy the first path segment.
XMLCh* namebuf=new XMLCh[slash + 1];
for (int pos=0; pos < slash; pos++)
namebuf[pos]=n[pos];
namebuf[slash]=chNull;
// Move past the slash in the original pathname.
n=n+slash+1;
// Skip any leading slashes again.
while (*n==chForwardSlash)
n++;
if (*n) {
// Create a placeholder Path element for the first path segment and replant under it.
DOMElement* newpath=path->getOwnerDocument()->createElementNS(shibspconstants::SHIB2SPCONFIG_NS,Path);
newpath->setAttributeNS(NULL,name,namebuf);
path->setAttributeNS(NULL,name,n);
path->getParentNode()->replaceChild(newpath,path);
newpath->appendChild(path);
// Repoint our locals at the new parent.
path=newpath;
n=path->getAttributeNS(NULL,name);
}
else {
// All we had was a pathname with trailing slash(es), so just reset it without them.
path->setAttributeNS(NULL,name,namebuf);
n=path->getAttributeNS(NULL,name);
}
delete[] namebuf;
}
Override* o=new Override(path,log,this);
pair<bool,const char*> name=o->getString("name");
char* dup=strdup(name.second);
for (char* pch=dup; *pch; pch++)
*pch=tolower(*pch);
if (m_map.count(dup)) {
log.warn("Skipping duplicate Path element (%s)",dup);
free(dup);
delete o;
continue;
}
m_map[dup]=o;
free(dup);
}
}
catch (exception&) {
delete m_acl;
for_each(m_map.begin(),m_map.end(),xmltooling::cleanup_pair<string,Override>());
throw;
}
}