Google

>
 HaXmlParentContentsIndex
Text.XML.HaXml.Xml2Haskell
Contents
Reading and writing XML data into a typed Haskell representation.
The enabling classes.
Parsing and printing helper functions
Re-exports
Description
This module provides the XmlContent class and readXml and writeXml functions that you will need if you generate a module of Haskell datatype definitions from an XML DTD. Use the DtdToHaskell program to generate both datatypes and instances of this class, then import this module to read and write values to and from XML files.
Synopsis
readXml :: (XmlContent a) => FilePath -> IO a
writeXml :: (XmlContent a) => FilePath -> a -> IO ()
class XmlContent a where
toElem :: a -> [Content]
fromElem :: [Content] -> (Maybe a, [Content])
class XmlAttributes a where
toAttrs :: a -> [Attribute]
fromAttrs :: [Attribute] -> a
class XmlAttrType a where
toAttrFrTyp :: String -> a -> Maybe Attribute
fromAttrToTyp :: String -> Attribute -> Maybe a
choice :: (XmlContent a) => (a -> b) -> ([Content] -> (Maybe b, [Content])) -> [Content] -> (Maybe b, [Content])
definite :: ([Content] -> (Maybe a, [Content])) -> String -> String -> [Content] -> (a, [Content])
many :: ([Content] -> (Maybe a, [Content])) -> [Content] -> ([a], [Content])
fromText :: [Content] -> (Maybe String, [Content])
toText :: String -> [Content]
maybeToAttr :: (String -> a -> Maybe Attribute) -> String -> Maybe a -> Maybe Attribute
defaultToAttr :: (String -> a -> Maybe Attribute) -> String -> Defaultable a -> Maybe Attribute
definiteA :: (String -> Attribute -> Maybe a) -> String -> String -> [Attribute] -> a
defaultA :: (String -> Attribute -> Maybe a) -> a -> String -> [Attribute] -> Defaultable a
possibleA :: (String -> Attribute -> Maybe a) -> String -> [Attribute] -> Maybe a
fromAttrToStr :: String -> Attribute -> Maybe String
toAttrFrStr :: String -> String -> Maybe Attribute
data Defaultable a
= Default a
| NonDefault a
str2attr :: String -> AttValue
attr2str :: AttValue -> String
data Element = Elem Name [Attribute] [Content]
data Content
= CElem Element
| CString Bool CharData
| CRef Reference
| CMisc Misc
Reading and writing XML data into a typed Haskell representation.
readXml :: (XmlContent a) => FilePath -> IO a
Read an XML document from a file and convert it to a fully-typed Haskell value.
writeXml :: (XmlContent a) => FilePath -> a -> IO ()
Write a fully-typed Haskell value to the given file as an XML document.
The enabling classes.
class XmlContent a where
The XmlContent class promises that an XML content element can be converted to and from a Haskell value.
Methods
toElem :: a -> [Content]
fromElem :: [Content] -> (Maybe a, [Content])
Instances
(XmlContent a, XmlContent b) => XmlContent (OneOf2 a b)
(XmlContent a, XmlContent b, XmlContent c) => XmlContent (OneOf3 a b c)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d) => XmlContent (OneOf4 a b c d)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e) => XmlContent (OneOf5 a b c d e)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f) => XmlContent (OneOf6 a b c d e f)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g) => XmlContent (OneOf7 a b c d e f g)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h) => XmlContent (OneOf8 a b c d e f g h)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i) => XmlContent (OneOf9 a b c d e f g h i)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j) => XmlContent (OneOf10 a b c d e f g h i j)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k) => XmlContent (OneOf11 a b c d e f g h i j k)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l) => XmlContent (OneOf12 a b c d e f g h i j k l)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l, XmlContent m) => XmlContent (OneOf13 a b c d e f g h i j k l m)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l, XmlContent m, XmlContent n) => XmlContent (OneOf14 a b c d e f g h i j k l m n)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l, XmlContent m, XmlContent n, XmlContent o) => XmlContent (OneOf15 a b c d e f g h i j k l m n o)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l, XmlContent m, XmlContent n, XmlContent o, XmlContent p) => XmlContent (OneOf16 a b c d e f g h i j k l m n o p)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l, XmlContent m, XmlContent n, XmlContent o, XmlContent p, XmlContent q) => XmlContent (OneOf17 a b c d e f g h i j k l m n o p q)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l, XmlContent m, XmlContent n, XmlContent o, XmlContent p, XmlContent q, XmlContent r) => XmlContent (OneOf18 a b c d e f g h i j k l m n o p q r)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l, XmlContent m, XmlContent n, XmlContent o, XmlContent p, XmlContent q, XmlContent r, XmlContent s) => XmlContent (OneOf19 a b c d e f g h i j k l m n o p q r s)
(XmlContent a, XmlContent b, XmlContent c, XmlContent d, XmlContent e, XmlContent f, XmlContent g, XmlContent h, XmlContent i, XmlContent j, XmlContent k, XmlContent l, XmlContent m, XmlContent n, XmlContent o, XmlContent p, XmlContent q, XmlContent r, XmlContent s, XmlContent t) => XmlContent (OneOf20 a b c d e f g h i j k l m n o p q r s t)
(XmlContent a, XmlContent b) => XmlContent (a, b)
(XmlContent a, XmlContent b, XmlContent c) => XmlContent (a, b, c)
(XmlContent a) => XmlContent [a]
(XmlContent a) => XmlContent (Maybe a)
class XmlAttributes a where
The XmlAttributes class promises that a list of XML tag attributes can be converted to and from a Haskell value.
Methods
toAttrs :: a -> [Attribute]
fromAttrs :: [Attribute] -> a
class XmlAttrType a where
The XmlAttrType class promises that an attribute taking an XML enumerated type can be converted to and from a Haskell value.
Methods
toAttrFrTyp :: String -> a -> Maybe Attribute
fromAttrToTyp :: String -> Attribute -> Maybe a
Parsing and printing helper functions
choice :: (XmlContent a) => (a -> b) -> ([Content] -> (Maybe b, [Content])) -> [Content] -> (Maybe b, [Content])
definite :: ([Content] -> (Maybe a, [Content])) -> String -> String -> [Content] -> (a, [Content])
many :: ([Content] -> (Maybe a, [Content])) -> [Content] -> ([a], [Content])
fromText :: [Content] -> (Maybe String, [Content])
toText :: String -> [Content]
maybeToAttr :: (String -> a -> Maybe Attribute) -> String -> Maybe a -> Maybe Attribute
defaultToAttr :: (String -> a -> Maybe Attribute) -> String -> Defaultable a -> Maybe Attribute
definiteA :: (String -> Attribute -> Maybe a) -> String -> String -> [Attribute] -> a
defaultA :: (String -> Attribute -> Maybe a) -> a -> String -> [Attribute] -> Defaultable a
possibleA :: (String -> Attribute -> Maybe a) -> String -> [Attribute] -> Maybe a
fromAttrToStr :: String -> Attribute -> Maybe String
toAttrFrStr :: String -> String -> Maybe Attribute
data Defaultable a
If an attribute is defaultable, then it either takes the default value (which is omitted from the output), or a non-default value (which obviously must be printed).
Constructors
Default a
NonDefault a
str2attr :: String -> AttValue
attr2str :: AttValue -> String
Re-exports
data Element
Constructors
Elem Name [Attribute] [Content]
data Content
Constructors
CElem Element
CString Bool CharData bool is whether whitespace is significant
CRef Reference
CMisc Misc
Produced by Haddock version 0.4