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); }
void DbXmlUpdateFactory::applyReplaceElementContent(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *target = (const DbXmlNodeImpl*)update.getTarget().get(); // TBD: this check is commented out... need to re-check why. // if (!target->isUpdateAble()) // return; // use child axis to create nodes to mark for delete DbXmlChildAxis children(0, target, 0); Item::Ptr item; while((item = children.next(context)).notNull()) { const DbXmlNodeImpl *child = (const DbXmlNodeImpl*)item-> getInterface(DbXmlNodeImpl::gDbXml); forDeletion_.insert(child); } // insert new content const XMLCh *value = update.getValue().first()->asString(context); if(value != 0 && *value != 0) { // create text node DbXmlConfiguration *conf = GET_CONFIGURATION(context); OperationContext &oc = conf->getOperationContext(); Document *document = const_cast<Document*>(target->getDocument()); Node::Ptr content = ((DbXmlFactoryImpl*)context->getItemFactory())-> createTextNode(nsNodeText, value, context); update_.insertText(*(const DbXmlNodeImpl*)content-> getInterface(DbXmlNodeImpl::gDbXml), *target, 0, *document, oc, context); } }
void XercesUpdateFactory::applyReplaceElementContent(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMElement *domnode = (DOMElement*)nodeImpl->getDOMNode(); // 1. For each node $C that is a child of $target, the parent property of $C is set to empty. DOMNode *child = domnode->getFirstChild(); while(child != 0) { forDeletion_.insert(child); child = child->getNextSibling(); } const XMLCh *value = update.getValue().first()->asString(context); if(value != 0 && *value != 0) { // 2. The parent property of $text is set to $target. // 3a. children is set to consist exclusively of $text. If $text is an empty sequence, then $target has // no children. // 3b. typed-value and string-value are set to the content property of $text. If $text is an empty sequence, // then typed-value is an empty sequence and string-value is an empty string. domnode->appendChild(domnode->getOwnerDocument()->createTextNode(value)); } // 3c. upd:removeType($target) is invoked. removeType(domnode); addToPutSet(update.getTarget(), &update, context); }
void DbXmlUpdateFactory::applyPut(const PendingUpdate &update, DynamicContext *context) { DbXmlUri uri(update.getValue().first()-> asString(context), true); if (uri.isDbXmlScheme()) { const DbXmlNodeImpl *content = (const DbXmlNodeImpl*)update.getTarget().get(); string cname = uri.getContainerName(); string docname = uri.getDocumentName(); DbXmlConfiguration *conf = GET_CONFIGURATION(context); XmlManager &mgr = conf->getManager(); XmlContainer cont = ((Manager&)mgr).getOpenContainer(cname); if (cont.isNull()) { string msg = "Target container for fn:put -- "; msg += cname; msg += " -- must be open"; throw XmlException(XmlException::INVALID_VALUE, msg); } OperationContext &oc = conf->getOperationContext(); XmlDocument doc = mgr.createDocument(); doc.setName(docname); XmlEventReader *reader = (XmlEventReader*)content->getEventReader(context); DBXML_ASSERT(reader); doc.setContentAsEventReader(*reader); XmlUpdateContext uc = mgr.createUpdateContext(); // use internal interface to avoid additional transaction int err = ((Container &)cont).addDocumentInternal(oc.txn(), doc, uc, 0); if (err != 0) throw XmlException(err); } }
void XercesUpdateFactory::applyDelete(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode()); forDeletion_.insert(domnode); addToPutSet(update.getTarget(), &update, context); }
void DbXmlUpdateFactory::applyReplaceValue(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *target = (const DbXmlNodeImpl*)update.getTarget().get(); if (!target->isUpdateAble()) return; // This is slow, but effective... // Create a new node with the replaced value and // treat this like replaceNode // This is ok because text and attribute nodes have no identity DbXmlFactoryImpl *factory = (DbXmlFactoryImpl*)context->getItemFactory(); Node::Ptr newNode; const XMLCh *value = update.getValue().first()->asString(context); switch (target->getNodeType()) { case nsNodeAttr: { newNode = factory-> createAttrNode(target->getPrefix(), target->getUri(), target->getLocalName(), value, 0, 0, // type name and URI 0, 0, NsNid(), 0, // cont, doc, nid, index context); break; } case nsNodeText: case nsNodeComment: case nsNodeCDATA: { newNode = factory-> createTextNode(target->getNodeType(), value, context); break; } case nsNodePinst: { newNode = factory-> createPINode(target->getPITarget(), value, context); break; } default: DBXML_ASSERT(false); break; } // now, replace... Sequence seq(newNode); PendingUpdate pu(PendingUpdate::REPLACE_NODE, update.getTarget(), seq, &update); if (target->getNodeType() == nsNodeAttr) applyReplaceAttribute(pu, context); else applyReplaceNode(pu, context); }
void DbXmlUpdateFactory::applyRename(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *node = (const DbXmlNodeImpl*)update.getTarget().get(); if (!node->isUpdateAble()) return; ATQNameOrDerived *qname = (ATQNameOrDerived*)update.getValue().first().get(); // Retrieve fresh node from database using RMW switch(node->getType()) { case NodeInfo::ELEMENT: { DbXmlConfiguration *conf = GET_CONFIGURATION(context); OperationContext &oc = conf->getOperationContext(); Document *document = const_cast<Document*>(node->getDocument()); DBXML_ASSERT(document); update_.renameElement(*node, qname, *document, oc, context); // Remove index entries under old name // Put prefix and URI in the dictionary // Update the prefix, URI, and name // Update NS_NAMEPREFIX, NS_HASURI flags // Add index entries for new name break; } case NodeInfo::ATTRIBUTE: { renameAttribute(update, qname, context); // Remove index entries under old name // Put prefix and URI in the dictionary // Update the prefix, URI, and name // Update NS_ATTR_PREFIX, NS_ATTR_URI flags // Add index entries for new name break; } case NodeInfo::PI: { // no indexes on PI renamePI(update, qname->getName(), context); break; } default: DBXML_ASSERT(false); break; } }
// This method has 2 functions: // 1. count number of elements in the child list // 2. ensure that text children are either comments or PI // or if text that it is all whitespace. // CDATA cannot be inserted (XQilla will not allow it). static int numElements(const PendingUpdate &update, DynamicContext *context) { int num = 0; Result children = update.getValue(); Item::Ptr item; while((item = children->next(context)).notNull()) { const DbXmlNodeImpl *child = (const DbXmlNodeImpl*)item-> getInterface(DbXmlNodeImpl::gDbXml); if (child) { switch (child->getNodeType()) { case nsNodeElement: ++num; break; case nsNodeComment: case nsNodePinst: break; // OK case nsNodeText: { XMLChToUTF8 s(child->getValue()); if (!NsUtil::isWhitespace(s.str())) { throw XmlException( XmlException::QUERY_EVALUATION_ERROR, "Cannot insert non-whitespace text node as a child of the document node"); } break; } default: DBXML_ASSERT(false); break; } } } return num; }
void DbXmlUpdateFactory::applyInsertAttributes(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *parent = (const DbXmlNodeImpl*)update.getTarget().get(); if (!parent->isUpdateAble()) return; insertAttributes(update, parent, context); }
void DbXmlUpdateFactory::applyInsertInto(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *parent = (const DbXmlNodeImpl*)update.getTarget().get(); if (!parent->isUpdateAble()) return; // 0 for next implies append applyInserts(update, parent, 0, context, false); }
void XercesUpdateFactory::applyReplaceAttribute(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMAttr *domnode = (DOMAttr*)nodeImpl->getDOMNode(); Node::Ptr parentNode = nodeImpl->dmParent(context); DOMElement *element = domnode->getOwnerElement(); DOMDocument *doc = element->getOwnerDocument(); bool untyped = parentNode->dmNodeKind() == Node::element_string && XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) && XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA); 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); // 1. Error checks: // a. If the QNames of any two attribute nodes in $replacement have implied namespace bindings that conflict with // each other, a dynamic error is raised [err:XUDY0024]. // b. If the QName of any attribute node in $replacement 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]. // Checks performed by UpdateFactory // 2b. If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked // on each element node in $replacement. if(!untyped) setTypes(newChild, childImpl->getDOMNode()); // 2a. For each node in $replacement, the parent property is set to parent($target). // 4a. If $target is an attribute node, the attributes property of parent($target) is modified by removing $target // and adding the nodes in $replacement (if any). // 4b. If $target is an attribute node, the namespaces property of parent($target) is modified to include namespace // bindings for any attribute namespace prefixes in $replacement that did not already have bindings. element->setAttributeNode((DOMAttr*)newChild); } // 3a. $target is marked for deletion. forDeletion_.insert(domnode); // 4d. upd:removeType(parent($target)) is invoked. removeType(element); // Use parentNode, since the attr replace could have removed the original attr addToPutSet(parentNode, &update, context); }
void DbXmlUpdateFactory::renamePI(const PendingUpdate &update, const XMLCh *name, DynamicContext *context) { DbXmlFactoryImpl *factory = (DbXmlFactoryImpl*)context->getItemFactory(); // create new attribute, using new name, old value Node::Ptr newNode = factory->createPINode( name, ((const DbXmlNodeImpl*)update.getTarget().get())->getValue(), context); // now, replace... Sequence seq(newNode); PendingUpdate pu(PendingUpdate::REPLACE_NODE, update.getTarget(), seq, &update); applyReplaceNode(pu, context); }
void XercesUpdateFactory::applyPut(const PendingUpdate &update, DynamicContext *context) { PutItem item(update.getValue().first()->asString(context), update.getTarget(), &update, context); std::pair<PutSet::iterator, bool> res = putSet_.insert(item); if(!res.second) { if(context->getMessageListener() != 0) { context->getMessageListener()->warning(X("In the context of this expression"), res.first->location); } XMLBuffer buf; buf.append(X("fn:put() called with the URI \"")); buf.append(item.uri); buf.append(X("\" twice. [err:XUDY0031]")); XQThrow3(ASTException, X("XercesUpdateFactory::applyPut"), buf.getRawBuffer(), &update); } }
void DbXmlUpdateFactory::applyInsertAsLast(const PendingUpdate &update, DynamicContext *context) { // NOTE: this is the same as applyInsertInto, which // is implemented as append const DbXmlNodeImpl *parent = (const DbXmlNodeImpl*)update.getTarget().get(); if (!parent->isUpdateAble()) return; // 0 for next implies append applyInserts(update, parent, 0, context, false); }
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); }
void DbXmlUpdateFactory::renameAttribute(const PendingUpdate &update, ATQNameOrDerived *qname, DynamicContext *context) { DbXmlFactoryImpl *factory = (DbXmlFactoryImpl*)context->getItemFactory(); // create new attribute, using new name, old value Node::Ptr newNode = factory->createAttrNode( (qname->getURI() ? qname->getPrefix() : 0), qname->getURI(), qname->getName(), ((const DbXmlNodeImpl*)update.getTarget().get())->getValue(), 0, 0, // type name and URI 0, 0, NsNid(), 0, // cont, doc, nid, index context); // now, replace... Sequence seq(newNode); PendingUpdate pu(PendingUpdate::REPLACE_NODE, update.getTarget(), seq, &update); applyReplaceAttribute(pu, context); }
void DbXmlUpdateFactory::applyInsertBefore(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *next = (const DbXmlNodeImpl*)update.getTarget().get(); if (!next->isUpdateAble()) return; Node::Ptr parent = next->dmParent(context); NsDomNodeRef nextRef = next->getNsDomNode(); applyInserts(update, (const DbXmlNodeImpl *)parent->getInterface(DbXmlNodeImpl::gDbXml), nextRef.get(), context, false); }
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); }
void DbXmlUpdateFactory::applyInsertAsFirst(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *parent = (const DbXmlNodeImpl*)update.getTarget().get(); if (!parent->isUpdateAble()) return; NsDomNodeRef parentRef = parent->getNsDomNode(); NsDomNodeRef nextRef = parentRef->getNsFirstChild(); if (!nextRef.get()) { DbXmlConfiguration *conf = GET_CONFIGURATION(context); parentRef->refreshNode(conf->getOperationContext(), true); nextRef = parentRef->getNsFirstChild(); } applyInserts(update, parent, nextRef.get(), context, true); }
void XercesUpdateFactory::applyInsertAttributes(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMElement *element = (DOMElement*)nodeImpl->getDOMNode(); DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(element)); bool untyped = nodeImpl->dmNodeKind() == Node::element_string && XPath2Utils::equals(nodeImpl->getTypeName(), DocumentCache::g_szUntyped) && XPath2Utils::equals(nodeImpl->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA); 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); // 1. Error checks: // a. If the QNames of any two attribute nodes in $content have implied namespace bindings that conflict with each other, // a dynamic error is raised [err:XUDY0024]. // b. If the QName of any attribute node in $content has an implied namespace binding that conflicts with a namespace // binding in the "namespaces" property of $target, a dynamic error is raised [err:XUDY0024]. // Checks performed by UpdateFactory // If the type-name property of $target is xs:untyped, then upd:setToUntyped($A) is invoked. if(!untyped) setTypes(newChild, childImpl->getDOMNode()); // The parent property of $A is set to $target. // attributes: Modified to include the nodes in $content. element->setAttributeNode((DOMAttr*)newChild); } // upd:removeType($target) is invoked. removeType(element); addToPutSet(update.getTarget(), &update, context); }
void XercesUpdateFactory::applyReplaceNode(const PendingUpdate &update, DynamicContext *context) { const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla); DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode()); 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); 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); // 1b. If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked // on each element node in $replacement. if(!untyped) setTypes(newChild, childImpl->getDOMNode()); // 1a. For each node in $replacement, the parent property is set to parent($target). // 3b. If $target is an element, text, comment, or processing instruction node, the children property // of parent($target) is modified to add the nodes in $replacement just before $target, preserving // their order. parent->insertBefore(newChild, domnode); } // 2a. $target is marked for deletion. forDeletion_.insert(domnode); // 3c. upd:removeType(parent($target)) is invoked. removeType(parent); addToPutSet(update.getTarget(), &update, context); }
void DbXmlUpdateFactory::applyReplaceNode(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *target = (const DbXmlNodeImpl*)update.getTarget().get(); if (!target->isUpdateAble()) return; Node::Ptr parent = target->dmParent(context); // insert all new nodes *before* the target, then // mark target for deletion NsDomNodeRef targetRef = target->getNsDomNode(); applyInserts(update, (const DbXmlNodeImpl *)parent->getInterface(DbXmlNodeImpl::gDbXml), targetRef.get(), context, false); forDeletion_.insert(target); }
void DbXmlUpdateFactory::applyReplaceAttribute(const PendingUpdate &update, DynamicContext *context) { // Replace via insert (at end), then mark target for removal. // This will not maintain order and results in rewriting the // parent node twice. // NOTE: this changes the index identity of the attribute (its value // in node indexes). This needs to be accounted for in reindexing const DbXmlNodeImpl *target = (const DbXmlNodeImpl*)update.getTarget().get(); if (!target->isUpdateAble()) return; Node::Ptr parent = target->dmParent(context); insertAttributes(update, (const DbXmlNodeImpl *)parent-> getInterface(DbXmlNodeImpl::gDbXml), context); forDeletion_.insert(target); }
// do the work of attribute insertion -- shared by applyInsertAttributes // and applyReplaceAttributes void DbXmlUpdateFactory::insertAttributes(const PendingUpdate &update, const DbXmlNodeImpl *parent, DynamicContext *context) { DbXmlConfiguration *conf = GET_CONFIGURATION(context); OperationContext &oc = conf->getOperationContext(); Document *document = const_cast<Document*>(parent->getDocument()); vector<const DbXmlNodeImpl *> nodeVec; Result children = update.getValue(); Item::Ptr item; while((item = children->next(context)).notNull()) { const DbXmlNodeImpl *attr = (const DbXmlNodeImpl*)item-> getInterface(DbXmlNodeImpl::gDbXml); nodeVec.push_back(attr); } update_.insertAttributes(nodeVec, *parent, *document, oc, context); }
// // "next" is NsDomNode * because the navigational methods used // to calculate it in callers are available via NsDom and not via // DbXmlNodeImpl, which uses axis iterators. They could be added // if ever deemed necessary and/or cleaner // void DbXmlUpdateFactory::applyInserts( const PendingUpdate &update, const DbXmlNodeImpl *parent, const NsDomNode *next, DynamicContext *context, bool firstOrAfter) { DbXmlConfiguration *conf = GET_CONFIGURATION(context); XmlManager &mgr = conf->getManager(); OperationContext &oc = conf->getOperationContext(); Document *document = const_cast<Document*>(parent->getDocument()); Result children = update.getValue(); Item::Ptr item; while((item = children->next(context)).notNull()) { const DbXmlNodeImpl *child = (const DbXmlNodeImpl*)item-> getInterface(DbXmlNodeImpl::gDbXml); switch(child->getNodeType()) { case nsNodeElement: { update_.insertElement(*child, *parent, next /* next */, mgr, *document, oc, context, firstOrAfter); break; } case nsNodeText: case nsNodeCDATA: case nsNodePinst: case nsNodeComment: { update_.insertText(*child, *parent, next, *document, oc, context); break; } default: throw XmlException(XmlException::INVALID_VALUE, "Cannot insert a node that is not element or text"); } } }
void DbXmlUpdateFactory::applyInsertAfter(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *prev = (const DbXmlNodeImpl*)update.getTarget().get(); if (!prev->isUpdateAble()) return; Node::Ptr parent = prev->dmParent(context); // in order to preserve order for multiple inserts, insertAfter must turn // into insertBefore NsDomNodeRef prevRef = prev->getNsDomNode(); NsDomNodeRef nextRef = prevRef->getNsNextSibling(); if (!nextRef.get()) { DbXmlConfiguration *conf = GET_CONFIGURATION(context); prevRef->refreshNode(conf->getOperationContext(), true); nextRef = prevRef->getNsNextSibling(); } applyInserts(update, (const DbXmlNodeImpl *)parent->getInterface(DbXmlNodeImpl::gDbXml), nextRef.get(), context, true); }
void DbXmlUpdateFactory::applyDelete(const PendingUpdate &update, DynamicContext *context) { const DbXmlNodeImpl *nodeImpl = (const DbXmlNodeImpl*)update.getTarget().get(); forDeletion_.insert(nodeImpl); }