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

SSD::XUpdateWriter Class Reference

XUpdate output writer class. More...

#include <out_xupdate.h>

List of all members.

Public Member Functions

void run (Doc &doc1, Doc &doc2, DiffDijkstra &diff)
 calculate the XUpdate rules needed for transformation
void dump ()
 Dump the result document.
 XUpdateWriter ()
 create the xupdate writer object
 ~XUpdateWriter ()
 delete the xupdate writer object

Public Attributes

xmlDocPtr result
 result XUpdate document

Private Member Functions

void initCloneMap (xmlNodePtr r1, xmlNodePtr r3)
 initialize clone map (the clone is where we simulate the xupdate execution)
void makePathBuf (xmlBufferPtr buf, xmlNodePtr pos)
 make a buffer to construct an xpath
xmlChar * makePath (xmlNodePtr pos)
 make an xpath to a node
void recDiff (xmlNodePtr pos1, xmlNodePtr pos2, xmlNodePtr pos3, xmlNodePtr addedpos, int descend)
 recursive diff procedure
xmlNodePtr writeStoreSubtree (int num, const xmlChar *path)
 write a store subtree statement
xmlNodePtr writeDeleteSubtree (const xmlChar *path)
 write a delete subtree statement
xmlNodePtr writeAppend (const xmlChar *path)
 write an append statement
xmlNodePtr writeInsertAfter (const xmlChar *path)
 write an insert-after statement
xmlNodePtr writeInsertBefore (const xmlChar *path)
 write an insert-before statement
xmlNodePtr writeValueOf (xmlNodePtr where, const xmlChar *path)
 write an value-of statement
xmlNodePtr writeElement (xmlNodePtr where, const xmlChar *elem)
 write an element xupdate statement
xmlNodePtr writeText (xmlNodePtr where)
 write an text xupdate statement
xmlNodePtr doInsertCmd (xmlNodePtr insertpos, int insert_mode)
 make an insert command, depending on insert_mode
void execInsert (xmlNodePtr insertpos, xmlNodePtr data, int insert_mode)
 execute an insert command, depending on insert_mode
bool tryDeleteTextNode (xmlNodePtr pos3)
 try to delete a text node out-of-sequence to avoid having to use dummy nodes
void insertDummyIfNeededForInsert (xmlNodePtr &insertpos, int &insert_mode)
 insert a dummy node if needed
void insertDummyIfNeededForDelete (xmlNodePtr deletepos, xmlNodePtr &insertpos, int &insert_mode)
 insert a dummy node if needed
void deleteDummyNodesRec (xmlNodePtr pos)
 delete all dummy nodes (internal recursive call)
void deleteDummyNodes (xmlNodePtr pos)
 delete all dummy nodes

Private Attributes

xmlNodePtr output
 pointer to the current output serialization position
xmlNsPtr ns
 XML namespace for xupdate statements.
hash_map< xmlNodePtr, xmlNodePtr,
hash< void * > > 
map
 hash_map summarizing diff result
hash_map< xmlNodePtr, int,
hash< void * > > 
map_index
 map nodes to index for move variables
int index_num
 next number to be used for a move variable
hash_map< int, xmlNodePtr,
hash< int > > 
map_move_subtrees
 storage for subtress "cut" but not yet reinserted (i.e. store variable contents)
set< xmlNodePtr > known
 to identify nodes ignored in the diff process
hash_map< xmlNodePtr, xmlNodePtr,
hash< void * > > 
map_clone
 map a node to its clone in the output
hash_map< xmlNodePtr, xmlNodePtr,
hash< void * > > 
map_clone_back
 map a cloned node back to its original node
set< xmlNodePtr > dummy_nodes
 set of dummy nodes we need to clean afterwards


Detailed Description

XUpdate output writer class.

The XUpdate output writer is by far the most complex. We're trying to make a minimal edit script to execute the changes we feel that are necessary

Definition at line 22 of file out_xupdate.h.


Constructor & Destructor Documentation

SSD::XUpdateWriter::XUpdateWriter  ) 
 

create the xupdate writer object

Definition at line 576 of file out_xupdate.cc.

References NAMESPACE_XUPDATE, ns, output, and result.

SSD::XUpdateWriter::~XUpdateWriter  ) 
 

delete the xupdate writer object

Definition at line 628 of file out_xupdate.cc.

References output, and result.


Member Function Documentation

void SSD::XUpdateWriter::deleteDummyNodes xmlNodePtr  pos  )  [private]
 

