testxmldiff.hs revision 4620e43bc9fa96506bd78ed6b3e5318b08de5996
2d2eda71267231c2526be701fe655db125852c1ffielding{- |
2d2eda71267231c2526be701fe655db125852c1ffieldingModule : $Header$
2d2eda71267231c2526be701fe655db125852c1ffieldingDescription : test xmldiff
2d2eda71267231c2526be701fe655db125852c1ffieldingCopyright : (c) C. Maeder, DFKI GmbH 2011
2d2eda71267231c2526be701fe655db125852c1ffieldingLicense : GPLv2 or higher, see LICENSE.txt
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffieldingMaintainer : Christian.Maeder@dfki.de
2d2eda71267231c2526be701fe655db125852c1ffieldingStability : experimental
2d2eda71267231c2526be701fe655db125852c1ffieldingPortability : portable
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffielding-}
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffieldingmodule Main (main) where
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffieldingimport Text.XML.Light
2d2eda71267231c2526be701fe655db125852c1ffieldingimport Common.XmlDiff
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffieldingimport Control.Monad
2d2eda71267231c2526be701fe655db125852c1ffieldingimport qualified Data.Set as Set
2d2eda71267231c2526be701fe655db125852c1ffieldingimport qualified Data.Map as Map
2d2eda71267231c2526be701fe655db125852c1ffieldingimport System.Environment
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffieldinghetsTags :: UnordTags
2d2eda71267231c2526be701fe655db125852c1ffieldinghetsTags = Map.fromList
2d2eda71267231c2526be701fe655db125852c1ffielding $ map (\ (e, as) -> (unqual e, Set.fromList $ map unqual as))
2d2eda71267231c2526be701fe655db125852c1ffielding [ ("DGNode", ["name"])
2d2eda71267231c2526be701fe655db125852c1ffielding , ("DGLink", ["linkid", "source", "target"]) ]
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffieldingmain :: IO ()
2d2eda71267231c2526be701fe655db125852c1ffieldingmain = do
2d2eda71267231c2526be701fe655db125852c1ffielding args <- getArgs
2d2eda71267231c2526be701fe655db125852c1ffielding case args of
2d2eda71267231c2526be701fe655db125852c1ffielding [f1, f2] -> do
2d2eda71267231c2526be701fe655db125852c1ffielding s1 <- readFile f1
2d2eda71267231c2526be701fe655db125852c1ffielding s2 <- readFile f2
2d2eda71267231c2526be701fe655db125852c1ffielding case (parseXMLDoc s1, parseXMLDoc s2) of
2d2eda71267231c2526be701fe655db125852c1ffielding (Just e1, Just e2) -> let
2d2eda71267231c2526be701fe655db125852c1ffielding ds = xmlDiff hetsTags [] Map.empty [Elem e1] [Elem e2]
2d2eda71267231c2526be701fe655db125852c1ffielding in unless (null ds) . putStrLn . ppTopElement $ mkMods ds
2d2eda71267231c2526be701fe655db125852c1ffielding _ -> error "parseXMLDoc"
2d2eda71267231c2526be701fe655db125852c1ffielding _ -> error $ "wrong arguments: " ++ show args
2d2eda71267231c2526be701fe655db125852c1ffielding