Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > d9c1887ff364dc87e282490223567c41 > files > 181

ocaml-pxp-1.2.1-1mdv2010.0.i586.rpm

<!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="Up" href="Pxp_reader.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_reader.resolver</title>
</head>
<body>
<div class="navbar">&nbsp;<a href="Pxp_reader.html">Up</a>
&nbsp;</div>
<center><h1>Class type <a href="type_Pxp_reader.resolver.html">Pxp_reader.resolver</a></h1></center>
<br>
<pre><span class="keyword">class type</span> <a name="TYPEresolver"></a>resolver = <code class="code"><span class="keyword">object</span></code> <a href="Pxp_reader.resolver.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><hr width="100%">
<pre><span class="keyword">method</span> <a name="METHODinit_rep_encoding"></a>init_rep_encoding : <code class="type"><a href="Pxp_types.html#TYPErep_encoding">Pxp_types.rep_encoding</a> -> unit</code></pre><div class="info">
A resolver can open an input source, and returns this source as
 <code class="code"><span class="constructor">Lexing</span>.lexbuf</code> (and as its advanced version, 
 <code class="code"><span class="constructor">Netulex</span>.<span class="constructor">ULB</span>.unicode_lexbuf</code>).
<p>

 After creating a resolver, one must invoke the two methods
 <code class="code">init_rep_encoding</code> and <code class="code">init_warner</code> to set the internal encoding of
 strings and the warner object, respectively. This is normally
 already done by the parsing core.
 It is not necessary to invoke these two methods for a fresh
 clone.
<p>

 It is possible that the character encoding of the source and the
 internal encoding of the parser are different. To cope with this,
 one of the tasks of the resolver is to recode the characters of
 the input source into the internal character encoding.
<p>

 Note that there are several ways of determining the encoding of the
 input: (1) It is possible that the transport protocol (e.g. HTTP)
 transmits the encoding, and (2) it is possible to inspect the beginning
 of the file, and to analyze:<ul>
<li>(2.1) The first two bytes indicate whether UTF-16 is used</li>
<li>(2.2) Otherwise, one can assume that an ASCII-compatible character
         set is used. It is now possible to read the XML declaration
         <code class="code">&lt;?xml ... encoding=<span class="string">"xyz"</span> ...<span class="keywordsign">?&gt;</span></code>. The encoding found here is
         to be used.</li>
<li>(2.3) If the XML declaration is missing, the encoding is UTF-8.</li>
</ul>

 The resolver needs only to distinguish between cases (1), (2.1),
 and the rest.
 The details of analyzing whether (2.2) or (2.3) applies are programmed
 elsewhere, and the resolver will be told the result (see below).
<p>

 A resolver is like a file: it must be opened before one can work
 with it, and it should be closed after all operations on it have been
 done. The method <code class="code">open_rid</code> is called with the resolver ID as argument
 and it must return the lexbuf reading from the external resource.
 (There is also the old method <code class="code">open_in</code> that expects an <code class="code">ext_id</code> as
 argument. It is less powerful and should not be used any longer.)
 The method <code class="code">close_in</code> does not require an argument.
<p>

 It is allowed to re-open a resolver after it has been closed. It is
 forbidden to open a resolver again while it is open.
 It is allowed to close a resolver several times: If <code class="code">close_in</code> is
 invoked while the resolver is already closed, nothing happens.
<p>

 The method <code class="code">open_rid</code> may raise <code class="code"><span class="constructor">Not_competent</span></code> to indicate that this
 resolver is not able to open this type of IDs.
<p>

 If <code class="code">open_rid</code> gets a <code class="code"><span class="constructor">PUBLIC</span></code> ID, it can be assumed that the string
 is already normalized (concerning whitespace).
<p>

 The method <code class="code">change_encoding</code> is called from the parser after the
 analysis of case (2) has been done; the argument is either the
 string name of the encoding, or the empty string to indicate
 that no XML declaration was found. It is guaranteed that
 <code class="code">change_encoding</code> is invoked after only a few tokens of the
 file. The resolver should react as follows:<ul>
<li>If case (1) applies:   Ignore the encoding passed to <code class="code">change_encoding</code>.</li>
<li>If case (2.1) applies: The encoding passed to <code class="code">change_encoding</code> must
                          be compatible with UTF-16. This should be
                          checked, and violations should be reported.</li>
<li>Else:                  If the passed encoding is "", assume UTF-8.
                          Otherwise, assume the passed encoding.</li>
</ul>

 The following rule helps synchronizing the lexbuf with the encoding:
 If the resolver has been opened, but <code class="code">change_encoding</code> has not yet
 been invoked, the lexbuf contains at most one character (which may
 be represented by multiple bytes); i.e. the lexbuf is created by
 <code class="code"><span class="constructor">Lexing</span>.from_function</code>, and the function puts only one character into
 the buffer at once.
 After <code class="code">change_encoding</code> has been invoked, there is no longer a limit
 on the lexbuf size.
<p>

 The reason for this rule is that you know exactly the character where
 the encoding changes to the encoding passed by <code class="code">change_encoding</code>.
<p>

 The method <code class="code">clone</code> may be invoked for open or closed resolvers.
 Basically, <code class="code">clone</code> returns a new resolver which is always closed.
 If the original resolver is already closed, the clone is simply a clone.
 If the original resolver is open at the moment of cloning, this applies:
 If the clone is later opened for a relative system ID (i.e. relative
 URL), the clone must interpret this ID relative to the ID of the
 original resolver.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODinit_warner"></a>init_warner : <code class="type"><a href="Pxp_types.html#TYPEsymbolic_warnings">Pxp_types.symbolic_warnings</a> option -><br>       <a href="Pxp_types.html#TYPEcollect_warnings">Pxp_types.collect_warnings</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODrep_encoding"></a>rep_encoding : <code class="type"><a href="Pxp_types.html#TYPErep_encoding">Pxp_types.rep_encoding</a></code></pre><div class="info">
Return the representation encoding, as set by <code class="code">init_rep_encoding</code><br>
</div>
<pre><span class="keyword">method</span> <a name="METHODopen_in"></a>open_in : <code class="type"><a href="Pxp_types.html#TYPEext_id">Pxp_types.ext_id</a> -> <a href="Pxp_reader.html#TYPElexer_source">lexer_source</a></code></pre><div class="info">
This is the old method to open a resolver. It is superseded by
 <code class="code">open_rid</code>.
 This method may raise <code class="code"><span class="constructor">Not_competent</span></code> if the object does not know
 how to handle this <code class="code">ext_id</code>.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODopen_rid"></a>open_rid : <code class="type"><a href="Pxp_types.html#TYPEresolver_id">Pxp_types.resolver_id</a> -> <a href="Pxp_reader.html#TYPElexer_source">lexer_source</a></code></pre><div class="info">
This is the new method to open a resolver. It takes a resolver ID
 instead of an <code class="code">ext_id</code> but works in the same way.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODclose_in"></a>close_in : <code class="type">unit</code></pre><div class="info">
Closes the resolver<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODchange_encoding"></a>change_encoding : <code class="type">string -> unit</code></pre><div class="info">
Changes the external encoding. See above for details<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODclone"></a>clone : <code class="type"><a href="Pxp_reader.resolver.html">resolver</a></code></pre><div class="info">
Every resolver can be cloned. The clone does not inherit the connection
 with the external object, i.e. it is initially closed.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODactive_id"></a>active_id : <code class="type"><a href="Pxp_types.html#TYPEresolver_id">Pxp_types.resolver_id</a></code></pre><div class="info">
Returns the actually used resolver ID. This is the ID passed to
 <code class="code">open_rid</code> where unused components have been set to None. The
 resolver ID returned by <code class="code">active_id</code> plays an important role when
 expanding relative URLs.<br>
</div>
</body></html>