我已经到了论文的第 3 部分。Haskell XML 工具箱的食谱,其中包含 M. Ohlendorf 的RDF 文档处理示例。
这是我写的程序,
import Text.XML.HXT.Core
import System.Exit
import System.Environment
import Data.Maybe
main = do
args <- getArgs
(al, src) <- cmdLineOpts args
[rc] <- runX (processDocument al src)
exitWith ( if rc >= c_err
then ExitFailure (-1)
else ExitSuccess
)
cmdLineOpts :: [String] -> IO (Attributes, String)
cmdLineOpts [] = return ([("","")], "")
cmdLineOpts xss = return (zip [""] xss :: Attributes, last xss)
processDocument :: Attributes -> String -> IOSArrow b Int
processDocument al src =
readDocument al src -- lecture du document en appliquant les attributes
>>>
removeAllWhiteSpace >>> propagateNamespaces
>>>
writeDocument al (fromMaybe "" (lookup a_output_file al))
>>>
getErrStatus
但我仍然遇到以下错误
hxtuto.hs:28:17:
Couldn't match expected type `XIOSysState -> XIOSysState'
against inferred type `(String, String)'
Expected type: SysConfigList
Inferred type: Attributes
In the first argument of `readDocument', namely `al'
In the first argument of `(>>>)', namely `readDocument al src'
Failed, modules loaded: none.
看来这是我的实现cmdLineOpts
不太合适。
这里有什么问题 ?我该如何解决?
谢谢你的帮助 !