pi package:hxt

conversion of an arbitrary value into an XML document tree. The pickler, first parameter, controls the conversion process. Result is a complete document tree including a root node
Pickler functions for converting between user defined data types and XmlTree data. Usefull for persistent storage and retreival of arbitray data as XML documents This module is an adaptation of the pickler combinators developed by Andrew Kennedy ( https://www.microsoft.com/en-us/research/wp-content/uploads/2004/01/picklercombinators.pdf ) The difference to Kennedys approach is that the target is not a list of Chars but a list of XmlTrees. The basic picklers will convert data into XML text nodes. New are the picklers for creating elements and attributes. One extension was neccessary: The unpickling may fail. Therefore the unpickler has a Maybe result type. Failure is used to unpickle optional elements (Maybe data) and lists of arbitray length There is an example program demonstrating the use of the picklers for a none trivial data structure. (see "examples/arrows/pickle" directory)
add an <?xml version="1.0"?> processing instruction if it's not already there
add an encoding spec to the <?xml version="1.0"?> processing instruction
The class for overloading xpickle, the default pickler
An arrow for checking picklers A value is transformed into an XML document by a given pickler, the associated DTD is extracted from the pickler and checked, the document including the DTD is tranlated into a string, this string is read and validated against the included DTD, and unpickled. The last step is the equality with the input. If the check succeeds, the arrow works like this, else it fails.
Pickles a value, then writes the document to a string.
Compute the associated DTD of a pickler
Conversion of an XML document tree into an arbitrary data type The inverse of pickleDoc. This law should hold for all picklers: unpickle px . pickle px $ v == Just v . Not every possible combination of picklers does make sense. For reconverting a value from an XML tree, is becomes neccessary, to introduce "enough" markup for unpickling the value
Like unpickleDoc but with a (sometimes) useful error message, when unpickling failed.
Pickle an Int
The arrow for generating the DTD out of a pickler A DTD is generated from a pickler and check for consistency. Errors concerning the DTD are issued.
store an arbitray value in a persistent XML document The pickler converts a value into an XML tree, this is written out with writeDocument. The option list is passed to writeDocument An option evaluated by this arrow is a_addDTD. If a_addDTD is set (v_1), the pickler DTD is added as an inline DTD into the document.
The arrow version of the pickler function
Write out the DTD generated out of a pickler. Calls xpicklerDTD
read an arbitray value from an XML document The document is read with readDocument. Options are passed to readDocument. The conversion from XmlTree is done with the pickler. xpickleDocument xp al dest >>> xunpickleDocument xp al' dest is the identity arrow when applied with the appropriate options. When during pickling indentation is switched on, the whitespace must be removed during unpickling.
The arrow version of the unpickler function