Hets - the Heterogeneous Tool Set

Copyright(c) Simon Ulbricht, DFKI GmbH 2011
LicenseGPLv2 or higher, see LICENSE.txt
Portabilitynon-portable (DevGraph)
Safe HaskellNone



break down Common.XPath.Expr into a simpler path description and transfer into cursor movement.



data SimplePath



data Finder

Finder stores predicate list to locate the element and an index, in case multiple elements comply with the predicate


FindBy QName [Attr] Int 

exprToSimplePath :: Monad m => Change -> m SimplePath

convert PathExpr into more simple Finder stucture

mkFinder :: Monad m => Finder -> [Expr] -> m Finder

built Finder by recursively following Expr-structure and adding data to an initially empty Finder along the way

mkAttr :: Monad m => [Expr] -> m Attr

create attribute to locate the element with from expr-data. Note: this method will fail for many illegal expr-types!

data ChangeList

Describes the minimal change-effect of a .diff upon a DGraph.

data Direction

iterate Xml in multiple directions



changeXmlMod :: Monad m => Element -> Element -> m (Element, ChangeList)

apply a diff to an xml-document. returns the result xml and a list of changes that affect the original DGraph

iterateXml :: Monad m => Direction -> [SimplePath] -> Cursor -> ChangeList -> m (Cursor, ChangeList)

follow the Xml-structure and apply Changes. The Change is only applied after the recursive call to simulate parallel application. Resulting DgChanges are collected along the way.

data ChangeRes


ChangeCr Cursor 

applyChanges :: Monad m => [ChangeData] -> Cursor -> Direction -> ChangeList -> m (Cursor, ChangeList)

a list of Changes is applied to a current Cursor. The resulting DgUpdates are added to the ChangeList.

applyChange :: Monad m => ChangeRes -> ChangeData -> m ChangeRes

sequentially built up resulting Cursor one Change at a time

changeText :: Monad m => String -> Cursor -> m ChangeRes

change the text-content of an element



:: Monad m 
=> Maybe String

optional update value

-> Cursor 
-> String

attribute key

-> m ChangeRes 

change or remove one of the elements attributes

applyAddOp :: Monad m => Insert -> Cursor -> AddChange -> m Cursor

add new elements or attributes

propagatePaths :: Monad m => Cursor -> [SimplePath] -> m ([ChangeData], [SimplePath], [SimplePath])

given the remaining PathElements, determine for which Paths the current Cursor is relevant (else -> toRight) and then gather from those the changes regarding the current object (PathEnds; else -> toChildren).

updateChangeList :: Monad m => Cursor -> ChangeList -> ChangeData -> m ChangeList

determine the required DgUpdates from a Change operation. NOTE: some changes (like most attribute changes) will be ignored!

mkAddChange :: Monad m => Cursor -> ChangeList -> AddChange -> m ChangeList

split a list of AddChanges and write all Node and Link insertions into the ChangeList.

mkUpdateChange :: Monad m => NodeMod -> ChangeList -> Cursor -> m ChangeList

go upwards until an updatable element is found

mkRemoveChange :: Monad m => ChangeList -> Cursor -> m ChangeList

if node or link is removed, add this to ChangeList. otherwise create update-change