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); }
static DOMNode *importNodeFix(DOMDocument *doc, DOMNode *node, bool deep) { DOMNode *newNode = doc->importNode(node, deep); // Xerces-C has a bug that doesn't copy the prefix correctly - jpcs if((node->getNodeType() == DOMNode::ELEMENT_NODE || node->getNodeType() == DOMNode::ATTRIBUTE_NODE) && node->getNamespaceURI() != 0 && *node->getNamespaceURI() != 0 && node->getPrefix() != 0 && *node->getPrefix() != 0) newNode->setPrefix(node->getPrefix()); return newNode; }