Migrating from HaXml 1.13 to HaXml >= 1.17
There are 3 main changes between 1.13 and 1.17:
More info fields in the generic document tree
Content items in the generic document representation now have an
extra polymorphic component field. This can be used for
propagating information throughout the document tree, like
namespace scopes. However, if you simply want to change some old
code to use the new types, essentially you can just use unit
() values as dummies to fill in this field.
data Document --> data Document i
data Element --> data Element i
data Content --> data Content i
New XmlContent class, replaces old classes
The Haskell2Xml and Xml2Haskell classes have been
merged into a single new class: XmlContent. Because the new
class is based on combinator parsers that return good error
messages, some of the signatures of user-accessible I/O routines
have changed to enable the possibility of reporting parse errors.
See this page for details.
If you are playing with the class methods themselves, then the
translation from old-style to new-style is more-or-less like this:
class XmlContent a where -- old
fromElem :: [Content] -> (Maybe a, [Content])
toElem :: a -> [Content]
becomes
class XMLContent a where --new
parseContents :: XMLParser a
toContents :: a -> [Content ()]
Lazy parsing
Parsing of generic XML documents can now be lazy, that is, it can
start returning part of the document tree, before seeing the end of
it. However, this does mean that parse errors can be discovered
too late to do anything sensible with them - your program will
likely just stop with the error message. To use the lazy parser,
import Text.XML.HaXml.Parse --> import Text.XML.HaXml.ParseLazy