Plist_xml
exception Error of int * int * error
Error ((line, col), msg)
indicates a syntax error at line number line
and column number col
. The line and column numbers start from 1
.
val error_message : error -> string
The simple interface provides functions for reading plist documents into a tree data structure.
type t = [
|
`Bool of bool
|
`Data of string
|
`Date of float * float option
(timestamp, timezone)
*)|
`Float of float
|
`Int of int
|
`String of string
|
`Array of t list
Array
*)|
`Dict of (string * t) list
Dictionary
*) ]
Plist values.
val parse : (unit -> int) -> t
parse source
reads an XML representation of a plist value by repeatedly calling source
, which supplies the next byte of input. The input should include the XML header.
val from_channel : Stdlib.in_channel -> t
from_channel in_channel
reads a plist from in_channel
. See parse
.
val print : (int -> unit) -> t -> unit
print sink t
outputs an XML representation of plist value t
by repeatedly calling sink
with each byte of output. The output includes the XML header and DTD.
val to_channel : Stdlib.out_channel -> t -> unit
to_channel out_channel t
outputs t
to out_channel
. See print
.
The streaming interface provides lower-level signal parsing and printing functions, which do not build up a tree in memory.
type token = [
|
`Array_start
|
`Array_end
|
`Data of string
|
`Date of float * float option
|
`Dict_start
|
`Dict_end
|
`False
|
`Int of int
|
`Key of string
|
`Real of float
|
`String of string
|
`True
]
A token of the logical syntax of a plist value. The logical syntax is an abstraction around an underlying format, such as XML.
A token sequence is well-formed iff it parses to a plist nonterminal:
plist ::= `Array_start plist* `Array_end | `Dict_start kv* `Dict_end | `False | `Data | `Date | `Int | `Real | `String | `True kv ::= `Key plist
Furthermore, a signal is either a token or an `EOI
marker. A well-formed signal sequence consists of a well-formed token sequence followed by `EOI
and represents a plist document.
doc ::= plist `EOI
val decode : (unit -> int) -> (signal -> unit) -> unit
decode source sink
reads bytes of input by repeatedly calling source
and calls sink
upon reading enough to determine the next signal. The emitted signal sequence is guaranteed to be a well-formed document.
val encode : (unit -> signal) -> (int -> unit) -> unit
encode source sink
reads signals by repeatedly calling source
and outputs their XML representation to sink
byte-by-byte.