HaXml
   HOME

TheInfoList



OR:

HaXml is a collection of utilities for
parsing Parsing, syntax analysis, or syntactic analysis is a process of analyzing a String (computer science), string of Symbol (formal), symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal gramm ...
,
filtering Filtration is a physical process that separates solid matter and fluid from a mixture. Filter, filtering, filters or filtration may also refer to: Science and technology Computing * Filter (higher-order function), in functional programming * Fil ...
, transforming, and generating Extensible Markup Language (
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
) documents using the
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
Haskell Haskell () is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell pioneered several programming language ...
.


Overview

HaXml utilities include: * XML parser * XML validator * a separate error-correcting parser for
HTML Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
* pretty-printers for XML and HTML * stream parser for XML events * translator from DTD to Haskell * translator from XML Schema definitions to Haskell data types HaXml provides a
combinator Combinatory logic is a notation to eliminate the need for quantified variables in mathematical logic. It was introduced by Moses Schönfinkel and Haskell Curry, and has more recently been used in computer science as a theoretical model of comp ...
library with a set of
higher-order function In mathematics and computer science, a higher-order function (HOF) is a function that does at least one of the following: * takes one or more functions as arguments (i.e. a procedural parameter, which is a parameter of a procedure that is itself ...
s which process the XML documents after they are represented using the native Haskell
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
s. The basic data type is Content which represents the document subset of XML. HaXml allows converting XML to Haskell data and vice versa, and XML to XML (by transforming or
filtering Filtration is a physical process that separates solid matter and fluid from a mixture. Filter, filtering, filters or filtration may also refer to: Science and technology Computing * Filter (higher-order function), in functional programming * Fil ...
). The common use of the HaXml's parser includes defining the method of traversing the XML data and it has the CFilter type (''content filter''), where type CFilter = Content -> ontent/code>. It means that this
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-orie ...
defined by the user will take a fragment of an XML data and either return more fragments or none at all. This approach allows to choose XML elements satisfying certain conditions (e.g., tags with certain name or all children of a specified tag).


Example

In the chapter 22 "Extended Example: Web Client Programming" of the Real World Haskell by Bryan O'Sullivan, Don Stewart, and John Goerzen, the following example is considered. The XML file looks like this (simplified version): Haskell Radio http://www.example.com/radio/ Description of this podcast First item Second item The following content filter is constructed: channel :: CFilter channel = tag "rss" /> tag "channel" This filter is later used to get the title of the channel: getTitle :: Content -> String getTitle doc = contentToStringDefault "Untitled Podcast" (channel /> tag "title" /> txt $ doc)


References


External links

* {{Haskell programming Free software programmed in Haskell XML parsers Software using the GNU Lesser General Public License