[Haskell-cafe] How to force HTML (rather than XML) output from Haskell XML Toolbox?

Dimitry Golubovsky golubovsky at gmail.com
Wed Aug 30 09:29:31 EDT 2006


Hi,

I am developing a code that reads a HTML page (template), modifies it
(adds some stuff) and then writes the output file which is to be HTML,
not XML.

I use hxt-5.3 (but I may upgrade if necessary).

It is desired to preserve the original HTML template pieces maximally
close to the original.

But output appears to be closer to XML rather than HTML.

The code I use:

====================

  let attrs = [(a_parse_html, "1"),
               (a_output_xml, "0"),
               (a_encoding,   utf8)]

  (res, err, rc) <- getXmlDocument attrs (fromJust $ tmplPath dopt)

  putXmlDocument attrs (fromJust $ outPath dopt) res

=====================

for this input HTML file:

=====================

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Empty Page Template for Haskell Applications</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
</body>
</html>

=====================

outputs:

=====================

<html>
<head>
  <title>Empty Page Template for Haskell Applications</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
</head>
<body>
</body>
</html>

=====================

which is close but not exactly as wanted. The <meta> (and I expect
other tags like <br> will have the same) tag has closing slash as it
would have in XML (XHTML), but not in HTML. Also the DOCTYPE has been
lost.

Is this something hxt is not able to provide, or just a bug fixed
since 5.3? Or should I write my own output code (because I am
guessing, hxt functionality regarding manipulation over XML trees is
sufficient for what I need)? Or should I use another package?

-- 
Dimitry Golubovsky

Anywhere on the Web


More information about the Haskell-Cafe mailing list