Class Pxp_document.document


class ['a node #extension as 'a] document : ?swarner:Pxp_core_types.symbolic_warnings -> Pxp_core_types.collect_warnings -> Pxp_core_types.rep_encoding -> object .. end

Documents: These are containers for root elements and for DTDs.

Important invariant: A document is either empty (no root element, no DTD), or it has both a root element and a DTD.

A fresh document created by 'new' is empty.

method init_xml_version : string -> unit
method init_root : 'a node -> string -> unit
method xml_version : string
Returns the XML version from the XML declaration. Returns "1.0" if the declaration is missing.
method xml_standalone : bool
Returns whether this document is declared as being standalone. This method returns the same value as 'standalone_declaration' of the DTD (if there is a DTD). Returns 'false' if there is no DTD.
method dtd : Pxp_dtd.dtd
Returns the DTD of the root element. Fails if there is no root element.
method encoding : Pxp_core_types.rep_encoding
Returns the string encoding of the document = the encoding of the root element = the encoding of the element tree = the encoding of the DTD. Fails if there is no root element.
method root : 'a node
Returns the root element, or fails if there is not any.
method raw_root_name : string
The unprocessed name of the root element (second arg of init_root)
method add_pinstr : Pxp_dtd.proc_instruction -> unit
Adds a processing instruction to the document container. The parser does this for PIs occurring outside the DTD and outside the root element.
method pinstr : string -> Pxp_dtd.proc_instruction list
Return all PIs for a passed target string.
method pinstr_names : string list
Return all target strings of all PIs.
method write : ?default:string ->
?prefer_dtd_reference:bool ->
?dtd_style:[ `Auto | `Included | `Omit | `Reference ] ->
?minimization:[ `AllEmpty | `DeclaredEmpty | `None ] ->
Pxp_core_types.output_stream -> Pxp_core_types.encoding -> unit
Write the document to the passed output stream; the passed encoding used. The format is compact (the opposite of "pretty printing"). If a DTD is present, the DTD is included as internal subset.

Option ~default: Specifies the normprefix that becomes the default namespace in the output.

Option ~dtd_style: Selects how to print the DTD. `Omit means to omit the DTD at all (no DOCTYPE clause). `Reference prints the DTD reference to an external entity (using SYSTEM or PUBLIC identifier), if possible, and falls back to `Included otherwise. `Included means to always include the DTD as internal subset. `Auto tries to find the best way: If there is a DTD, try `Reference then `Included. Otherwise, `Omit. The default is `Included.

Option ~prefer_dtd_reference: Same as ~dtd_style:`Reference (backward-compatible).

Option ~minimization: How to write out empty elements. `AllEmpty means that all empty elements are minimized (using the <name/> form). `DeclaredEmpty minimizes only empty elements that are declared as empty in the DTD. `None does not minimize at all and is the default.

method display : ?prefer_dtd_reference:bool ->
?dtd_style:[ `Auto | `Included | `Omit | `Reference ] ->
?minimization:[ `AllEmpty | `DeclaredEmpty | `None ] ->
Pxp_core_types.output_stream -> Pxp_core_types.encoding -> unit
Write the document to the passed output stream; the passed encoding used. The format is compact (the opposite of "pretty printing"). If a DTD is present, the DTD is included as internal subset. In contrast to write, this method uses the display namespace prefixes instead of the normprefixes.

Option ~dtd_style: Same meaning as in write.

Option ~prefer_dtd_reference: Same meaning as in write.

Option ~minimization: Same meaning as in write.

method dump : Format.formatter -> unit