| Copyright | Dennis Gosnell 2017 |
|---|---|
| License | BSD3 |
| Maintainer | Dennis Gosnell (cdep.illabout@gmail.com) |
| Stability | experimental |
| Portability | unknown |
| Safe Haskell | None |
| Language | Haskell2010 |
Text.XML.QQ
Contents
Description
This module provides a quasi-quoter for XML Documents. See the xml
function for some examples.
The difference between Text.XML.QQ and Text.HTML.QQ is the function that is
used to parse the input String into a Document.
xml uses parseText to parse the input String.
parseText returns an error on a malformed document. This is
generally what you want for XML documents.
html uses parseLT to parse the input String.
parseLT will parse any HTML document, skipping parts of the
document that are malformed. This is generally what you want for HTML
documents.
- xml :: QuasiQuoter
- xmlUnsafe :: QuasiQuoter
- xmlRaw :: QuasiQuoter
- data Document :: *
- data SomeException :: *
Documentation
xml :: QuasiQuoter Source #
This QuasiQuoter produces XML Documents.
This QuasiQuoter produces expressions of type
. It produces a
Either SomeException Document when the input string cannot be parsed into an XML
Left SomeExceptionDocument.
Here's a simple example of using it:
>>>[xml|<html></html>|]Right (Document {documentPrologue = Prologue {prologueBefore = [], prologueDoctype = Nothing, prologueAfter = []}, documentRoot = Element {elementName = Name {nameLocalName = "html", nameNamespace = Nothing, namePrefix = Nothing}, elementAttributes = fromList [], elementNodes = []}, documentEpilogue = []})
Internally, this function is using the
heterocephalus package.
This means you can use variable interpolation, as well as forall, if,
and case control statements. Checkout the
heterocephalus README for
more info.
>>>let a = "hello world">>>[xml|<html>#{a}</html>|]Right ...
Here's an example of invalue XML that will produce a Left value:
>>>[xml|<html </html>|]Left ...
Here's an example of a template that can be parsed as an HTML Document, but
not as an XML Document:
>>>[xml|<html><br></html>|]Left ...
xmlRaw :: QuasiQuoter Source #
Types
data SomeException :: * #
The SomeException type is the root of the exception type hierarchy.
When an exception of type e is thrown, behind the scenes it is
encapsulated in a SomeException.
Instances