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 listtype dtd_element_type= Types.dtd_element_type=|DTDEmpty|DTDAny|DTDChild of dtd_childtype dtd_attr_default= Types.dtd_attr_default=|DTDDefault of string|DTDRequired|DTDImplied|DTDFixed of stringtype dtd_attr_type= Types.dtd_attr_type=|DTDCData|DTDNMToken|DTDEnum of string list|DTDID|DTDIDReftype dtd_item= Types.dtd_item=|DTDAttribute of string * string * dtd_attr_type * dtd_attr_default|DTDElement of string * dtd_element_typetype dtd= dtd_item list
The DTD Functions
val parse_file : string -> dtdParse the named file into a Dtd data structure. Raise
Xml.File_not_foundif an error occured while opening the file. RaiseDtd.Parse_errorif parsing failed.
val parse_in : Stdlib.in_channel -> dtdRead the content of the in_channel and parse it into a Dtd data structure. Raise
Dtd.Parse_errorif parsing failed.
val parse_string : string -> dtdParse the string containing a Dtd document into a Dtd data structure. Raise
Dtd.Parse_errorif parsing failed.
val check : dtd -> checkedCheck the Dtd data structure declaration and return a checked DTD. Raise
Dtd.Check_errorif the DTD checking failed.
val prove : checked -> string -> Types.xml -> Types.xmlProve 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_errorElementNotDeclaredif the entry point is not found, raiseDtd.Prove_errorif the Xml document failed to be proved with the DTD.
val to_string : dtd_item -> stringPrint 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
type parse_error_msg=|InvalidDTDDecl|InvalidDTDElement|InvalidDTDAttribute|InvalidDTDTag|DTDItemExpectedtype check_error=type prove_error=type parse_error= parse_error_msg * Types.error_pos
exceptionParse_error of parse_errorexceptionCheck_error of check_errorexceptionProve_error of prove_error
val parse_error : parse_error -> stringval check_error : check_error -> stringval prove_error : prove_error -> string