HaXml-1.13.2: Utilities for manipulating XML documentsContentsIndex
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 => String -> Maybe a
showXml :: XmlContent a => a -> String
hGetXml :: XmlContent a => Handle -> IO a
hPutXml :: XmlContent a => Handle -> a -> IO ()
fReadXml :: XmlContent a => FilePath -> IO a
fWriteXml :: XmlContent a => FilePath -> a -> IO ()
class XmlContent a where
fromElem :: [Content] -> (Maybe a, [Content])
toElem :: a -> [Content]
class XmlAttributes a where
fromAttrs :: [Attribute] -> a
toAttrs :: a -> [Attribute]
class XmlAttrType a where
fromAttrToTyp :: String -> Attribute -> Maybe a
toAttrFrTyp :: String -> a -> Maybe Attribute
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]
data List1 a = NonEmpty [a]
data ANYContent = ANYContent
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
catMaybes
Reading and writing XML data into a typed Haskell representation.
readXml :: XmlContent a => String -> Maybe a
Read a fully-typed XML document from a string.
showXml :: XmlContent a => a -> String
Convert a fully-typed XML document to a string.
hGetXml :: XmlContent a => Handle -> IO a
Read a fully-typed XML document from a file handle.
hPutXml :: XmlContent a => Handle -> a -> IO ()
Write a fully-typed XML document to a file handle.
fReadXml :: XmlContent a => FilePath -> IO a
Read an XML document from a file and convert it to a fully-typed Haskell value.
fWriteXml :: 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
fromElem :: [Content] -> (Maybe a, [Content])
toElem :: a -> [Content]
show/hide Instances
XmlContent ANYContent
(XmlContent a, XmlContent b) => XmlContent (a, b)
(XmlContent a, XmlContent b, XmlContent c) => XmlContent (a, b, c)
XmlContent a => XmlContent (List1 a)
XmlContent a => XmlContent (Maybe a)
XmlContent a => XmlContent [a]
(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)
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
fromAttrs :: [Attribute] -> a
toAttrs :: a -> [Attribute]
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
fromAttrToTyp :: String -> Attribute -> Maybe a
toAttrFrTyp :: String -> a -> Maybe Attribute
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]
data List1 a
The List1 type represents lists with at least one element. It is required for DTD content models that use + as a modifier.
Constructors
NonEmpty [a]
show/hide Instances
??? a => Eq (List1 a)
??? a => Show (List1 a)
XmlContent a => XmlContent (List1 a)
data ANYContent
A type corresponding to XML's ANY contentspec data ANYContent = forall a . XmlContent a => ANYContent a
Constructors
ANYContent
show/hide Instances
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
show/hide Instances
str2attr :: String -> AttValue
attr2str :: AttValue -> String
Re-exports
data Element
Constructors
Elem Name [Attribute] [Content]
show/hide Instances
data Content
Constructors
CElem Element
CString Bool CharDatabool is whether whitespace is significant
CRef Reference
CMisc Misc
show/hide Instances
catMaybes
Produced by Haddock version 0.8