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;
	}
}
Example #2
0
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);
}