csvfields

Runtime support for ppx_xml_conv and ppx_csv_conv
IN THIS PACKAGE
Module Xml_light . Dtd
The DTD Types
include module type of Dtd0
type dtd_child = Types.dtd_child =
| DTDTag of string
| DTDPCData
| DTDOptional of dtd_child
| DTDZeroOrMore of dtd_child
| DTDOneOrMore of dtd_child
| DTDChoice of dtd_child list
| DTDChildren of dtd_child list
type dtd_element_type = Types.dtd_element_type =
| DTDEmpty
| DTDAny
| DTDChild of dtd_child
type dtd_attr_default = Types.dtd_attr_default =
| DTDDefault of string
| DTDRequired
| DTDImplied
| DTDFixed of string
type dtd_attr_type = Types.dtd_attr_type =
| DTDCData
| DTDNMToken
| DTDEnum of string list
| DTDID
| DTDIDRef
type dtd_item = Types.dtd_item =
| DTDAttribute of string * string * dtd_attr_type * dtd_attr_default
| DTDElement of string * dtd_element_type
type dtd = dtd_item list
type checked
The DTD Functions
val parse_file : string -> dtd

Parse the named file into a Dtd data structure. Raise Xml.File_not_found if an error occured while opening the file. Raise Dtd.Parse_error if parsing failed.

val parse_in : in_channel -> dtd

Read the content of the in_channel and parse it into a Dtd data structure. Raise Dtd.Parse_error if parsing failed.

val parse_string : string -> dtd

Parse the string containing a Dtd document into a Dtd data structure. Raise Dtd.Parse_error if parsing failed.

val check : dtd -> checked

Check the Dtd data structure declaration and return a checked DTD. Raise Dtd.Check_error if the DTD checking failed.

val prove : checked -> string -> Types.xml -> Types.xml

Prove an Xml document using a checked DTD and an entry point. The entry point is the first excepted tag of the Xml document, the returned Xml document has the same structure has the original one, excepted that non declared optional attributes have been set to their default value specified in the DTD. Raise Dtd.Check_error ElementNotDeclared if the entry point is not found, raise Dtd.Prove_error if the Xml document failed to be proved with the DTD.

val to_string : dtd_item -> string

Print a DTD element into a string. You can easily get a DTD document from a DTD data structure using for example String.concat "\n" (List.map Dtd.to_string) my_dtd

The DTD Exceptions

There is three types of DTD excecptions :

  • Dtd.Parse_error is raised when an error occured while parsing a DTD document into a DTD data structure.
  • Dtd.Check_error is raised when an error occured while checking a DTD data structure for completeness, or when the prove entry point is not found when calling Dtd.prove.
  • Dtd.Prove_error is raised when an error occured while proving an Xml document.

Several string conversion functions are provided to enable you to report errors to the user.

type parse_error_msg =
| InvalidDTDDecl
| InvalidDTDElement
| InvalidDTDAttribute
| InvalidDTDTag
| DTDItemExpected
type check_error =
| ElementDefinedTwice of string
| AttributeDefinedTwice of string * string
| ElementEmptyContructor of string
| ElementReferenced of string * string
| ElementNotDeclared of string
| WrongImplicitValueForID of string * string
type prove_error =
| UnexpectedPCData
| UnexpectedTag of string
| UnexpectedAttribute of string
| InvalidAttributeValue of string
| RequiredAttribute of string
| ChildExpected of string
| EmptyExpected
| DuplicateID of string
| MissingID of string
type parse_error = parse_error_msg * Types.error_pos
exception Parse_error of parse_error
exception Check_error of check_error
exception Prove_error of prove_error
val parse_error : parse_error -> string
val check_error : check_error -> string
val prove_error : prove_error -> string