コード例 #1
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
void DeltaApplyEngine::TextNode_Update( XID_t nodeXID, DOMNode *operationNode ) {
	vddprintf(("        update xid=%d\n",(int)nodeXID));
	DOMNode* upNode = xiddoc->getXidMap().getNodeWithXID( nodeXID );
	if (upNode==NULL) THROW_AWAY(("node with XID=%d not found",(int)nodeXID));
	
	DOMNodeList *opNodes = operationNode->getChildNodes();
	vddprintf(("opNodes->length() = %d\n", opNodes->getLength()));
	XyStrDeltaApply *xytext = new XyStrDeltaApply(xiddoc, upNode, 1);
	xytext->setApplyAnnotations(applyAnnotations);
	for (int i = opNodes->getLength() - 1; i >= 0; i--) {
		DOMElement *op = (DOMElement *) opNodes->item(i);
		char *optype = XMLString::transcode(op->getLocalName());
		XMLCh pos_attr[4];
		XMLCh len_attr[4];
		XMLString::transcode("pos", pos_attr, 3);
		XMLString::transcode("len", len_attr, 3);
		vddprintf(("item %d = %s\n", i, optype));
		// Replace operation
		if (strcmp(optype, "tr") == 0) {
			char *pos = XMLString::transcode(op->getAttribute(pos_attr));
			char *len = XMLString::transcode(op->getAttribute(len_attr));
			xytext->replace(atoi(pos), atoi(len), op->getTextContent());
			XMLString::release(&pos);
			XMLString::release(&len);
		}
		// Delete operation
		else if (strcmp(optype, "td") == 0) {
			char *pos = XMLString::transcode(op->getAttribute(pos_attr));
			char *len = XMLString::transcode(op->getAttribute(len_attr));
			xytext->remove(atoi(pos), atoi(len));
			XMLString::release(&pos);
			XMLString::release(&len);
		}
		// Insert operation
		else if (strcmp(optype, "ti") == 0) {
			char *pos = XMLString::transcode(op->getAttribute(pos_attr));
			xytext->insert(atoi(pos), op->getTextContent());
			XMLString::release(&pos);
		}
		XMLString::release(&optype);
	}
	xytext->complete();
	delete xytext;
}
コード例 #2
0
ファイル: xopen.c プロジェクト: jpmens/diablo
void 
ddprintf(const char *ctl, ...)
{
    va_list va;

    if (DebugOpt) {
	va_start(va, ctl);
	vddprintf(ctl, va);
	va_end(va);
    }
}
コード例 #3
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
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 );
		}
	}
コード例 #4
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
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 );
	}
コード例 #5
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
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);
	}