delete all dummy nodes

Parameters:
pos position to delete dummy nodes at

Definition at line 341 of file out_xupdate.cc.

References deleteDummyNodesRec(), and dummy_nodes.

Referenced by run().

Here is the call graph for this function:

void SSD::XUpdateWriter::deleteDummyNodesRec xmlNodePtr  pos  )  [private]
 

delete all dummy nodes (internal recursive call)

Parameters:
pos position to delete dummy nodes at

Definition at line 324 of file out_xupdate.cc.

References dummy_nodes, makePath(), and writeDeleteSubtree().

Referenced by deleteDummyNodes().

Here is the call graph for this function:

xmlNodePtr SSD::XUpdateWriter::doInsertCmd xmlNodePtr  insertpos,
int  insert_mode
[private]
 

make an insert command, depending on insert_mode

Parameters:
insertpos current processing position
insert_mode which type of insert statement (append, insert-before, insert-after) to do

Definition at line 190 of file out_xupdate.cc.

References INSERT_MODE_APPEND, INSERT_MODE_CHILD, INSERT_MODE_FOSIB, INSERT_MODE_PRSIB, makePath(), writeAppend(), writeInsertAfter(), and writeInsertBefore().

Referenced by insertDummyIfNeededForInsert(), and recDiff().

Here is the call graph for this function:

void SSD::XUpdateWriter::dump  ) 
 

Dump the result document.

Definition at line 624 of file out_xupdate.cc.

References result.

void SSD::XUpdateWriter::execInsert xmlNodePtr  insertpos,
xmlNodePtr  data,
int  insert_mode
[private]
 

execute an insert command, depending on insert_mode

"execute" the xupdate statement we just (should) have written

Parameters:
insertpos current processing position
data data to be inserted
insert_mode which type of insert step (append, insert-before, insert-after) to execute

Definition at line 220 of file out_xupdate.cc.

References INSERT_MODE_APPEND, INSERT_MODE_CHILD, INSERT_MODE_FOSIB, and INSERT_MODE_PRSIB.

Referenced by insertDummyIfNeededForInsert(), and recDiff().

void SSD::XUpdateWriter::initCloneMap xmlNodePtr  r1,
xmlNodePtr  r3
[private]
 

initialize clone map (the clone is where we simulate the xupdate execution)

Parameters:
r1 root of original document
r3 root of cloned document

Definition at line 95 of file out_xupdate.cc.

References map_clone, and map_clone_back.

Referenced by run().

void SSD::XUpdateWriter::insertDummyIfNeededForDelete xmlNodePtr  deletepos,
xmlNodePtr &  insertpos,
int &  insert_mode
[private]
 

insert a dummy node if needed

The insertion of dummy nodes may be necessary to prevent text node collapsing when deleting elements

Parameters:
deletepos current position we are at
insertpos insert script position we are at (correct? FIXME!)
insert_mode insertion mode we are in

Definition at line 304 of file out_xupdate.cc.

References dummy_nodes, DUMMY_TAG, makePath(), tryDeleteTextNode(), writeElement(), and writeInsertAfter().

Referenced by recDiff().

Here is the call graph for this function:

void SSD::XUpdateWriter::insertDummyIfNeededForInsert xmlNodePtr &  insertpos,
int &  insert_mode
[private]
 

insert a dummy node if needed

The insertion of dummy nodes may be necessary to prevent text node collapsing when inserting text nodes.

Parameters:
insertpos current position we are at
insert_mode insertion mode we are in

Definition at line 263 of file out_xupdate.cc.

References doInsertCmd(), dummy_nodes, DUMMY_TAG, execInsert(), INSERT_MODE_APPEND, INSERT_MODE_CHILD, INSERT_MODE_FOSIB, INSERT_MODE_PRSIB, tryDeleteTextNode(), and writeElement().

Referenced by recDiff().

Here is the call graph for this function:

xmlChar * SSD::XUpdateWriter::makePath xmlNodePtr  pos  )  [private]
 

make an xpath to a node

Parameters:
pos node the xpath should point to

Definition at line 81 of file out_xupdate.cc.

References makePathBuf(), and result.

Referenced by deleteDummyNodesRec(), doInsertCmd(), insertDummyIfNeededForDelete(), recDiff(), and tryDeleteTextNode().

Here is the call graph for this function:

void SSD::XUpdateWriter::makePathBuf xmlBufferPtr  buf,
xmlNodePtr  pos
[private]
 

