Web/Libraries/XML and HTML
This page is under construction. Feel free to help out. If you make substantial edits, please add your name to the authors list at the bottom of this page, so that you can be credited if this is ever published in another medium.
The libraries on this page need checking and sorting into maintained/not maintained.
HTML Templating[edit]
- XHtml library
- This is a version of Text.Html, modified to produce XHTML 1.0 Transitional.
Example:
header << thetitle << "Page title"
thediv noHtml ! [theclass "logo"] << "…"
thediv noHtml ! [identifier "login"]
Later, for some people, blaze-html became the new goto HTML writing library. It improved upon the XHTML package by being faster and having a convenient monad instance. It looks like this:
page1 = html $ do
head $ do
title "Introduction page."
link ! rel "stylesheet" ! type_ "text/css" ! href "screen.css"
body $ do
div ! id "header" $ "Syntax"
p "This is an example of BlazeMarkup syntax."
ul $ mapM_ (li . toMarkup . show) [1, 2, 3]
- Vieux: A Nevow implementation
- Vieux is a html-template system for Haskell. The basic idea is to define a xhtml template which is used to generate a xhtml document by Vieux.
- Text.HTML.Chunks
- Text.HTML.Chunks is a templating system inspired by the Perl HTML::Chunks module. The major change for the Haskell version is that the use of the templates is statically verified.
Wanting to improve on Xhtml and Blaze-html, Chris Done wrote Lucid (reddit discussion); a bit later, he updated Lucid to major version 2.0 in a way that removes the need for the with combinator.
Example:
page :: Html ()
page =
html_
(do head_
(do title_ "Introduction page."
link_ [rel_ "stylesheet",type_ "text/css",href_ "screen.css"]
style_ "body{background:red}")
body_
(do div_ [id_ "header",style_ "color:white"] "Syntax"
p_ (span_ (strong_ "This is an example of Lucid syntax."))
hr_ []
ul_ (mapM_ (li_ . toHtml . show)
[1,2,3])
table_ (tr_ (do td_ "Hello!"
td_ [class_ "alt"] "World!"
td_ "Sup?"))))
HTML Parsing[edit]
- TagSoup
- TagSoup is a library for extracting information out of unstructured HTML code, sometimes known as tag-soup. The HTML does not have to be well formed, or render properly within any particular framework. This library is for situations where the author of the HTML is not cooperating with the person trying to extract the information, but is also not trying to hide the information. The library provides a basic data type for a list of unstructured tags, a parser to convert HTML into this tag type, and useful functions and combinators for finding and extracting information.
XML[edit]
- HaXml: utilities for using XML with Haskell
- Includes an XML parser, an HTML parser, a pretty-printer, a combinator library for generic XML transformations, and two Haskell>-<XML converters using type-based translation.
- HXT: Haskell XML Toolbox
- The Haskell XML Toolbox (HXT) bases on the ideas of HaXml and HXML, but introduces a more general approach based on arrows for processing XML with Haskell. The Haskell XML Toolbox uses a generic data model for representing XML documents, including the DTD subset and the document subset, in Haskell. It contains an XML parser, an HTML parser, namespaces are supported, XPath expressions can be used for selecting and transforming parts of a document. Validation can be performed with respect to DTDs and RelaxNG schema. A Getting started page describes the programming model behind HXT and gives some simple examples.
- WraXML
- A little wrapper to HaXML and HXT: It provides a more natural data structure for representing XML trees, and converts between HaXML or HXT and its custom tree structure. The operations on the tree need not to be of type (a -> [a]), thus using these functions is a bit more type safe. It has a custom lazy HTML parser using TagSoup and a custom lazy formatter. The library is currently much oriented to HTML rather than XML.
- 2LT: Two-Level Transformation
- A two-level data transformation consists of a type-level transformation of a data format coupled with value-level transformations of data instances corresponding to that format. Examples of two-level data transformations include XML schema evolution coupled with document migration, and data mappings used for interoperability and persistence. A library of two-level transformation combinators. These combinators are used to compose transformation systems which, when applied to an input type, produce an output type, together with the conversion functions that mediate between input and out types. Front-ends for XML and SQL. These front-ends support (i) reading a schema, (ii) applying a two-level transformation system to produce a new schema, (iii) convert a document/database corresponding to the input schema to a document/database corresponding to the output schema, and vice versa. Referential constraints and primary key information are propagated through the schema transformation.
- HSXML
- A direct Haskell embedding of SXML
- StaticDTD
- StaticDTD: complete static validness against a DTD.