<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="Pxp_document.namespace_attribute_impl-c.html"> <link rel="Up" href="Pxp_document.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of class methods" rel=Appendix href="index_methods.html"> <link title="Index of classes" rel=Appendix href="index_classes.html"> <link title="Index of class types" rel=Appendix href="index_class_types.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Pxp_types" rel="Chapter" href="Pxp_types.html"> <link title="Pxp_document" rel="Chapter" href="Pxp_document.html"> <link title="Pxp_dtd" rel="Chapter" href="Pxp_dtd.html"> <link title="Pxp_tree_parser" rel="Chapter" href="Pxp_tree_parser.html"> <link title="Pxp_core_types" rel="Chapter" href="Pxp_core_types.html"> <link title="Pxp_ev_parser" rel="Chapter" href="Pxp_ev_parser.html"> <link title="Pxp_event" rel="Chapter" href="Pxp_event.html"> <link title="Pxp_dtd_parser" rel="Chapter" href="Pxp_dtd_parser.html"> <link title="Pxp_codewriter" rel="Chapter" href="Pxp_codewriter.html"> <link title="Pxp_marshal" rel="Chapter" href="Pxp_marshal.html"> <link title="Pxp_yacc" rel="Chapter" href="Pxp_yacc.html"> <link title="Pxp_reader" rel="Chapter" href="Pxp_reader.html"> <link title="Intro_trees" rel="Chapter" href="Intro_trees.html"> <link title="Intro_extensions" rel="Chapter" href="Intro_extensions.html"> <link title="Intro_namespaces" rel="Chapter" href="Intro_namespaces.html"> <link title="Intro_events" rel="Chapter" href="Intro_events.html"> <link title="Intro_resolution" rel="Chapter" href="Intro_resolution.html"> <link title="Intro_getting_started" rel="Chapter" href="Intro_getting_started.html"> <link title="Intro_advanced" rel="Chapter" href="Intro_advanced.html"> <link title="Intro_preprocessor" rel="Chapter" href="Intro_preprocessor.html"> <link title="Example_readme" rel="Chapter" href="Example_readme.html"><title>PXP Reference : Pxp_document.document</title> </head> <body> <div class="navbar"><a class="pre" href="Pxp_document.namespace_attribute_impl-c.html" title="Pxp_document.namespace_attribute_impl">Previous</a> <a class="up" href="Pxp_document.html" title="Pxp_document">Up</a> </div> <h1>Class <a href="type_Pxp_document.document.html">Pxp_document.document</a></h1> <pre><span name="TYPEdocument"><span class="keyword">class</span> <code class="type">[< clone : 'a; node : 'a <a href="Pxp_document.node-c.html">node</a>;<br> set_node : 'a <a href="Pxp_document.node-c.html">node</a> -> unit; .. ><br> as 'a]</code> document</span> : <code class="type">?swarner:<a href="Pxp_types.html#TYPEsymbolic_warnings">Pxp_types.symbolic_warnings</a> -> <a href="Pxp_types.html#TYPEcollect_warnings">Pxp_types.collect_warnings</a> -> <a href="Pxp_types.html#TYPErep_encoding">Pxp_types.rep_encoding</a> -> </code><code class="code"><span class="keyword">object</span></code> <a href="Pxp_document.document-c.html">..</a> <code class="code"><span class="keyword">end</span></code></pre>Documents are used to represent closed documents that may consist of an XML declaration, a DTD, and a node tree. <p> Important invariant: A document is either empty (no root element, no DTD), or it has both a root element and a DTD. <p> A fresh document created by <code class="code"><span class="keyword">new</span></code> is empty.<br> <hr width="100%"> <pre><span id="METHODinit_xml_version"><span class="keyword">method</span> init_xml_version</span> : <code class="type">string -> unit</code></pre><div class="info"> Set the XML version string of the XML declaration.<br> </div> <pre><span id="METHODinit_root"><span class="keyword">method</span> init_root</span> : <code class="type">'a <a href="Pxp_document.node-c.html">node</a> -> string -> unit</code></pre><div class="info"> Set the root element. It is expected that the root element has a DTD. The second argument is the original name of the root element (without namespace prefix processing). Note that <code class="code">init_root</code> checks whether the passed root element has the type expected by the DTD. The check takes into account that the root element might be a virtual root node.<br> </div> <pre><span id="METHODxml_version"><span class="keyword">method</span> xml_version</span> : <code class="type">string</code></pre><div class="info"> Returns the XML version from the XML declaration. Returns "1.0" if the declaration is missing.<br> </div> <pre><span id="METHODxml_standalone"><span class="keyword">method</span> xml_standalone</span> : <code class="type">bool</code></pre><div class="info"> 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 <code class="code"><span class="keyword">false</span></code> if there is no DTD.<br> </div> <pre><span id="METHODdtd"><span class="keyword">method</span> dtd</span> : <code class="type"><a href="Pxp_dtd.dtd-c.html">Pxp_dtd.dtd</a></code></pre><div class="info"> Returns the DTD of the root element. Fails if there is no root element.<br> </div> <pre><span id="METHODencoding"><span class="keyword">method</span> encoding</span> : <code class="type"><a href="Pxp_types.html#TYPErep_encoding">Pxp_types.rep_encoding</a></code></pre><div class="info"> 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.<br> </div> <pre><span id="METHODroot"><span class="keyword">method</span> root</span> : <code class="type">'a <a href="Pxp_document.node-c.html">node</a></code></pre><div class="info"> Returns the root element, or fails if there is not any.<br> </div> <pre><span id="METHODraw_root_name"><span class="keyword">method</span> raw_root_name</span> : <code class="type">string</code></pre><div class="info"> The unprocessed name of the root element (second arg of <code class="code">init_root</code>)<br> </div> <pre><span id="METHODadd_pinstr"><span class="keyword">method</span> add_pinstr</span> : <code class="type"><a href="Pxp_dtd.proc_instruction-c.html">Pxp_dtd.proc_instruction</a> -> unit</code></pre><div class="info"> Adds a processing instruction to the document container. The parser does this for PIs occurring outside the DTD and outside the root element.<br> </div> <pre><span id="METHODpinstr"><span class="keyword">method</span> pinstr</span> : <code class="type">string -> <a href="Pxp_dtd.proc_instruction-c.html">Pxp_dtd.proc_instruction</a> list</code></pre><div class="info"> Return all PIs for a passed target string.<br> </div> <pre><span id="METHODpinstr_names"><span class="keyword">method</span> pinstr_names</span> : <code class="type">string list</code></pre><div class="info"> Return all target strings of all PIs.<br> </div> <span id="2_WritingdocumentsasXMLtext"><h2>Writing documents as XML text</h2></span> <p> The <code class="code">write</code> and <code class="code">display</code> methods are very similar. The main difference is how namespaces are handled. When generating XML text, the namespaces need to be again represented as prefixes. The <code class="code">write</code> method uses the normalized prefixes for this purpose. The <code class="code">display</code> method uses the display prefixes, i.e. the prefixes as they orginally have been in the parsed XML text. This means for parsed XML text <code class="code">display</code> produces an more exact copy of the text, whereas <code class="code">write</code> shows the prefixes as they are seen by the program.<pre><span id="METHODwrite"><span class="keyword">method</span> write</span> : <code class="type">?default:string -><br> ?prefer_dtd_reference:bool -><br> ?dtd_style:[ `Auto | `Included | `Omit | `Reference ] -><br> ?minimization:[ `AllEmpty | `DeclaredEmpty | `None ] -><br> <a href="Pxp_types.html#TYPEoutput_stream">Pxp_types.output_stream</a> -> <a href="Pxp_types.html#TYPEencoding">Pxp_types.encoding</a> -> unit</code></pre><div class="info"> 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. <p> Option <code class="code">~default</code>: Specifies the normprefix that becomes the default namespace in the output. <p> Option <code class="code">~dtd_style</code>: Selects how to print the DTD. <code class="code"><span class="keywordsign">`</span><span class="constructor">Omit</span></code> means to omit the DTD at all (no DOCTYPE clause). <code class="code"><span class="keywordsign">`</span><span class="constructor">Reference</span></code> prints the DTD reference to an external entity (using SYSTEM or PUBLIC identifier), if possible, and falls back to <code class="code"><span class="keywordsign">`</span><span class="constructor">Included</span></code> otherwise. <code class="code"><span class="keywordsign">`</span><span class="constructor">Included</span></code> means to always include the DTD as internal subset. <code class="code"><span class="keywordsign">`</span><span class="constructor">Auto</span></code> tries to find the best way: If there is a DTD, try <code class="code"><span class="keywordsign">`</span><span class="constructor">Reference</span></code> then <code class="code"><span class="keywordsign">`</span><span class="constructor">Included</span></code>. Otherwise, <code class="code"><span class="keywordsign">`</span><span class="constructor">Omit</span></code>. The default is <code class="code"><span class="keywordsign">`</span><span class="constructor">Included</span></code>. <p> Option <code class="code">~prefer_dtd_reference</code>: Same as <code class="code">~dtd_style:<span class="keywordsign">`</span><span class="constructor">Reference</span></code> (backward-compatible). <p> Option <code class="code">~minimization</code>: How to write out empty elements. <code class="code"><span class="keywordsign">`</span><span class="constructor">AllEmpty</span></code> means that all empty elements are minimized (using the <name/> form). <code class="code"><span class="keywordsign">`</span><span class="constructor">DeclaredEmpty</span></code> minimizes only empty elements that are declared as empty in the DTD. <code class="code"><span class="keywordsign">`</span><span class="constructor">None</span></code> does not minimize at all and is the default.<br> </div> <pre><span id="METHODdisplay"><span class="keyword">method</span> display</span> : <code class="type">?prefer_dtd_reference:bool -><br> ?dtd_style:[ `Auto | `Included | `Omit | `Reference ] -><br> ?minimization:[ `AllEmpty | `DeclaredEmpty | `None ] -><br> <a href="Pxp_types.html#TYPEoutput_stream">Pxp_types.output_stream</a> -> <a href="Pxp_types.html#TYPEencoding">Pxp_types.encoding</a> -> unit</code></pre><div class="info"> 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 <code class="code">write</code>, this method uses the display namespace prefixes instead of the normprefixes. <p> Option <code class="code">~dtd_style</code>: Same meaning as in <code class="code">write</code>. <p> Option <code class="code">~prefer_dtd_reference</code>: Same meaning as in <code class="code">write</code>. <p> Option <code class="code">~minimization</code>: Same meaning as in <code class="code">write</code>.<br> </div> <pre><span id="METHODdump"><span class="keyword">method</span> dump</span> : <code class="type">Format.formatter -> unit</code></pre></body></html>