make a buffer to construct an xpath

Parameters:
buf buffer to be used
pos node the xpath should point to

Definition at line 52 of file out_xupdate.cc.

Referenced by makePath().

void SSD::XUpdateWriter::recDiff xmlNodePtr  pos1,
xmlNodePtr  pos2,
xmlNodePtr  pos3,
xmlNodePtr  addedpos,
int  descend
[private]
 

recursive diff procedure

Parameters:
pos1 Position in "old" first document
pos2 Position in second ("target") document
pos3 Position in "current" document obtained by application of the xupdate rules written
addedpos Position we last added at (?? FIXME!)
descend flag if we should recursively descend further (?? FIXME! )

Definition at line 348 of file out_xupdate.cc.

References SSD::calcLIS(), doInsertCmd(), execInsert(), index_num, INSERT_MODE_CHILD, INSERT_MODE_FOSIB, insertDummyIfNeededForDelete(), insertDummyIfNeededForInsert(), known, makePath(), map, map_clone, map_index, map_move_subtrees, OUTPUT_FIRST, OUTPUT_SECOND, writeDeleteSubtree(), writeElement(), writeStoreSubtree(), writeText(), and writeValueOf().

Referenced by run().

Here is the call graph for this function:

void SSD::XUpdateWriter::run Doc doc1,
Doc doc2,
DiffDijkstra diff
 

calculate the XUpdate rules needed for transformation

Parameters:
doc1 first document
doc2 second document
diff difference search result

Definition at line 590 of file out_xupdate.cc.

References SSD::DiffDijkstraState::ass, deleteDummyNodes(), SSD::Doc::getDOM(), initCloneMap(), known, map, SSD::NodeAssignments::next, OUTPUT_BOTH, SSD::Doc::processed, recDiff(), and SSD::DiffDijkstra::result.

Here is the call graph for this function:

bool SSD::XUpdateWriter::tryDeleteTextNode xmlNodePtr  pos3  )  [private]
 

try to delete a text node out-of-sequence to avoid having to use dummy nodes

When we have a text node, an element, more text, and the element gets deleted, we need to prevent the text nodes from collapsing. Therefore we insert a dummy node there. but in the case where we're going to delete the following text node, too, we can just do that deletion first, then delete the element without a dummy.

Parameters:
pos3 check if we have to delete this text node

Definition at line 241 of file out_xupdate.cc.

References known, makePath(), map, map_clone_back, and writeDeleteSubtree().

Referenced by insertDummyIfNeededForDelete(), and insertDummyIfNeededForInsert().

Here is the call graph for this function:

xmlNodePtr SSD::XUpdateWriter::writeAppend const xmlChar *  path  )  [private]
 

write an append statement

Parameters:
path path to be used in the append command

Definition at line 137 of file out_xupdate.cc.

References ns, output, XUPDATE_APPEND, and XUPDATE_APPSEL.

Referenced by doInsertCmd().

xmlNodePtr SSD::XUpdateWriter::writeDeleteSubtree const xmlChar *  path  )  [private]
 

write a delete subtree statement

Parameters:
path path to be used in the delete command

Definition at line 129 of file out_xupdate.cc.

References ns, output, XUPDATE_REMOVE, and XUPDATE_REMSEL.

Referenced by deleteDummyNodesRec(), recDiff(), and tryDeleteTextNode().

xmlNodePtr SSD::XUpdateWriter::writeElement xmlNodePtr  where,
const xmlChar *  elem
[private]
 

write an element xupdate statement

Parameters:
where xupdate statement to be inserted into
elem element name to be used in the element command

Definition at line 169 of file out_xupdate.cc.

References ns, XUPDATE_ELEMENT, and XUPDATE_ELEMNAME.

Referenced by insertDummyIfNeededForDelete(), insertDummyIfNeededForInsert(), and recDiff().

xmlNodePtr SSD::XUpdateWriter::writeInsertAfter const xmlChar *  path  )  [private]
 

write an insert-after statement

Parameters:
path path to be used in the insert-after command

Definition at line 145 of file out_xupdate.cc.

References ns, output, XUPDATE_INSASEL, and XUPDATE_INSERTA.

Referenced by doInsertCmd(), and insertDummyIfNeededForDelete().

xmlNodePtr SSD::XUpdateWriter::writeInsertBefore const xmlChar *  path  )  [private]
 

write an insert-before statement

Parameters:
path path to be used in the insert-before command

Definition at line 153 of file out_xupdate.cc.