コード例 #6
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
DeltaApplyEngine::DeltaApplyEngine(XID_DOMDocument *sourceDoc) {
  
	if (sourceDoc    == NULL)          THROW_AWAY(("document is null"));
	xiddoc            = sourceDoc ;

	vddprintf(("creating temporary move document\n"));
	moveDocument = XID_DOMDocument::createDocument() ;
	moveDocument->initEmptyXidmapStartingAt(-1);
	XMLCh *moveRootCh = XMLString::transcode("moveRoot");
	DOMElement* moveRoot = moveDocument->createElement(moveRootCh) ;
	XMLString::release(&moveRootCh);
	moveDocument->appendChild( moveRoot );
	applyAnnotations = false;
}
コード例 #7
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
void DeltaApplyEngine::Attribute_Insert( XID_t nodeXID, const XMLCh* attr, const XMLCh* value ) {
	vddprintf(("        insert attr at xid=%d\n",(int)nodeXID));
	DOMNode* node = xiddoc->getXidMap().getNodeWithXID( nodeXID );
	if (node==NULL) THROW_AWAY(("node with XID=%d not found",(int)nodeXID));
	DOMAttr* attrNode = xiddoc->createAttribute( attr );
	attrNode->setNodeValue( value );
	DOMNamedNodeMap *attrs = node->getAttributes();
	if (attrs == NULL) {
		if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
			THROW_AWAY(("Attempted to insert an attribute on a non-element node. Perhaps xidmap was corrupted?"));
		} else {
			THROW_AWAY(("Unexpected error encountered: getAttributes() returned NULL for element"));
		}
	} else {
		attrs->setNamedItem( attrNode );
	}
	
}
コード例 #8
0
ファイル: xopen.c プロジェクト: jpmens/diablo
int
xfprintf(FILE *fo, const char *ctl, ...)
{
    va_list va;
    int r;

    if (fo == NULL) {
	logit(LOG_CRIT, "xfprintf() - fo NULL!");
	exit(1);
    }

    va_start(va, ctl);
    r = vfprintf(fo, ctl, va);
    va_end(va);
    if (DebugOpt > 2) {
	va_start(va, ctl);
	vddprintf(ctl, va);
	va_end(va);
    }
    return(r);
}
コード例 #9
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
void DeltaApplyEngine::ApplyDeltaElement(DOMNode* incDeltaElement) {
	vddprintf(("Apply delta element\n"));
	deltaElement = incDeltaElement;
	
	/* ---- Do All DELETE Operations ( including 'from' part of move ) ---- */
	
	vddprintf(("Apply Delete operations\n"));
	DOMNode* firstOp = deltaElement->getFirstChild() ;
	vddprintf(("    first sort delete operations...\n"));
	SortDeleteOperationsEngine deleteOps(xiddoc, firstOp);
	vddprintf(("    then apply all of them 1 by 1...\n"));
	while(!deleteOps.isListEmpty()) {
		DOMNode* op=deleteOps.getNextDeleteOperation();
		ApplyOperation(op);
		}

	vddprintf(("Ok, there are no more delete operations.\n"));
	
	/* ---- Do All INSERT Operations ( including 'to' part of move ) ---- */
	
	firstOp = deltaElement->getFirstChild() ;
	SortInsertOperationsEngine insertOps(xiddoc, firstOp);
	while(!insertOps.isListEmpty()) {
		DOMNode* op=insertOps.getNextInsertOperation();
		ApplyOperation(op);
		}
	
	/* ---- Do all  UPDATE  &  ATTRIBUTE  Operations ---- */

	DOMNode* child = deltaElement->getFirstChild() ;
	XMLCh iStr[100];
	XMLString::transcode("i", iStr, 99);
	XMLCh dStr[100];
	XMLString::transcode("d", dStr, 99);
	while (child != NULL) {
		if ( (!XMLString::equals(child->getLocalName(),iStr))
		
		   &&(!XMLString::equals(child->getLocalName(), dStr)) ) ApplyOperation(child);
	  child = child->getNextSibling() ;
		}
		
	/* ---- Small consistency checks ---- */

	if (moveDocument->getDocumentElement()->hasChildNodes()) THROW_AWAY(("temporary document used to move node is not empty!"));

	vddprintf(("xiddoc=%s\n",xiddoc->getXidMap().String().c_str() ));
}
コード例 #10
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
void DeltaApplyEngine::Subtree_Insert( DOMNode *insertSubtreeRoot, XID_t parentXID, int position, const char *xidmapStr ) {

	vddprintf(( "        insert xidmap=%s at (parent=%d, pos=%d)\n", xidmapStr, (int)parentXID, position));
	DOMNode* contentNode  = xiddoc->importNode( insertSubtreeRoot, true );
	DOMNode* parentNode   = xiddoc->getXidMap().getNodeWithXID( parentXID );
	if (parentNode==NULL) THROW_AWAY(("parent node with XID=%d not found",(int)parentXID));

	int actual_pos = 1 ;
	if ((position!=1)&&(!parentNode->hasChildNodes())) THROW_AWAY(("parent has no children but position is %d",position));
	DOMNode* brother = parentNode->getFirstChild();
	while (actual_pos < position) {
	  brother = brother->getNextSibling();
		actual_pos++;
		if ((brother==NULL)&&(actual_pos<position)) THROW_AWAY(("parent has %d children but position is %d",actual_pos-1, position));
		}
	
	// Add node to the tree
	if (brother==NULL) parentNode->appendChild( contentNode );
	else parentNode->insertBefore( contentNode, brother );
	
	xiddoc->getXidMap().mapSubtree( xidmapStr, contentNode );

	}
