Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 94e13c00c3445b8058b0a613635adf88 > files > 17

ocaml-xml-light-devel-2.2.cvs20070817-16.fc15.i686.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="previous" href="Dtd.html">
<link rel="next" href="XmlParser.html">
<link rel="Up" href="index.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 modules" rel=Appendix href="index_modules.html">
<link title="Dtd" rel="Chapter" href="Dtd.html">
<link title="Xml" rel="Chapter" href="Xml.html">
<link title="XmlParser" rel="Chapter" href="XmlParser.html"><link title="Xml Data Structure" rel="Section" href="#6_XmlDataStructure">
<link title="Xml Parsing" rel="Section" href="#6_XmlParsing">
<link title="Xml Exceptions" rel="Section" href="#exc">
<link title="Xml Functions" rel="Section" href="#6_XmlFunctions">
<link title="Xml Printing" rel="Section" href="#6_XmlPrinting">
<title>Xml</title>
</head>
<body>
<div class="navbar"><a href="Dtd.html">Previous</a>
&nbsp;<a href="index.html">Up</a>
&nbsp;<a href="XmlParser.html">Next</a>
</div>
<center><h1>Module <a href="type_Xml.html">Xml</a></h1></center>
<br>
<pre><span class="keyword">module</span> Xml: <code class="code">sig</code> <a href="Xml.html">..</a> <code class="code">end</code></pre>Xml Light
<p>

  Xml Light is a minimal Xml parser &amp; printer for OCaml.
  It provide few functions to parse a basic Xml document into
  an OCaml data structure and to print back the data structures
  to an Xml document.
<p>

  Xml Light has also support for <b>DTD</b> (Document Type Definition).
<p>

  <i>(c)Copyright 2002-2003 Nicolas Cannasse</i><br>
<hr width="100%">
<br>
<span id="6_XmlDataStructure"><h6>Xml Data Structure</h6></span><br>
<br><code><span id="TYPExml"><span class="keyword">type</span> <code class="type"></code>xml</span> = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Element</span> <span class="keyword">of</span> <code class="type">(string * (string * string) list * <a href="Xml.html#TYPExml">xml</a> list)</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">PCData</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr></table>

<div class="info">
An Xml node is either
	<code class="code">Element (tag-name, attributes, children)</code> or <code class="code">PCData text</code><br>
</div>

<br>
<span id="6_XmlParsing"><h6>Xml Parsing</h6></span><br>
<br>
For easily parsing an Xml data source into an xml data structure,
	you can use theses functions. But if you want advanced parsing usage,
	please look at the <a href="XmlParser.html"><code class="code">XmlParser</code></a> module.
	All the parsing functions can raise some exceptions, see the
	<a href="#exc">Exceptions</a> section for more informations.<br>
<pre><span id="VALparse_file"><span class="keyword">val</span> parse_file</span> : <code class="type">string -> <a href="Xml.html#TYPExml">xml</a></code></pre><div class="info">
Parse the named file into an Xml data structure.<br>
</div>
<pre><span id="VALparse_in"><span class="keyword">val</span> parse_in</span> : <code class="type">Pervasives.in_channel -> <a href="Xml.html#TYPExml">xml</a></code></pre><div class="info">
Read the content of the in_channel and parse it into an Xml data
 structure.<br>
</div>
<pre><span id="VALparse_string"><span class="keyword">val</span> parse_string</span> : <code class="type">string -> <a href="Xml.html#TYPExml">xml</a></code></pre><div class="info">
Parse the string containing an Xml document into an Xml data
 structure.<br>
</div>
<br>
<span id="exc"><h6>Xml Exceptions</h6></span><br>
<br>
Several exceptions can be raised when parsing an Xml document : <ul>
<li><a href="Xml.html#EXCEPTIONError"><code class="code">Xml.Error</code></a> is raised when an xml parsing error occurs. the
		<a href="Xml.html#VALerror_msg"><code class="code">Xml.error_msg</code></a> tells you which error occured during parsing
		and the <a href="Xml.html#TYPEerror_pos"><code class="code">Xml.error_pos</code></a> can be used to retreive the document
		location where the error occured at.</li>
