[Haskell-cafe] HaXML - creating a simple document

Jeremy Shaw jeremy.shaw at linspireinc.com
Sat Dec 30 17:50:09 EST 2006


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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list