コード例 #11
0
ファイル: DeltaReverse.cpp プロジェクト: alon/xydiff
DOMNode* DeltaReverse( DOMNode *deltaElement, DOMDocument *reversedDoc ) {
	
	vddprintf(("    reversing time-version header\n"));

	DOMNode* reversedElement = reversedDoc->importNode( deltaElement, false );

	//DOMString from = deltaElement.getAttributes().getNamedItem("from").getNodeValue() ;
        //DOMString to   = deltaElement.getAttributes().getNamedItem("to"  ).getNodeValue() ;
        const XMLCh* from = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("from"))->getNodeValue() ;
        const XMLCh* to = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("to"))->getNodeValue() ;
        
	reversedElement->getAttributes()->getNamedItem(XMLString::transcode("to"))->setNodeValue( from );
	reversedElement->getAttributes()->getNamedItem(XMLString::transcode("from"))->setNodeValue( to );

	DOMNode* fromXidMap = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("fromXidMap"));
	DOMNode* toXidMap   = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("toXidMap"));
	if (fromXidMap!=NULL) {
          //DOMString from = fromXidMap.getNodeValue();
		reversedElement->getAttributes()->getNamedItem(XMLString::transcode("toXidMap"))->setNodeValue( fromXidMap->getNodeValue() );
	}
	if (toXidMap!=NULL) {
          //DOMString to = toXidMap.getNodeValue();
		reversedElement->getAttributes()->getNamedItem(XMLString::transcode("fromXidMap"))->setNodeValue( toXidMap->getNodeValue() );
	}

	// No chanhges in the delta -> ok
	if (!deltaElement->hasChildNodes()) return( reversedElement );
	
	// Input : read Elementary Operation
	DOMNode* child = deltaElement->getFirstChild() ;
	
	// Output : precedent will be used to write Elementary Operation in reverse order
	DOMNode* precedent = NULL; // =NULL by default

	while (child != NULL) {
		if (child->getNodeType()!=DOMNode::ELEMENT_NODE) THROW_AWAY(("Bad type (%d) for Delta Operation Node", (int)child->getNodeType()));
		DOMElement* operationNode = (DOMElement*) child ;
		XyLatinStr operation(child->getLocalName());
		
		// Reverse DELETE into INSERT
		
		if (strcmp(operation, "d")==0) {
			vddprintf(("    reversing delete into insert\n"));
			DOMElement* iElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:i")) ;
			CopyAttr(iElement, operationNode, XMLString::transcode("par"), true);
			CopyAttr(iElement, operationNode, XMLString::transcode("pos"), true);
			CopyAttr(iElement, operationNode, XMLString::transcode("xm"), true);
			CopyAttr(iElement, operationNode, XMLString::transcode("move"), false);
			CopyAttr(iElement, operationNode, XMLString::transcode("update"), false);
			CopyContent(iElement, operationNode);
			reversedElement->insertBefore( iElement, precedent ) ;
			precedent = iElement ;
			}

		// Reverse INSERT into DELETE
		
		else if (strcmp(operation, "i")==0) {
	    		vddprintf(("    reversing insert into delete\n")); 
			DOMElement *iElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:d")) ;
			CopyAttr(iElement, operationNode, XMLString::transcode("par"), true);
			CopyAttr(iElement, operationNode, XMLString::transcode("pos"), true);
			CopyAttr(iElement, operationNode, XMLString::transcode("xm"), true);
			CopyAttr(iElement, operationNode, XMLString::transcode("move"), false);
			CopyAttr(iElement, operationNode, XMLString::transcode("update"), false);
			CopyContent(iElement, operationNode);
			reversedElement->insertBefore( iElement, precedent ) ;
			precedent = iElement ;
		  }
	// Attribute Update
		else if (strcmp(operation, "au")==0) {
			vddprintf(("    reversing attribute update\n"));
			
			//DOMString xidElem  = operationNode.getAttributes().getNamedItem("xid").getNodeValue();
			//DOMString attrName = operationNode.getAttributes().getNamedItem("a").getNodeValue();
			//DOMString oldValue = operationNode.getAttributes().getNamedItem("ov").getNodeValue();
			//DOMString newValue = operationNode.getAttributes().getNamedItem("nv").getNodeValue();
			const XMLCh* xidElem = operationNode->getAttributes()->getNamedItem(XMLString::transcode("xid"))->getNodeValue();
                        const XMLCh* attrName = operationNode->getAttributes()->getNamedItem(XMLString::transcode("a"))->getNodeValue();
                        const XMLCh* oldValue = operationNode->getAttributes()->getNamedItem(XMLString::transcode("ov"))->getNodeValue();
                        const XMLCh* newValue = operationNode->getAttributes()->getNamedItem(XMLString::transcode("nv"))->getNodeValue();
                        

			DOMElement* auElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:au"));
			auElement->setAttribute(XMLString::transcode("xid"), xidElem);
			auElement->setAttribute(XMLString::transcode("a"),   attrName);
			auElement->setAttribute(XMLString::transcode("nv"),  oldValue);
			auElement->setAttribute(XMLString::transcode("ov"),  newValue);
			
			reversedElement->insertBefore(auElement, precedent);
			precedent = auElement ;
		}
	// Attribute Delete
		else if (strcmp(operation, "ad")==0) {
			vddprintf(("    reversing attribute insert into attribute delete\n"));

			//DOMString xidElem  = operationNode.getAttributes().getNamedItem("xid").getNodeValue();
			//DOMString attrName = operationNode.getAttributes().getNamedItem("a").getNodeValue();
			//DOMString attrVal  = operationNode.getAttributes().getNamedItem("v").getNodeValue();
			const XMLCh* xidElem  = operationNode->getAttributes()->getNamedItem(XMLString::transcode("xid"))->getNodeValue();
			const XMLCh* attrName = operationNode->getAttributes()->getNamedItem(XMLString::transcode("a"))->getNodeValue();
			const XMLCh* attrVal  = operationNode->getAttributes()->getNamedItem(XMLString::transcode("v"))->getNodeValue();
			
			DOMElement* aiElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:ai"));
			aiElement->setAttribute(XMLString::transcode("xid"), xidElem);
			aiElement->setAttribute(XMLString::transcode("a"), attrName);
			aiElement->setAttribute(XMLString::transcode("v"), attrVal);
			
			reversedElement->insertBefore(aiElement, precedent);
			precedent = aiElement ;
		}
	// Attribute Insert
		else if (strcmp(operation, "ai")==0) {
			vddprintf(("    reversing attribute delete into attribute insert\n"));

			//DOMString xidElem  = operationNode.getAttributes().getNamedItem("xid").getNodeValue();
			//DOMString attrName = operationNode.getAttributes().getNamedItem("a").getNodeValue();
			//DOMString attrVal  = operationNode.getAttributes().getNamedItem("v").getNodeValue();
                        const XMLCh* xidElem  = operationNode->getAttributes()->getNamedItem(XMLString::transcode("xid"))->getNodeValue();
			const XMLCh* attrName = operationNode->getAttributes()->getNamedItem(XMLString::transcode("a"))->getNodeValue();
			const XMLCh* attrVal  = operationNode->getAttributes()->getNamedItem(XMLString::transcode("v"))->getNodeValue();
			
			DOMElement* adElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:ad"));
			adElement->setAttribute(XMLString::transcode("xid"), xidElem);
			adElement->setAttribute(XMLString::transcode("a"), attrName);
			adElement->setAttribute(XMLString::transcode("v"), attrVal);
			
			reversedElement->insertBefore(adElement, precedent);
			precedent = adElement ;
		}
		
    // Reverse UPDATE to UPDATE
		
		else if (strcmp(operation, "u")==0) {
			vddprintf(("    reversing update\n"));
		  
			DOMNode* oldValue = child->getFirstChild() ;
			if ( oldValue==NULL ) throw ReverseUpdateException("<update> has no child!");
			
			DOMNode* newValue = oldValue->getNextSibling() ;
			if ( newValue==NULL ) throw ReverseUpdateException("<update> has only one child!");
			
			//DOMString xid= child.getAttributes().getNamedItem("xid").getNodeValue() ;
                        const XMLCh* xid= child->getAttributes()->getNamedItem(XMLString::transcode("xid"))->getNodeValue() ;
			
			DOMElement *uElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:u")) ;
			uElement->setAttribute(XMLString::transcode("xid"), xid);
			
			DOMElement* uOld = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:ov"));
			DOMNode* uOldText = reversedDoc->importNode( newValue->getFirstChild(), true );
			uOld->appendChild( uOldText );
			
			DOMElement* uNew = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:nv"));
			DOMNode* uNewText = reversedDoc->importNode( oldValue->getFirstChild(), true );
			uNew->appendChild( uNewText );
			
			uElement->appendChild( uOld ) ;
			uElement->appendChild( uNew ) ;
			
		  reversedElement->insertBefore( uElement, precedent ) ;
			precedent = uElement ;
			}
		else if (strcmp(operation, "renameRoot")==0) {
			vddprintf(("    reversing renameRoot operation\n"));

			const XMLCh* rFrom = operationNode->getAttributes()->getNamedItem(XMLString::transcode("from"))->getNodeValue();
			const XMLCh* rTo   = operationNode->getAttributes()->getNamedItem(XMLString::transcode("to"))->getNodeValue();
			
			DOMElement *rrElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:renameRoot"));
			rrElement->setAttribute(XMLString::transcode("from"), rTo);
			rrElement->setAttribute(XMLString::transcode("to"), rFrom);
			
			reversedElement->insertBefore(rrElement, precedent);
			precedent = rrElement ;			
		}
		
		else {
			throw DeltaReverseException("Invalid Data", "main", "Unknown operation <" + std::string(operation) + ">")  ;
		}
				
		child = child->getNextSibling();
		}
	
	return ( reversedElement ) ;
	}
