X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=hxt-compile.git;a=blobdiff_plain;f=Text%2FXML%2FHXT%2FCompilation%2FXmlTree.hs;h=42db1a60f8e9e2a378173314072ff2340d507992;hp=7f8d48bebe390c4e0ba45b214b0d1443b9144710;hb=5c37ddeda538fb5feb7291a9364d0d130c34f56d;hpb=1dbe832a2826be88eda5fb1229576108bd133d69 diff --git a/Text/XML/HXT/Compilation/XmlTree.hs b/Text/XML/HXT/Compilation/XmlTree.hs index 7f8d48b..42db1a6 100644 --- a/Text/XML/HXT/Compilation/XmlTree.hs +++ b/Text/XML/HXT/Compilation/XmlTree.hs @@ -19,7 +19,7 @@ compileXmlTree t = let node = compileXNode (getNode t) children = HsList (map compileXmlTree (getChildren t)) in - xn "mkTree" $: HsParen node $: children + unq "mkTree" $: HsParen node $: children compileXmlTrees :: XmlTrees -> HsExp @@ -27,28 +27,37 @@ compileXmlTrees = HsList . map compileXmlTree compileXNode :: XNode -> HsExp -compileXNode (XText s) = xn "mkText" $: litStr s -compileXNode (XCharRef n) = xn "mkCharRef" $: litInt n -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 (XError n s) = xn "mkError" $: litInt n $: litStr s +compileXNode (XText s) = unq "mkText" $: litStr s +compileXNode (XCharRef n) = unq "mkCharRef" $: litInt n +compileXNode (XEntityRef s) = unq "mkEntityRef" $: litStr s +compileXNode (XCmt s) = unq "mkCmt" $: litStr s +compileXNode (XCdata s) = unq "mkCdata" $: litStr s +compileXNode (XPi qn ts) = unq "mkPi" $: HsParen (compileQName qn) $: compileXmlTrees ts +compileXNode (XTag qn ts) = unq "mkElementNode" $: HsParen (compileQName qn) $: compileXmlTrees ts +compileXNode (XDTD de as) = unq "mkDTDNode" $: compileDTDElem de $: compileAttributes as +compileXNode (XAttr qn) = unq "mkAttrNode" $: HsParen (compileQName qn) +compileXNode (XError n s) = unq "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 unq :: String -> HsExp unq = HsVar . UnQual . HsIdent