References ns, output, XUPDATE_INSBSEL, and XUPDATE_INSERTB.

Referenced by doInsertCmd().

xmlNodePtr SSD::XUpdateWriter::writeStoreSubtree int  num,
const xmlChar *  path
[private]
 

write a store subtree statement

Parameters:
num variable number to use
path path to be used in the store command

Definition at line 118 of file out_xupdate.cc.

References ns, output, XUPDATE_VARIABLE, XUPDATE_VARNAME, and XUPDATE_VARSEL.

Referenced by recDiff().

xmlNodePtr SSD::XUpdateWriter::writeText xmlNodePtr  where  )  [private]
 

write an text xupdate statement

Parameters:
where xupdate statement where text wrapper should be inserted

Definition at line 177 of file out_xupdate.cc.

References ns, and XUPDATE_TEXT.

Referenced by recDiff().

xmlNodePtr SSD::XUpdateWriter::writeValueOf xmlNodePtr  where,
const xmlChar *  path
[private]
 

write an value-of statement

Parameters:
where xupdate statement to be inserted into
path path (or more precisely, variable name) to be used in the value-of command

Definition at line 161 of file out_xupdate.cc.

References ns, XUPDATE_VALUE, and XUPDATE_VALUESEL.

Referenced by recDiff().


Member Data Documentation

set<xmlNodePtr> SSD::XUpdateWriter::dummy_nodes [private]
 

set of dummy nodes we need to clean afterwards

Definition at line 43 of file out_xupdate.h.

Referenced by deleteDummyNodes(), deleteDummyNodesRec(), insertDummyIfNeededForDelete(), and insertDummyIfNeededForInsert().

int SSD::XUpdateWriter::index_num [private]
 

next number to be used for a move variable

Definition at line 33 of file out_xupdate.h.

Referenced by recDiff().

set<xmlNodePtr> SSD::XUpdateWriter::known [private]
 

to identify nodes ignored in the diff process

Definition at line 37 of file out_xupdate.h.

Referenced by recDiff(), run(), and tryDeleteTextNode().

hash_map<xmlNodePtr, xmlNodePtr, hash<void*> > SSD::XUpdateWriter::map [private]
 

hash_map summarizing diff result

Definition at line 29 of file out_xupdate.h.

Referenced by recDiff(), run(), and tryDeleteTextNode().

hash_map<xmlNodePtr, xmlNodePtr, hash<void*> > SSD::XUpdateWriter::map_clone [private]
 

map a node to its clone in the output

Definition at line 39 of file out_xupdate.h.

Referenced by initCloneMap(), and recDiff().

hash_map<xmlNodePtr, xmlNodePtr, hash<void*> > SSD::XUpdateWriter::map_clone_back [private]
 

map a cloned node back to its original node

Definition at line 41 of file out_xupdate.h.

Referenced by initCloneMap(), and tryDeleteTextNode().

hash_map<xmlNodePtr, int, hash<void*> > SSD::XUpdateWriter::map_index [private]
 

map nodes to index for move variables

Definition at line 31 of file out_xupdate.h.

Referenced by recDiff().

hash_map<int, xmlNodePtr, hash<int> > SSD::XUpdateWriter::map_move_subtrees [private]
 

storage for subtress "cut" but not yet reinserted (i.e. store variable contents)

Definition at line 35 of file out_xupdate.h.

Referenced by recDiff().

xmlNsPtr SSD::XUpdateWriter::ns [private]
 

XML namespace for xupdate statements.

Definition at line 27 of file out_xupdate.h.

Referenced by writeAppend(), writeDeleteSubtree(), writeElement(), writeInsertAfter(), writeInsertBefore(), writeStoreSubtree(), writeText(), writeValueOf(), and XUpdateWriter().

xmlNodePtr SSD::XUpdateWriter::output [private]
 

pointer to the current output serialization position

Definition at line 25 of file out_xupdate.h.

Referenced by writeAppend(), writeDeleteSubtree(), writeInsertAfter(), writeInsertBefore(), writeStoreSubtree(), XUpdateWriter(), and ~XUpdateWriter().

xmlDocPtr SSD::XUpdateWriter::result
 

result XUpdate document

Definition at line 127 of file out_xupdate.h.

Referenced by dump(), makePath(), XUpdateWriter(), and ~XUpdateWriter().


The documentation for this class was generated from the following files:
Generated on Thu Aug 4 17:59:26 2005 for SSDDiff by  doxygen 1.4.3-20050530