Commit 1e42fca1 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-21 22:09:48 by cvscast] Manual

Original author: cvscast
Date: 2003-05-21 22:09:49+00:00
parent 6a3e3df5
...@@ -16,11 +16,9 @@ ...@@ -16,11 +16,9 @@
<external href="/cgi-bin/cduce" title="Online demo" name="proto"/> <external href="/cgi-bin/cduce" title="Online demo" name="proto"/>
<include file="bench.xml"/> <include file="bench.xml"/>
<include file="memento.xml"/>
<include file="papers.xml"/> <include file="papers.xml"/>
<include file="examples.xml"/> <include file="examples.xml"/>
<include file="team.xml"/> <include file="team.xml"/>
<include file="tutorial.xml"/>
<include file="manual.xml"/> <include file="manual.xml"/>
<include file="sitemap.xml"/> <include file="sitemap.xml"/>
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page name="manual"> <page name="manual">
<title>CDuce user's manual</title> <title>User's manual</title>
<include file="tutorial.xml"/>
<include file="memento.xml"/>
<include file="manual/types_patterns.xml"/> <include file="manual/types_patterns.xml"/>
<include file="manual/expressions.xml"/> <include file="manual/expressions.xml"/>
<box title="Table of Contents" link="toc"> <box title="Table of Contents" link="toc">
<p><b>This manual is under construction !</b></p> <p><b>This manual is under construction !</b></p>
<p>Sections:</p> <p>Sections:</p>
......
...@@ -400,6 +400,44 @@ better localization in the program, and more informative messages. ...@@ -400,6 +400,44 @@ better localization in the program, and more informative messages.
<box title="XML-specific constructions" link="xml"> <box title="XML-specific constructions" link="xml">
<section title="Loading XML documents">
<p>
The <code>load_xml</code> operator parse an XML document on the local
file system; the argument gives the filename:</p>
<sample><![CDATA[
load_xml %%e%%
]]></sample>
</section>
<section title="Pretty-printing XML documents">
<p>
Two operators can be used to produce a string from an XML document:
</p>
<sample><![CDATA[
print_xml %%e%%
print_xml_utf8 %%e%%
]]></sample>
<p>
They fail if the argument is not an XML document (this isn't checked
statically). The first operator
<code>print_xml</code> prepares the document to be dumped to
a ISO-8859-1 encoded XML file: Unicode characters outside Latin1
are escaped accordingly, and the operator fails if the document
contains tag or attribute names which cannot be represented
in ISO-8859-1. The second operator <code>print_xml_utf8</code>
always succeed but produces a string suitable for being dumped
in an UTF-8 encoded file. See the variants of the
<code>dump_to_file</code> operator
in the section on <a href="#io">Input/output</a>.
</p>
<p>
In both cases, the resulting string does <em>not</em> contain
the XML prefix "&lt;?xml ...>".
</p>
</section>
<section title="Projection">
<p> <p>
The projection takes a sequence of XML elements and returns The projection takes a sequence of XML elements and returns
the concatenation of all their children with a given type. the concatenation of all their children with a given type.
...@@ -425,6 +463,10 @@ evaluates to ...@@ -425,6 +463,10 @@ evaluates to
]]></code>. ]]></code>.
</p> </p>
</section>
<section title="Iteration over XML trees">
<p> <p>
Another XML-specific construction is <code>xtransform</code> Another XML-specific construction is <code>xtransform</code>
which is a generalization of <code>transform</code> to XML trees: which is a generalization of <code>transform</code> to XML trees:
...@@ -442,6 +484,46 @@ is applied recursively to its content. Elements in the input sequence ...@@ -442,6 +484,46 @@ is applied recursively to its content. Elements in the input sequence
which are not matched and are not XML elements are copied verbatim. which are not matched and are not XML elements are copied verbatim.
</p> </p>
</section>
</box>
<box title="Input-output" link="io">
<section title="Loading files">
<p>
There are two operators available to load a file into a CDuce string:
</p>
<sample><![CDATA[
load_file %%e%%
load_file_utf8 %%e%%
]]></sample>
<p>
The first one loads an ISO-8859-1 encoded file, whereas the second
one loads a UTF-8 encoded file.
</p>
</section>
<section title="Dumping to files">
<p>
There are two operators available to dump a CDuce string to a file:
</p>
<sample><![CDATA[
dump_to_file %%e1%% %%e2%%
load_file_utf8 %%e1%% %%e2%%
]]></sample>
<p>
The first one creates an ISO-8859-1 encoded file (it fails
when the CDuce string contains non Latin1 characters), whereas the second
one creates a UTF-8 encoded file. In both cases, the first
argument is the filename and the second one is the string to dump.
</p>
</section>
</box> </box>
</page> </page>
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page name="memento"> <page name="memento">
<title>CDuce memento</title> <title>Memento</title>
<left> <left>
<p>This page briefly presents the syntax of the CDuce language.</p> <p>This page briefly presents the syntax of the CDuce language.</p>
...@@ -50,7 +50,7 @@ _" character, starting by a capitalized letter or underscore.</li> ...@@ -50,7 +50,7 @@ _" character, starting by a capitalized letter or underscore.</li>
<box title="Operators" link="op"> <box title="Operators" link="op">
<ul> <ul>
<li>Infix: <li>Infix:
<br/> <code>@</code> : String,String -> String <br/> <code>@</code> : concatenation of sequences
<br/> <code>+,*,-,div,mod</code> : Integer,Integer -> Integer <br/> <code>+,*,-,div,mod</code> : Integer,Integer -> Integer
<br/> <code>=, &lt;&lt;, &lt;=, &gt;&gt;, &gt;= </code> : <br/> <code>=, &lt;&lt;, &lt;=, &gt;&gt;, &gt;= </code> :
Integer,Integer -> Bool = <code>`true | `false</code> Integer,Integer -> Bool = <code>`true | `false</code>
...@@ -63,9 +63,6 @@ Integer,Integer -> Bool = <code>`true | `false</code> ...@@ -63,9 +63,6 @@ Integer,Integer -> Bool = <code>`true | `false</code>
<br/><code>int_of</code> : [('0'--'9')+] -> Integer <br/><code>int_of</code> : [('0'--'9')+] -> Integer
<br/><code>string_of</code> : Integer -> String <br/><code>string_of</code> : Integer -> String
</li> </li>
<li>Postfix:
<br/><code>?,*,+,??,*?,+?</code> : for regexp
</li>
</ul> </ul>
</box> </box>
......
...@@ -70,7 +70,7 @@ let fun load_include (String -> [Any*]) ...@@ -70,7 +70,7 @@ let fun load_include (String -> [Any*])
(* let _ = print [ 'Loading ' !name '... \n' ] in *) (* let _ = print [ 'Loading ' !name '... \n' ] in *)
xtransform [ (load_xml name) ] with xtransform [ (load_xml name) ] with
| <include file=(s & String)>[] -> load_include s | <include file=(s & String)>[] -> load_include s
| <include-verbatim file=(s & String)>[] -> let [] = print s in load_file s;; | <include-verbatim file=(s & String)>[] -> load_file s;;
(* Highlighting text between {{...}} *) (* Highlighting text between {{...}} *)
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page name="tutorial"> <page name="tutorial">
<title>CDuce tutorial</title> <title>Tutorial</title>
<include file="tutorial/getting_started.xml"/> <include file="tutorial/getting_started.xml"/>
......
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