本文整理汇总了C++中DOMNode::getParentNode方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMNode::getParentNode方法的具体用法?C++ DOMNode::getParentNode怎么用?C++ DOMNode::getParentNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::getParentNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeType
void XercesUpdateFactory::removeType(DOMNode *node)
{
DOMNode *ancestor = node;
// 1. If $N is an element node, its properties are changed as follows:
if(node->getNodeType() == DOMNode::ELEMENT_NODE) {
// a. If type-name is not equal to xs:untyped, then
const XMLCh *typeURI, *typeName;
XercesNodeImpl::typeUriAndName(node, typeURI, typeName);
if(!XPath2Utils::equals(typeName, DocumentCache::g_szUntyped) ||
!XPath2Utils::equals(typeURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)) {
// i. type-name is set to xs:anyType
XercesSequenceBuilder::setElementTypeInfo((DOMElement *)node, SchemaSymbols::fgURI_SCHEMAFORSCHEMA,
SchemaSymbols::fgATTVAL_ANYTYPE);
// ii. If the parent of N is an element node, then upd:removeType(parent($N)) is invoked.
DOMNode *parent = node->getParentNode();
if(parent && parent->getNodeType() == DOMNode::ELEMENT_NODE)
removeType(parent);
}
// b. string-value is set equal to the concatenated contents of the text node descendants, in document order.
// c. typed-value is set equal to the string-value property, as an instance of xs:untypedAtomic.
// d. nilled, is-id, and is-idrefs are set to false.
// Automatically done by changing the type
}
// 2. If $N is an attribute node, its properties are changed as follows:
else if(node->getNodeType() == DOMNode::ATTRIBUTE_NODE) {
// a. type-name is set to xs:untypedAtomic.
XercesSequenceBuilder::setAttributeTypeInfo((DOMAttr *)node, SchemaSymbols::fgURI_SCHEMAFORSCHEMA,
ATUntypedAtomic::fgDT_UNTYPEDATOMIC);
// b. typed-value is set equal to the string-value property, as an instance of xs:untypedAtomic.
// c. is-id and is-idrefs are set to false.
// Automatically done by changing the type
// d. If $N has a parent, upd:removeType(parent($N)) is invoked.
ancestor = ((DOMAttr*)node)->getOwnerElement();
if(ancestor) removeType(ancestor);
}
else return;
// 3. The topmost ancestor of $N is marked for revalidation.
if(ancestor) {
while(ancestor->getParentNode() != 0)
ancestor = ancestor->getParentNode();
forRevalidation_.insert(ancestor);
}
}
示例2: applyRename
void XercesUpdateFactory::applyRename(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode());
ATQNameOrDerived *qname = (ATQNameOrDerived*)update.getValue().first().get();
if(domnode->getNodeType() == DOMNode::PROCESSING_INSTRUCTION_NODE) {
DOMProcessingInstruction *newPI = domnode->getOwnerDocument()->
createProcessingInstruction(qname->getName(), domnode->getNodeValue());
domnode->getParentNode()->replaceChild(newPI, domnode);
domnode = newPI;
}
else {
// If $newName has an implied namespace binding that conflicts with an existing namespace binding
// in the namespaces property of $target, a dynamic error is raised [err:XUDY0024].
// If $target has a parent, and $newName has an implied namespace binding that conflicts with a
// namespace binding in the namespaces property of parent($target), a dynamic error is raised [err:XUDY0024].
domnode->getOwnerDocument()->renameNode(domnode, qname->getURI(), qname->getName());
if(qname->getURI() != 0 && *qname->getURI() != 0)
domnode->setPrefix(qname->getPrefix());
removeType(domnode);
}
// Deliberately create a new XercesNodeImpl, since the PI is actually
// replaced, not just renamed, meaning it is no longer attached to the tree
addToPutSet(nodeImpl, &update, context);
}
示例3: completeDeletions
void XercesUpdateFactory::completeDeletions(DynamicContext *context)
{
// e. Finally, for each node marked for deletion by one of the update primitives listed above, let $N be the node that is marked
// for deletion, and let $P be its parent node. The following actions are applied:
// i. The parent property of $N is set to empty.
// ii. If $N is an attribute node, the attributes property of $P is modified to remove $N.
// iii. If $N is a non-attribute node, the children property of $P is modified to remove $N.
// iv. If $N is an element, attribute, or text node, and $P is an element node, then upd:removeType($P) is invoked.
for(DOMNodeSet::iterator i = forDeletion_.begin(); i != forDeletion_.end(); ++i) {
DOMNode *domnode = *i;
if(domnode->getNodeType() == DOMNode::ATTRIBUTE_NODE) {
DOMAttr *attr = (DOMAttr*)domnode;
DOMElement *owner = attr->getOwnerElement();
if(owner != 0) {
owner->removeAttributeNode(attr);
removeType(owner);
}
}
else {
DOMNode *parent = domnode->getParentNode();
if(parent != 0) {
parent->removeChild(domnode);
if(domnode->getNodeType() == DOMNode::ELEMENT_NODE ||
domnode->getNodeType() == DOMNode::TEXT_NODE ||
domnode->getNodeType() == DOMNode::CDATA_SECTION_NODE) {
removeType(parent);
}
}
}
}
}
示例4: checkNodeInInput
bool TXFMXPathFilter::checkNodeInInput(DOMNode * n, DOMNode * attParent) {
if (mp_fragment != NULL) {
DOMNode * p = n;
/* Check attParent here to reduce cycles */
if (attParent != NULL) {
if (p == mp_fragment)
return true;
p = attParent;
}
while (p != NULL) {
if (p == mp_fragment)
return true;
p = p->getParentNode();
}
return false;
}
return mp_inputList->hasNode(n);
}
示例5: castToNode
const XMLCh* DOMNodeImpl::getBaseURI() const{
DOMNode *thisNode = castToNode(this);
DOMNode* parent = thisNode->getParentNode();
if (parent)
return parent->getBaseURI();
else
return 0;
}
示例6: matchNodeOrParent
/** Return node, if matches or any parent if matches. */
DOMNode* DOMNodeIteratorImpl::matchNodeOrParent (DOMNode* node) {
for (DOMNode* n = fCurrentNode; n != fRoot; n = n->getParentNode()) {
if (node == n) return n;
}
return 0;
}
示例7: fieldName
//Detect field name of value element
static char* fieldName(DOMElement* elem) {
DOMNode *node = elem;
if (getGeometryTypeOfElem(elem))
{
int depth = 0; // Depth of value elem node
for (node = elem; node; node = node->getParentNode()) ++depth;
//Field name is on level 4
node = elem;
for (int d = 0; d<depth-4; ++d) node = node->getParentNode();
}
if( node == NULL )
{
CPLError(CE_Failure, CPLE_AssertionFailed, "node == NULL");
return CPLStrdup("***bug***");
}
char* pszNodeName = tr_strdup(node->getNodeName());
return pszNodeName;
}
示例8: getElementAncestor
DOMNode* DOMNodeImpl::getElementAncestor (const DOMNode* currentNode) const {
DOMNode* parent = currentNode->getParentNode();
while(parent != 0) {
short type = parent->getNodeType();
if (type == DOMNode::ELEMENT_NODE) {
return parent;
}
parent=parent->getParentNode();
}
return 0;
}
示例9: Subtree_Delete
void DeltaApplyEngine::Subtree_Delete( const char *xidmapStr ) {
XidMap_Parser parse(xidmapStr) ;
// Note here that the PostFix order for XID-map is important to garantuee that nodes will be deleted in the correct order
while (!parse.isListEmpty()) {
XID_t deleteXID = parse.getNextXID();
vddprintf(( " delete node xid=%d\n", (int) deleteXID ));
DOMNode* deleteNode = xiddoc->getXidMap().getNodeWithXID( deleteXID );
if (deleteNode==NULL) THROW_AWAY(("node with XID=%d not found",(int)deleteXID));
xiddoc->getXidMap().removeNode( deleteNode );
deleteNode = deleteNode->getParentNode()->removeChild( deleteNode );
}
}
示例10: Subtree_MoveFrom
void DeltaApplyEngine::Subtree_MoveFrom( XID_t myXID ) {
vddprintf((" move (from) node xid=%d\n", (int) myXID ));
DOMNode* moveNode = xiddoc->getXidMap().getNodeWithXID( myXID );
if (moveNode==NULL) THROW_AWAY(("node with XID=%d not found",(int)myXID));
DOMNode* backupNode = moveDocument->importNode( moveNode, true );
moveDocument->getXidMap().mapSubtree( xiddoc->getXidMap().String(moveNode).c_str() , backupNode );
moveDocument->getDocumentElement()->appendChild( backupNode );
moveNode = moveNode->getParentNode()->removeChild( moveNode );
xiddoc->getXidMap().removeSubtree( moveNode );
}
示例11: fieldName
char* fieldName(DOMElement* elem) {
string fullname;
int depth = 0;
DOMNode *node;
for (node = elem; node; node = node->getParentNode()) ++depth;
depth-=3; //ignore root elements
// We cannot do this sort of dynamic stack alloc on MSVC6.
// DOMNode* elements[depth];
DOMNode* elements[1000];
CPLAssert( depth < (int)(sizeof(elements) / sizeof(DOMNode*)) );
int d=0;
for (node = elem; d<depth; node = node->getParentNode()) elements[d++] = node;
for (d=depth-1; d>=0; --d) {
if (d < depth-1) fullname += "_";
char* pszNodeName = XMLString::transcode(elements[d]->getNodeName());
fullname += pszNodeName;
XMLString::release(&pszNodeName);
}
return CPLStrdup(fullname.c_str());
}
示例12: Subtree_MoveTo
void DeltaApplyEngine::Subtree_MoveTo( XID_t myXID, XID_t parentXID, int position ) {
vddprintf((" move subtree rooted by %d to (parent=%d, pos=%d)\n", (int)myXID, (int)parentXID, position));
DOMNode* moveRoot = NULL;
try {
moveRoot = moveDocument->getXidMap().getNodeWithXID( myXID ) ;
} catch (...) {
return;
}
if (moveRoot==NULL) return; //THROW_AWAY(("node with XID=%d not found",(int)myXID));
Subtree_Insert(moveRoot, parentXID, position, moveDocument->getXidMap().String(moveRoot).c_str() );
(void)moveRoot->getParentNode()->removeChild(moveRoot);
}
示例13: applyReplaceValue
void XercesUpdateFactory::applyReplaceValue(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode());
// 2. If $target is a text, comment, or processing instruction node: content of $target is set to $string-value.
domnode->setNodeValue(update.getValue().first()->asString(context));
if(domnode->getNodeType() == DOMNode::ATTRIBUTE_NODE) {
// 1. If $target is an attribute node:
// a. string-value of $target is set to $string-value. (done above)
// b. upd:removeType($target) is invoked.
removeType(domnode);
}
else if(domnode->getNodeType() == DOMNode::TEXT_NODE ||
domnode->getNodeType() == DOMNode::CDATA_SECTION_NODE) {
// 3. If $target is a text node, upd:removeType(parent($target)) is invoked.
if(domnode->getParentNode() != 0)
removeType(domnode->getParentNode());
}
addToPutSet(update.getTarget(), &update, context);
}
示例14: getPreviousLogicalSibling
// Returns the previous logical sibling with respect to the given node.
DOMNode* DOMElementImpl::getPreviousLogicalSibling(const DOMNode* n) const
{
DOMNode* prev = n->getPreviousSibling();
// If "n" has no previous sibling and its parent is an entity reference node we
// need to continue the search through the previous siblings of the entity
// reference as these are logically siblings of the given node.
if (prev == NULL) {
DOMNode* parent = n->getParentNode();
while (parent != NULL && parent->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE) {
prev = parent->getPreviousSibling();
if (prev != NULL) {
break;
}
parent = parent->getParentNode();
}
}
return prev;
}
示例15: applyInsertAfter
void XercesUpdateFactory::applyInsertAfter(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode());
DOMNode *before = domnode->getNextSibling();
Node::Ptr parentNode = nodeImpl->dmParent(context);
DOMNode *parent = domnode->getParentNode();
DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(domnode));
bool untyped = parentNode->dmNodeKind() == Node::element_string &&
XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) &&
XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
bool containsElementOrText = false;
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);
if(childImpl->dmNodeKind() == Node::element_string ||
childImpl->dmNodeKind() == Node::text_string) {
containsElementOrText = true;
}
// If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked on each
// element or attribute node in $content.
if(!untyped) setTypes(newChild, childImpl->getDOMNode());
// For each node in $content, the parent property is set to parent($target).
// The children property of parent($target) is modified to add the nodes in $content just before $target,
// preserving their order.
parent->insertBefore(newChild, before);
}
// If at least one of the nodes in $content is an element or text node, upd:removeType(parent($target)) is invoked.
if(containsElementOrText) {
removeType(parent);
}
addToPutSet(update.getTarget(), &update, context);
}