
Hello, I don't know why my simple example will not render a simple HTML document. For the moment, I simply want to render this: <html> </html> or whatever, the simplest document is. When I run my source code, it simply hangs (as the transcript below shows) {- SOURCE CODE -} import Text.XML.HaXml.Html.Generate import Text.XML.HaXml.Combinators import Text.XML.HaXml.Wrappers main = processXmlWith go go = html [] {- EXECUTION TRANSCRIPT <!-- ~/Documents/Haskell/haxml/mkElem tbrannon --> ghci mk.hs ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. [1 of 1] Compiling Main ( mk.hs, interpreted ) Ok, modules loaded: Main. *Main> main Loading package haskell98 ... linking ... done. Loading package HaXml-1.17 ... linking ... done. -}

Hello, According to this page: http://www.cs.york.ac.uk/fp/HaXml/HaXml/Text-XML-HaXml-Wrappers.html processXmlWith is used to apply a filter to an existing XML document. By default, it will try to read the input document from stdin. So, I am imagine that is what it is doing -- sitting their waiting for you to input the document on stdin. It sounds like what you want to do is create a new html document from scratch -- not filter an existing document. I have never been very clear on how you are supposed to do this with HaXml... Also, creating html or xhtml documents with HaXml may be a bit tricky, because HaXml will try to use short tags whenever there is no content in the body. But, html does not always allow this. For example, an empty textarea in html must have distinct open and close tags: <textarea></textarea> But HaXml will try to use the short tag: <textarea/> However, it looks like there is now a function, htmlprint :: [Content] -> Doc http://www.cs.york.ac.uk/fp/HaXml/HaXml/Text-XML-HaXml-Html-Generate.html So may something like this would work:
main = print $ htmlprint $ go (CString False "")
go :: CFilter go = html []
I don't have HaXml install at the moment, so that may not type-check... j. At Sat, 30 Dec 2006 21:38:50 +0000 (UTC), Terrence Brannon wrote:
Hello, I don't know why my simple example will not render a simple HTML document.
For the moment, I simply want to render this: <html> </html>
or whatever, the simplest document is.
When I run my source code, it simply hangs (as the transcript below shows)
{- SOURCE CODE -} import Text.XML.HaXml.Html.Generate import Text.XML.HaXml.Combinators import Text.XML.HaXml.Wrappers
main = processXmlWith go
go = html []
{- EXECUTION TRANSCRIPT
<!-- ~/Documents/Haskell/haxml/mkElem tbrannon --> ghci mk.hs ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help.
Loading package base ... linking ... done. [1 of 1] Compiling Main ( mk.hs, interpreted ) Ok, modules loaded: Main. *Main> main Loading package haskell98 ... linking ... done. Loading package HaXml-1.17 ... linking ... done.
-}
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 12/30/06, Jeremy Shaw < jeremy.shaw@linspireinc.com> wrote: So may something like this would work: > main = print $ htmlprint $ go (CString False "") mk.hs:6:33: Couldn't match expected type `Content i' against inferred type `i1 -> Content i1' In the first argument of `go', namely `(CString False "")' In the second argument of `($)', namely `go (CString False "")' In the second argument of `($)', namely `htmlprint $ (go (CString False ""))' --------------------------------------------------------------------------- I modified it like this and got the error included in the comment: The type check error for your version is below. I include my modified source and associated error jeopardy style. Thanks for your efforts on this. import Text.XML.HaXml.Html.Generate import Text.XML.HaXml.Combinators import Text.XML.HaXml.XmlContent import Text.XML.HaXml.Wrappers main = print $ htmlprint $ go $ (CString False "") {- mk.hs:6:34: Couldn't match expected type `Content i' against inferred type `i1 -> Content i1' In the second argument of `($)', namely `(CString False "")' In the second argument of `($)', namely `go $ (CString False "")' In the second argument of `($)', namely `htmlprint $ (go $ (CString False ""))' -} go = html []

Actually, the examples directory in the distro for the development release has a nice program to create an element and print it to stdout called SimpleTestBool.hs: module Main where import List (isPrefixOf) import Text.XML.HaXml.XmlContent import Text.XML.HaXml.Types import Text.PrettyPrint.HughesPJ (render) import Text.XML.HaXml.Pretty (document) -- Test stuff --value1 :: ([(Bool,Int)],(String,Maybe Char)) value1 = True --main = do (putStrLn . render . document . toXml) value2 main = fWriteXml "/dev/tty" value1
participants (3)
-
Jeremy Shaw
-
Terrence Brannon
-
Terrence Brannon