Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

out_marked.cc

Go to the documentation of this file.
00001 /* ===========================================================================
00002  *        Filename:  out_marked.cc
00003  *     Description:  the "marked" output format
00004  * 
00005  *         Version:  $Rev: 6 $
00006  *         Changed:  $Date: 2005-05-10 15:55:44 -0700 (Di, 10 Mai 2005) $
00007  *         Licence:  GPL (read COPYING file for details)
00008  * 
00009  *          Author:  Erich Schubert (eS), erich@debian.org
00010  *                   Institut für Informatik, LMU München
00011  * ======================================================================== */
00012 #include "config.h"
00013 #include "doc.h"
00014 #include "diff.h"
00015 #include "util.h"
00016 #include <libxml/tree.h>
00017 #include "string.h"
00018 #include "out_marked.h"
00019 
00020 /* FIXME: attributes are not being marked */
00021 
00022 using namespace SSD;
00023 namespace SSD {
00024 
00025 static void markNode(xmlNode* node, xmlChar* text, xmlNsPtr ns) {
00026         if (xmlNodeIsText(node)) {
00027                 if (node->prev) {
00028                         xmlSetNsProp(node->prev,ns,(xmlChar*)"f",text);
00029                 } else if (node->parent) {
00030                         xmlSetNsProp(node->parent,ns,(xmlChar*)"c",text);
00031                 } else {
00032                         cerr << "Textnode has neither prev sib nor parent" << endl;
00033                 };
00034         } else {
00035                 xmlSetNsProp(node,ns,(xmlChar*)"n",text);
00036         }
00037 }
00038 
00039 void MarkedWriter::run(Doc& d1, Doc& d2, DiffDijkstra& diff) {
00040         doc1 = &d1; doc2 = &d2;
00041         xmlNsPtr n1 = xmlNewNs(xmlDocGetRootElement(doc1->getDOM()),(xmlChar*)"http://xmldesign.de/XML/diff/mark/0.1",(xmlChar*)"di");
00042         xmlNsPtr n2 = xmlNewNs(xmlDocGetRootElement(doc2->getDOM()),(xmlChar*)"http://xmldesign.de/XML/diff/mark/0.1",(xmlChar*)"di");
00043         int i=0;
00044         char buffer[10];
00045         for (NodeAssignments* iter = diff.result->ass; iter; iter = iter->next) {
00046                 snprintf(buffer,10,"%d",i);
00047                 if (iter->n1 && iter->n2) {
00048                         markNode((xmlNode*)iter->n1->data,(xmlChar*)buffer,n1);
00049                         markNode((xmlNode*)iter->n2->data,(xmlChar*)buffer,n2);
00050                         i++;
00051                 } else if (iter->n1) {
00052 #ifdef MARK_DELETED
00053                         markNode((xmlNode*)iter->n1->data,(xmlChar*)"del",n1);
00054 #endif
00055                 }
00056         }
00057 }
00058 
00059 void MarkedWriter::dump() {
00060         xmlDocDump(stdout,doc1->getDOM());
00061         xmlDocDump(stdout,doc2->getDOM());
00062 }
00063 } // namespace SSD

Generated on Thu Aug 4 17:57:12 2005 for SSDDiff by  doxygen 1.4.3-20050530