<li><a href="Xml.html#EXCEPTIONFile_not_found"><code class="code">Xml.File_not_found</code></a> is raised when and error occured while
		opening a file with the <a href="Xml.html#VALparse_file"><code class="code">Xml.parse_file</code></a> function or when a
		DTD file declared by the Xml document is not found <i>(see the
		<a href="XmlParser.html"><code class="code">XmlParser</code></a> module for more informations on how to handle the
		DTD file loading)</i>.</li>
</ul>

	If the Xml document is containing a DTD, then some other exceptions
	can be raised, see the module <a href="Dtd.html"><code class="code">Dtd</code></a> for more informations.<br>
<pre><span id="TYPEerror_pos"><span class="keyword">type</span> <code class="type"></code>error_pos</span> </pre>

<br><code><span id="TYPEerror_msg"><span class="keyword">type</span> <code class="type"></code>error_msg</span> = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">UnterminatedComment</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">UnterminatedString</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">UnterminatedEntity</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">IdentExpected</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">CloseExpected</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">NodeExpected</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">AttributeNameExpected</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">AttributeValueExpected</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">EndOfTagExpected</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">EOFExpected</span></code></td>

</tr></table>


<pre><span id="TYPEerror"><span class="keyword">type</span> <code class="type"></code>error</span> = <code class="type"><a href="Xml.html#TYPEerror_msg">error_msg</a> * <a href="Xml.html#TYPEerror_pos">error_pos</a></code> </pre>

<pre><span id="EXCEPTIONError"><span class="keyword">exception</span> Error</span> <span class="keyword">of</span> <code class="type"><a href="Xml.html#TYPEerror">error</a></code></pre>
<pre><span id="EXCEPTIONFile_not_found"><span class="keyword">exception</span> File_not_found</span> <span class="keyword">of</span> <code class="type">string</code></pre>
<pre><span id="VALerror"><span class="keyword">val</span> error</span> : <code class="type"><a href="Xml.html#TYPEerror">error</a> -> string</code></pre><div class="info">
Get a full error message from an Xml error.<br>
</div>
<pre><span id="VALerror_msg"><span class="keyword">val</span> error_msg</span> : <code class="type"><a href="Xml.html#TYPEerror_msg">error_msg</a> -> string</code></pre><div class="info">
Get the Xml error message as a string.<br>
</div>
<pre><span id="VALline"><span class="keyword">val</span> line</span> : <code class="type"><a href="Xml.html#TYPEerror_pos">error_pos</a> -> int</code></pre><div class="info">
Get the line the error occured at.<br>
</div>
<pre><span id="VALrange"><span class="keyword">val</span> range</span> : <code class="type"><a href="Xml.html#TYPEerror_pos">error_pos</a> -> int * int</code></pre><div class="info">
Get the relative character range (in current line) the error occured at.<br>
</div>
<pre><span id="VALabs_range"><span class="keyword">val</span> abs_range</span> : <code class="type"><a href="Xml.html#TYPEerror_pos">error_pos</a> -> int * int</code></pre><div class="info">
Get the absolute character range the error occured at.<br>
</div>
<br>
<span id="6_XmlFunctions"><h6>Xml Functions</h6></span><br>
<pre><span id="EXCEPTIONNot_element"><span class="keyword">exception</span> Not_element</span> <span class="keyword">of</span> <code class="type"><a href="Xml.html#TYPExml">xml</a></code></pre>
<pre><span id="EXCEPTIONNot_pcdata"><span class="keyword">exception</span> Not_pcdata</span> <span class="keyword">of</span> <code class="type"><a href="Xml.html#TYPExml">xml</a></code></pre>
<pre><span id="EXCEPTIONNo_attribute"><span class="keyword">exception</span> No_attribute</span> <span class="keyword">of</span> <code class="type">string</code></pre>
<pre><span id="VALtag"><span class="keyword">val</span> tag</span> : <code class="type"><a href="Xml.html#TYPExml">xml</a> -> string</code></pre><div class="info">
<code class="code">tag xdata</code> returns the tag value of the xml node.
 Raise <a href="Xml.html#EXCEPTIONNot_element"><code class="code">Xml.Not_element</code></a> if the xml is not an element<br>
