Commit 56590afb authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-07-04 09:39:28 by afrisch] Doc

Original author: afrisch
Date: 2004-07-04 09:39:29+00:00
parent 3e1738e3
......@@ -111,11 +111,18 @@ let exn_not_found =
let eval_load_file ~utf8 e =
Location.protect_op "load_file";
let ic = open_in (Value.get_string_latin1 e) in
let fn = Value.get_string_latin1 e in
let s = match Url.process fn with
| Url.Filename fn ->
let ic = open_in fn in
let len = in_channel_length ic in
let s = String.create len in
really_input ic s 0 len;
close_in ic;
s
| Url.Url txt ->
txt
in
if utf8 then
match U.mk_check s with
| Some s -> Value.string_utf8 s
......@@ -230,13 +237,6 @@ unary_op_warning "int_of"
try Value.Integer (Intervals.V.mk (U.get_str s)) (* UTF-8 is ASCII compatible ! *)
with Failure _ -> raise exn_int_of);;
unary_op_cst "float_of"
string float
(fun v ->
let (s,_) = Value.get_string_utf8 v in
try Value.Abstract (float_abs, Obj.repr (float_of_string (U.get_str s)))
with Failure _ -> raise exn_int_of);;
unary_op_cst "atom_of"
string atom
(fun v ->
......
......@@ -446,6 +446,18 @@ file system; the argument gives the filename:</p>
<sample><![CDATA[
load_xml %%e%%
]]></sample>
<p>
If the support for netclient or curl is available, it is also
possible to fetch an XML file from an URL, e.g.:
<code>load_xml "http://..."</code>.
</p>
<p>
There is also a <code>load_html</code> operator to parse in a
permissive way HTML documents. The result has type <code>[Any*]</code>.
</p>
</section>
<section title="Pretty-printing XML documents">
......@@ -596,6 +608,11 @@ The first one loads an ISO-8859-1 encoded file (resulting type:
whereas the second
one loads a UTF-8 encoded file (resulting type: <code>String</code>).
</p>
<p>
If the support for netclient or curl is available, it is also
possible to fetch a file from an URL, e.g.:
<code>load_file "http://..."</code>.
</p>
</section>
......
......@@ -59,12 +59,19 @@ _" character, starting by a capitalized letter or underscore.</li>
<br/> <code>not</code>: Bool -> Bool
</li>
<li>Prefix:
<br/><code>load_xml,load_html</code> : String -> Any,
<br/><code>dump_to_file</code> : String -> String -> Any,
<br/><code>print_xml</code> : Any -> String
<br/><code>print</code> : String -> []
<br/><code>int_of</code> : ['-'? ('0'--'9')+] -> Integer
<br/><code>string_of</code> : Any -> Latin1
<br/><code>load_xml</code> : String -> Any,
<br/><code>load_html</code> : String -> [ Any* ],
<br/><code>load_file</code> : String -> Latin1,
<br/><code>load_file_utf8</code> : String -> String,
<br/><code>argv</code> : [] -> [ String* ],
<br/><code>dump_to_file</code> : String -> String -> [],
<br/><code>dump_to_file_utf8</code> : String -> String -> [],
<br/><code>print_xml</code> : Any -> Latin1,
<br/><code>print_xml_utf8</code> : Any -> String,
<br/><code>print</code> : String -> [],
<br/><code>int_of</code> : String -> Integer,
<br/><code>string_of</code> : Any -> Latin1,
<br/><code>atom_of</code> : String -> Atom
</li>
</ul>
</box>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment