main :: IO ()
-main = do let fpath = "examples/utf8.xml"
+main = do let fpath = "examples/dtd.xml"
[hsMod] <- runX ( setErrorMsgHandler False fail
>>>
constA fpath
>>>
readFromDocument [ (a_validate , v_0)
+ , (a_canonicalize , v_0)
, (a_check_namespaces, v_1)
]
>>>
wrapIntoModule = proc (modName, (extImports, (symName, (symType, symExp)))) ->
do let hsModule = HsModule undefined modName (Just exports) imports decls
exports = [HsEVar (UnQual symName)]
- imports = [ HsImportDecl undefined (Module "Text.XML.HXT.Arrow") False Nothing Nothing
- , HsImportDecl undefined (Module "Text.XML.HXT.DOM.XmlNode") True (Just (Module "XN")) Nothing
+ imports = [ HsImportDecl undefined (Module "Text.XML.HXT.DOM.Interface") False Nothing Nothing
+ , HsImportDecl undefined (Module "Text.XML.HXT.DOM.XmlNode" ) False Nothing Nothing
] ++ extImports
decls = [ HsTypeSig undefined [symName] symType
, HsFunBind [HsMatch undefined symName [] (HsUnGuardedRhs symExp) []]
compileXNode (XEntityRef s) = xn "mkEntityRef" $: litStr s
compileXNode (XCmt s) = xn "mkCmt" $: litStr s
compileXNode (XCdata s) = xn "mkCdata" $: litStr s
-compileXNode (XPi qn ts) = xn "mkPi" $: HsParen (compileQName qn) $: compileXmlTrees ts
-compileXNode (XTag qn ts) = xn "mkElementNode" $: HsParen (compileQName qn) $: compileXmlTrees ts
-compileXNode (XDTD de as) = xn "mkDTDNode" $: HsParen (compileDTDElem de) $: HsParen (compileAttributes as)
-compileXNode (XAttr qn) = xn "mkAttrNode" $: HsParen (compileQName qn)
+compileXNode (XPi qn ts) = xn "mkPi" $: HsParen (compileQName qn) $: compileXmlTrees ts
+compileXNode (XTag qn ts) = xn "mkElementNode" $: HsParen (compileQName qn) $: compileXmlTrees ts
+compileXNode (XDTD de as) = xn "mkDTDNode" $: compileDTDElem de $: compileAttributes as
+compileXNode (XAttr qn) = xn "mkAttrNode" $: HsParen (compileQName qn)
compileXNode (XError n s) = xn "mkError" $: litInt n $: litStr s
compileDTDElem :: DTDElem -> HsExp
-compileDTDElem = error "compileDTDElem: FIXME: not implemented"
+compileDTDElem DOCTYPE = unq "DOCTYPE"
+compileDTDElem ELEMENT = unq "ELEMENT"
+compileDTDElem CONTENT = unq "CONTENT"
+compileDTDElem ATTLIST = unq "ATTLIST"
+compileDTDElem ENTITY = unq "ENTITY"
+compileDTDElem PENTITY = unq "PENTITY"
+compileDTDElem NOTATION = unq "NOTATION"
+compileDTDElem CONDSECT = unq "CONDSECT"
+compileDTDElem NAME = unq "NAME"
+compileDTDElem PEREF = unq "PEREF"
compileAttributes :: Attributes -> HsExp
-compileAttributes = error "compileAttributes: FIXME: not implemented"
+compileAttributes = HsList . map compileAttr
+ where
+ compileAttr :: (String, String) -> HsExp
+ compileAttr (k, v) = HsTuple [ litStr k, litStr v ]
+
xn :: String -> HsExp
-xn = HsVar . Qual (Module "XN") . HsIdent
+--xn = HsVar . Qual (Module "XN") . HsIdent
+xn = unq
unq :: String -> HsExp
unq = HsVar . UnQual . HsIdent