</div>
<pre><span id="VALpcdata"><span class="keyword">val</span> pcdata</span> : <code class="type"><a href="Xml.html#TYPExml">xml</a> -> string</code></pre><div class="info">
<code class="code">pcdata xdata</code> returns the PCData value of the xml node.
 Raise <a href="Xml.html#EXCEPTIONNot_pcdata"><code class="code">Xml.Not_pcdata</code></a> if the xml is not a PCData<br>
</div>
<pre><span id="VALattribs"><span class="keyword">val</span> attribs</span> : <code class="type"><a href="Xml.html#TYPExml">xml</a> -> (string * string) list</code></pre><div class="info">
<code class="code">attribs xdata</code> returns the attribute list of the xml node.
 First string if the attribute name, second string is attribute value.
 Raise <a href="Xml.html#EXCEPTIONNot_element"><code class="code">Xml.Not_element</code></a> if the xml is not an element<br>
</div>
<pre><span id="VALattrib"><span class="keyword">val</span> attrib</span> : <code class="type"><a href="Xml.html#TYPExml">xml</a> -> string -> string</code></pre><div class="info">
<code class="code">attrib xdata "href"</code> returns the value of the <code class="code">"href"</code>
 attribute of the xml node (attribute matching is case-insensitive).
 Raise <a href="Xml.html#EXCEPTIONNo_attribute"><code class="code">Xml.No_attribute</code></a> if the attribute does not exists in the node's
 attribute list 
 Raise <a href="Xml.html#EXCEPTIONNot_element"><code class="code">Xml.Not_element</code></a> if the xml is not an element<br>
</div>
<pre><span id="VALchildren"><span class="keyword">val</span> children</span> : <code class="type"><a href="Xml.html#TYPExml">xml</a> -> <a href="Xml.html#TYPExml">xml</a> list</code></pre><div class="info">
<code class="code">children xdata</code> returns the children list of the xml node
 Raise <a href="Xml.html#EXCEPTIONNot_element"><code class="code">Xml.Not_element</code></a> if the xml is not an element<br>
</div>
<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">(<a href="Xml.html#TYPExml">xml</a> -> unit) -> <a href="Xml.html#TYPExml">xml</a> -> unit</code></pre><div class="info">
<code class="code">iter f xdata</code> calls f on all children of the xml node.
 Raise <a href="Xml.html#EXCEPTIONNot_element"><code class="code">Xml.Not_element</code></a> if the xml is not an element<br>
</div>
<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">(<a href="Xml.html#TYPExml">xml</a> -> 'a) -> <a href="Xml.html#TYPExml">xml</a> -> 'a list</code></pre><div class="info">
<code class="code">map f xdata</code> is equivalent to <code class="code">List.map f (Xml.children xdata)</code>
 Raise <a href="Xml.html#EXCEPTIONNot_element"><code class="code">Xml.Not_element</code></a> if the xml is not an element<br>
</div>
<pre><span id="VALfold"><span class="keyword">val</span> fold</span> : <code class="type">('a -> <a href="Xml.html#TYPExml">xml</a> -> 'a) -> 'a -> <a href="Xml.html#TYPExml">xml</a> -> 'a</code></pre><div class="info">
<code class="code">fold f init xdata</code> is equivalent to
 <code class="code">List.fold_left f init (Xml.children xdata)</code>
 Raise <a href="Xml.html#EXCEPTIONNot_element"><code class="code">Xml.Not_element</code></a> if the xml is not an element<br>
</div>
<br>
<span id="6_XmlPrinting"><h6>Xml Printing</h6></span><br>
<pre><span id="VALto_string"><span class="keyword">val</span> to_string</span> : <code class="type"><a href="Xml.html#TYPExml">xml</a> -> string</code></pre><div class="info">
Print the xml data structure into a compact xml string (without
 any user-readable formating ).<br>
</div>
<pre><span id="VALto_string_fmt"><span class="keyword">val</span> to_string_fmt</span> : <code class="type"><a href="Xml.html#TYPExml">xml</a> -> string</code></pre><div class="info">
Print the xml data structure into an user-readable string with
 tabs and lines break between different nodes.<br>
</div>
</body></html>