-- | -- format a xml tree in tree representation -- -- Version : $Id: FormatXmlTree.hs,v 1.9 2003/08/29 14:55:57 hxml Exp $ module FormatXmlTree ( formatXmlTree , formatXmlContents ) where import XmlTree -- ------------------------------------------------------------ formatXmlContents :: XmlFilter formatXmlContents t = [mkXTextTree (formatXmlTree t)] formatXmlTree :: XmlTree -> String formatXmlTree = formatNTree xnode2String xnode2String :: XNode -> String xnode2String (XTag n al) = "XTag " ++ showQn n ++ concatMap showAl al xnode2String (XPi n al) = "XPi " ++ showQn n ++ concatMap showAl al xnode2String n = show n showAl :: XmlTree -> String showAl (NTree (XAttr an) av) = "\n| " ++ showQn an ++ "=" ++ show (xmlTreesToString av) showAl t = show t showQn :: QName -> String showQn n | null ns = show $ qualifiedName n | otherwise = show $ "{" ++ ns ++ "}" ++ qualifiedName n where ns = namespaceUri n -- ------------------------------------------------------------