コード例 #12
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
void DeltaApplyEngine::ApplyOperation(DOMNode *operationNode) {
	 
	vddprintf(("ApplyOperation\n"));
	XMLCh dStr[2];
	XMLCh iStr[2];
	XMLCh uStr[2];
	XMLCh adStr[3];
	XMLCh aiStr[3];
	XMLCh auStr[3];
	XMLCh renameRootStr[11];
	XMLString::transcode("d", dStr, 1);
	XMLString::transcode("i", iStr, 1);
	XMLString::transcode("u", uStr, 1);
	XMLString::transcode("ad", adStr, 2);
	XMLString::transcode("ai", aiStr, 2);
	XMLString::transcode("au", auStr, 2);
	XMLString::transcode("renameRoot", renameRootStr, 10);
	XMLCh tempStr[6];
	if (XMLString::equals(operationNode->getLocalName(), dStr)) {
		vddprintf(("        d(elete)\n"));
		
		bool move = false ;
		XMLString::transcode("move", tempStr, 5);
		DOMNode* moveAttr = operationNode->getAttributes()->getNamedItem(tempStr) ;
		XMLString::transcode("yes", tempStr, 5);
		if ((moveAttr!=NULL) && (XMLString::equals(moveAttr->getNodeValue(),tempStr))) {
			move = true;
		}

		XMLString::transcode("xm", tempStr, 5);
		char *xidmapStr = XMLString::transcode(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());		
		if (move) {
			XidMap_Parser parse(xidmapStr) ;
			XID_t myXid = parse.getRootXID();
			Subtree_MoveFrom( myXid );
		  }
		else {
			Subtree_Delete(xidmapStr) ;
		}
		XMLString::release(&xidmapStr);
	}

	else if (XMLString::equals(operationNode->getLocalName(),iStr)) {
		vddprintf(("        i(nsert)\n"));

		bool move = false ;
		XMLString::transcode("move", tempStr, 5);
		DOMNode* moveAttr = operationNode->getAttributes()->getNamedItem(tempStr) ;
		XMLString::transcode("yes", tempStr, 5);
		if ( (moveAttr!=NULL) && (XMLString::equals( moveAttr->getNodeValue(), tempStr ))) {
			move = true;
		}
		XMLString::transcode("pos", tempStr, 5);
		DOMNode *n = operationNode->getAttributes()->getNamedItem(tempStr);
		int position = XyInt(n->getNodeValue());

		XMLString::transcode("par", tempStr, 5);
		n = operationNode->getAttributes()->getNamedItem(tempStr);
		XID_t parentXID = (XID_t)(int)XyInt(n->getNodeValue());

		XMLString::transcode("xm", tempStr, 5);
		char *xidmapStr = XMLString::transcode(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());
		if (move) {
			XidMap_Parser parse(xidmapStr) ;
			XID_t myXid = parse.getRootXID();

			Subtree_MoveTo( myXid, parentXID, position );
		}
		else {
			DOMNode* insertRoot ;
			// get data to insert
			if (operationNode->hasChildNodes()) insertRoot = operationNode->getFirstChild() ;
			else THROW_AWAY(("insert operator element contains no data"));
				
			Subtree_Insert( insertRoot, parentXID, position, xidmapStr ) ;
		}
		XMLString::release(&xidmapStr);
	}

	else if (XMLString::equals(operationNode->getLocalName(), uStr)) {
		vddprintf(("        u(pdate)\n"));
		XMLString::transcode("oldxm", tempStr, 5);
		char *xidmapStr = XMLString::transcode(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());
		XidMap_Parser parse(xidmapStr) ;
		XID_t nodeXID = parse.getRootXID();
		TextNode_Update( nodeXID, operationNode);
		XMLString::release(&xidmapStr);
		}

	else if (XMLString::equals(operationNode->getLocalName(), adStr)) {
		vddprintf(("        a(ttribute) d(elete)\n"));
		XMLString::transcode("xid", tempStr, 5);
		XID_t nodeXID = (XID_t)(int)XyInt(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());

		XMLString::transcode("a", tempStr, 5);
        const XMLCh* attr = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
		Attribute_Delete( nodeXID, attr );
		}
	else if (XMLString::equals(operationNode->getLocalName(), aiStr)) {
		vddprintf(("        a(ttribute) i(nsert)\n"));
		XMLString::transcode("xid", tempStr, 5);
		XID_t nodeXID = (XID_t)(int)XyInt(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());
		XMLString::transcode("a", tempStr, 5);
        const XMLCh* attr = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
		XMLString::transcode("v", tempStr, 5);
        const XMLCh* value = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
		Attribute_Insert( nodeXID, attr, value );
		}
	else if (XMLString::equals(operationNode->getLocalName(), auStr)) {
		vddprintf(("        a(ttribute) u(pdate)\n"));
		XMLString::transcode("xid", tempStr, 5);
		XID_t nodeXID = (XID_t)(int)XyInt(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());
		XMLString::transcode("a", tempStr, 5);
        const XMLCh* attr = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
		XMLString::transcode("nv", tempStr, 5);
        const XMLCh* value = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
		Attribute_Update( nodeXID, attr, value );
		}
	else if (XMLString::equals(operationNode->getLocalName(), renameRootStr)) {
		vddprintf(("        renameRoot\n"));
		DOMNode *root = xiddoc->getDocumentElement();
		XID_t rootXID = xiddoc->getXidMap().getXIDbyNode(root);
		XMLString::transcode("to", tempStr, 5);
        const XMLCh* newrootName = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
		DOMElement* newroot = xiddoc->createElement(newrootName);

		DOMNode* child = root->getFirstChild();
		while(child!=NULL) {
			root->removeChild(child);
			newroot->appendChild(child);
			child = root->getFirstChild();
		}
		DOMNamedNodeMap *attributes = root->getAttributes();
		for(unsigned int i=0;i<attributes->getLength();i++) {
			DOMNode *an = attributes->item(i);
			newroot->setAttribute(an->getNodeName(), an->getNodeValue());
		}
		xiddoc->removeChild(root);
		xiddoc->getXidMap().removeNode(root);
		root->release();
		xiddoc->appendChild(newroot);
		xiddoc->getXidMap().registerNode(newroot, rootXID);
		xiddoc->getXidMap().SetRootElement(newroot);
		}
	}
コード例 #13
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
void DeltaApplyEngine::Attribute_Delete( XID_t nodeXID, const XMLCh* attr ) {
	vddprintf(("        delete attr at xid=%d\n",(int)nodeXID));
	DOMNode* node = xiddoc->getXidMap().getNodeWithXID( nodeXID );
	if (node==NULL) THROW_AWAY(("node with XID=%d not found",(int)nodeXID));
	node = node->getAttributes()->removeNamedItem( attr );
	}
コード例 #14
0
ファイル: DeltaApply.cpp プロジェクト: alon/xydiff
void DeltaApplyEngine::Attribute_Update( XID_t nodeXID, const XMLCh* attr, const XMLCh* value ) {
	vddprintf(("        update attr at xid=%d\n",(int)nodeXID));
	DOMNode* node = xiddoc->getXidMap().getNodeWithXID( nodeXID );
	if (node==NULL) THROW_AWAY(("node with XID=%d not found",(int)nodeXID));
	node->getAttributes()->getNamedItem( attr )->setNodeValue( value );
	}