<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- xmerl_scan</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/xmerl-1.2.4.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>xmerl</strong><br><strong>Reference Manual</strong><br><small>Version 1.2.4</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p> <ul class="flipMenu"> <li id="loadscrollpos" title="xmerl_scan " expanded="true">xmerl_scan<ul> <li><a href="xmerl_scan.html"> Top of manual page </a></li> <li title="accumulate_whitespace-4"><a href="xmerl_scan.html#accumulate_whitespace-4">accumulate_whitespace/4</a></li> <li title="cont_state-1"><a href="xmerl_scan.html#cont_state-1">cont_state/1</a></li> <li title="cont_state-2"><a href="xmerl_scan.html#cont_state-2">cont_state/2</a></li> <li title="event_state-1"><a href="xmerl_scan.html#event_state-1">event_state/1</a></li> <li title="event_state-2"><a href="xmerl_scan.html#event_state-2">event_state/2</a></li> <li title="fetch_state-1"><a href="xmerl_scan.html#fetch_state-1">fetch_state/1</a></li> <li title="fetch_state-2"><a href="xmerl_scan.html#fetch_state-2">fetch_state/2</a></li> <li title="file-1"><a href="xmerl_scan.html#file-1">file/1</a></li> <li title="file-2"><a href="xmerl_scan.html#file-2">file/2</a></li> <li title="hook_state-1"><a href="xmerl_scan.html#hook_state-1">hook_state/1</a></li> <li title="hook_state-2"><a href="xmerl_scan.html#hook_state-2">hook_state/2</a></li> <li title="rules_state-1"><a href="xmerl_scan.html#rules_state-1">rules_state/1</a></li> <li title="rules_state-2"><a href="xmerl_scan.html#rules_state-2">rules_state/2</a></li> <li title="string-1"><a href="xmerl_scan.html#string-1">string/1</a></li> <li title="string-2"><a href="xmerl_scan.html#string-2">string/2</a></li> <li title="user_state-1"><a href="xmerl_scan.html#user_state-1">user_state/1</a></li> <li title="user_state-2"><a href="xmerl_scan.html#user_state-2">user_state/2</a></li> </ul> </li> <li id="no" title="xmerl " expanded="false">xmerl<ul> <li><a href="xmerl.html"> Top of manual page </a></li> <li title="callbacks-1"><a href="xmerl.html#callbacks-1">callbacks/1</a></li> <li title="export-2"><a href="xmerl.html#export-2">export/2</a></li> <li title="export-3"><a href="xmerl.html#export-3">export/3</a></li> <li title="export_content-2"><a href="xmerl.html#export_content-2">export_content/2</a></li> <li title="export_element-2"><a href="xmerl.html#export_element-2">export_element/2</a></li> <li title="export_element-3"><a href="xmerl.html#export_element-3">export_element/3</a></li> <li title="export_simple-2"><a href="xmerl.html#export_simple-2">export_simple/2</a></li> <li title="export_simple-3"><a href="xmerl.html#export_simple-3">export_simple/3</a></li> <li title="export_simple_content-2"><a href="xmerl.html#export_simple_content-2">export_simple_content/2</a></li> <li title="export_simple_element-2"><a href="xmerl.html#export_simple_element-2">export_simple_element/2</a></li> </ul> </li> <li id="no" title="xmerl_xs " expanded="false">xmerl_xs<ul> <li><a href="xmerl_xs.html"> Top of manual page </a></li> <li title="built_in_rules-2"><a href="xmerl_xs.html#built_in_rules-2">built_in_rules/2</a></li> <li title="select-2"><a href="xmerl_xs.html#select-2">select/2</a></li> <li title="value_of-1"><a href="xmerl_xs.html#value_of-1">value_of/1</a></li> <li title="xslapply-2"><a href="xmerl_xs.html#xslapply-2">xslapply/2</a></li> </ul> </li> <li id="no" title="xmerl_eventp " expanded="false">xmerl_eventp<ul> <li><a href="xmerl_eventp.html"> Top of manual page </a></li> <li title="file_sax-4"><a href="xmerl_eventp.html#file_sax-4">file_sax/4</a></li> <li title="stream-2"><a href="xmerl_eventp.html#stream-2">stream/2</a></li> <li title="stream_sax-4"><a href="xmerl_eventp.html#stream_sax-4">stream_sax/4</a></li> <li title="string_sax-4"><a href="xmerl_eventp.html#string_sax-4">string_sax/4</a></li> </ul> </li> <li id="no" title="xmerl_xpath " expanded="false">xmerl_xpath<ul> <li><a href="xmerl_xpath.html"> Top of manual page </a></li> <li title="string-2"><a href="xmerl_xpath.html#string-2">string/2</a></li> <li title="string-3"><a href="xmerl_xpath.html#string-3">string/3</a></li> <li title="string-5"><a href="xmerl_xpath.html#string-5">string/5</a></li> </ul> </li> <li id="no" title="xmerl_xsd " expanded="false">xmerl_xsd<ul> <li><a href="xmerl_xsd.html"> Top of manual page </a></li> <li title="file2state-1"><a href="xmerl_xsd.html#file2state-1">file2state/1</a></li> <li title="format_error-1"><a href="xmerl_xsd.html#format_error-1">format_error/1</a></li> <li title="process_schema-1"><a href="xmerl_xsd.html#process_schema-1">process_schema/1</a></li> <li title="process_schema-2"><a href="xmerl_xsd.html#process_schema-2">process_schema/2</a></li> <li title="process_schemas-1"><a href="xmerl_xsd.html#process_schemas-1">process_schemas/1</a></li> <li title="process_schemas-2"><a href="xmerl_xsd.html#process_schemas-2">process_schemas/2</a></li> <li title="process_validate-2"><a href="xmerl_xsd.html#process_validate-2">process_validate/2</a></li> <li title="process_validate-3"><a href="xmerl_xsd.html#process_validate-3">process_validate/3</a></li> <li title="state2file-1"><a href="xmerl_xsd.html#state2file-1">state2file/1</a></li> <li title="state2file-2"><a href="xmerl_xsd.html#state2file-2">state2file/2</a></li> <li title="validate-2"><a href="xmerl_xsd.html#validate-2">validate/2</a></li> <li title="validate-3"><a href="xmerl_xsd.html#validate-3">validate/3</a></li> </ul> </li> <li id="no" title="xmerl_sax_parser " expanded="false">xmerl_sax_parser<ul> <li><a href="xmerl_sax_parser.html"> Top of manual page </a></li> <li title="file-2"><a href="xmerl_sax_parser.html#file-2">file/2</a></li> <li title="stream-2"><a href="xmerl_sax_parser.html#stream-2">stream/2</a></li> <li title="ContinuationFun-1"><a href="xmerl_sax_parser.html#ContinuationFun-1">ContinuationFun/1</a></li> <li title="EventFun-3"><a href="xmerl_sax_parser.html#EventFun-3">EventFun/3</a></li> </ul> </li> </ul> </div></div> <div id="content"> <div class="innertube"> <!-- refpage --><center><h1>xmerl_scan</h1></center> <h3>MODULE</h3> <div class="REFBODY">xmerl_scan</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">This module is the interface to the XML parser, it handles XML 1.0.</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p>This module is the interface to the XML parser, it handles XML 1.0. The XML parser is activated through <span class="code">xmerl_scan:string/[1,2]</span> or <span class="code">xmerl_scan:file/[1,2]</span>. It returns records of the type defined in xmerl.hrl. See also <span class="bold_code"><a href="xmerl_examples.html">tutorial</a></span> on customization functions.</p></p></div> <h3><a name="id2263313">DATA TYPES</a></h3> <div class="REFBODY"> <a name="types"></a> <dl> <dt><strong><span class="code">global_state()</span></strong></dt> <dd> <a name="type-global_state"></a> <p> The global state of the scanner, represented by the #xmerl_scanner{} record. </p> </dd> <dt><strong><span class="code">option_list()</span></strong></dt> <dd> <a name="type-option_list"></a> <p>Options allow to customize the behaviour of the scanner. See also <span class="bold_code"><a href="xmerl_examples.html">tutorial</a></span> on customization functions. </p> Possible options are: <dl> <dt><strong><span class="code">{acc_fun, Fun}</span></strong></dt> <dd><p>Call back function to accumulate contents of entity.</p></dd> <dt><strong><span class="code">{continuation_fun, Fun} | {continuation_fun, Fun, ContinuationState}</span></strong></dt> <dd><p>Call back function to decide what to do if the scanner runs into EOF before the document is complete.</p></dd> <dt><strong><span class="code">{event_fun, Fun} | {event_fun, Fun, EventState}</span></strong></dt> <dd><p>Call back function to handle scanner events.</p></dd> <dt><strong><span class="code">{fetch_fun, Fun} | {fetch_fun, Fun, FetchState}</span></strong></dt> <dd><p>Call back function to fetch an external resource.</p></dd> <dt><strong><span class="code">{hook_fun, Fun} | {hook_fun, Fun, HookState}</span></strong></dt> <dd><p>Call back function to process the document entities once identified.</p></dd> <dt><strong><span class="code">{close_fun, Fun}</span></strong></dt> <dd><p>Called when document has been completely parsed.</p></dd> <dt><strong><span class="code">{rules, ReadFun, WriteFun, RulesState} | {rules, Rules}</span></strong></dt> <dd><p>Handles storing of scanner information when parsing.</p></dd> <dt><strong><span class="code">{user_state, UserState}</span></strong></dt> <dd><p>Global state variable accessible from all customization functions</p></dd> <dt><strong><span class="code">{fetch_path, PathList}</span></strong></dt> <dd><p>PathList is a list of directories to search when fetching files. If the file in question is not in the fetch_path, the URI will be used as a file name.</p></dd> <dt><strong><span class="code">{space, Flag}</span></strong></dt> <dd><p>'preserve' (default) to preserve spaces, 'normalize' to accumulate consecutive whitespace and replace it with one space.</p></dd> <dt><strong><span class="code">{line, Line}</span></strong></dt> <dd><p>To specify starting line for scanning in document which contains fragments of XML.</p></dd> <dt><strong><span class="code">{namespace_conformant, Flag}</span></strong></dt> <dd><p>Controls whether to behave as a namespace conformant XML parser, 'false' (default) to not otherwise 'true'.</p></dd> <dt><strong><span class="code">{validation, Flag}</span></strong></dt> <dd><p>Controls whether to process as a validating XML parser: 'off' (default) no validation, or validation 'dtd' by DTD or 'schema' by XML Schema. 'false' and 'true' options are obsolete (i.e. they may be removed in a future release), if used 'false' equals 'off' and 'true' equals 'dtd'.</p></dd> <dt><strong><span class="code">{schemaLocation, [{Namespace,Link}|...]}</span></strong></dt> <dd><p>Tells explicitly which XML Schema documents to use to validate the XML document. Used together with the <span class="code">{validation,schema}</span> option.</p></dd> <dt><strong><span class="code">{quiet, Flag}</span></strong></dt> <dd><p>Set to 'true' if xmerl should behave quietly and not output any information to standard output (default 'false').</p></dd> <dt><strong><span class="code">{doctype_DTD, DTD}</span></strong></dt> <dd><p>Allows to specify DTD name when it isn't available in the XML document. This option has effect only together with <span class="code">{validation,'dtd'</span> option.</p></dd> <dt><strong><span class="code">{xmlbase, Dir}</span></strong></dt> <dd><p>XML Base directory. If using string/1 default is current directory. If using file/1 default is directory of given file.</p></dd> <dt><strong><span class="code">{encoding, Enc}</span></strong></dt> <dd><p>Set default character set used (default UTF-8). This character set is used only if not explicitly given by the XML declaration. </p></dd> </dl> </dd> </dl> </div> <h3>EXPORTS</h3> <p><a name="accumulate_whitespace-4"><span class="bold_code">accumulate_whitespace(T::string(), S::global_state(), X3::atom(), Acc::string()) -> {Acc, T1, S1}</span></a><br></p> <div class="REFBODY"><p><a name="accumulate_whitespace-4"></a> <p>Function to accumulate and normalize whitespace.</p> </p></div> <p><a name="cont_state-1"><span class="bold_code">cont_state(S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="cont_state-1"></a> <p>Equivalent to <span class="bold_code"><a href="#cont_state-2">cont_state(ContinuationState, S)</a></span>.</p> </p></div> <p><a name="cont_state-2"><span class="bold_code">cont_state(X::ContinuationState, S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="cont_state-2"></a> <p>For controlling the ContinuationState, to be used in a continuation function, and called when the parser encounters the end of the byte stream. See <span class="bold_code"><a href="xmerl_examples.html">tutorial</a></span> on customization functions.</p> </p></div> <p><a name="event_state-1"><span class="bold_code">event_state(S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="event_state-1"></a> <p>Equivalent to <span class="bold_code"><a href="#event_state-2">event_state(EventState, S)</a></span>.</p> </p></div> <p><a name="event_state-2"><span class="bold_code">event_state(X::EventState, S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="event_state-2"></a> <p>For controlling the EventState, to be used in an event function, and called at the beginning and at the end of a parsed entity. See <span class="bold_code"><a href="xmerl_examples.html">tutorial</a></span> on customization functions.</p> </p></div> <p><a name="fetch_state-1"><span class="bold_code">fetch_state(S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="fetch_state-1"></a> <p>Equivalent to <span class="bold_code"><a href="#fetch_state-2">fetch_state(FetchState, S)</a></span>.</p> </p></div> <p><a name="fetch_state-2"><span class="bold_code">fetch_state(X::FetchState, S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="fetch_state-2"></a> <p>For controlling the FetchState, to be used in a fetch function, and called when the parser fetch an external resource (eg. a DTD). See <span class="bold_code"><a href="xmerl_examples.html">tutorial</a></span> on customization functions.</p> </p></div> <p><a name="file-1"><span class="bold_code">file(Filename::string()) -> {xmlElement(), Rest}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Rest = list()</span><br> </div> </div> <div class="REFBODY"><p><a name="file-1"></a> <p>Equivalent to <span class="bold_code"><a href="#file-2">file(Filename, [])</a></span>.</p> </p></div> <p><a name="file-2"><span class="bold_code">file(Filename::string(), Options::option_list()) -> {xmlElement(), Rest}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Rest = list()</span><br> </div> </div> <div class="REFBODY"><p><a name="file-2"></a> <p>Parse file containing an XML document</p> </p></div> <p><a name="hook_state-1"><span class="bold_code">hook_state(S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="hook_state-1"></a> <p>Equivalent to <span class="bold_code"><a href="#hook_state-2">hook_state(HookState, S)</a></span>.</p> </p></div> <p><a name="hook_state-2"><span class="bold_code">hook_state(X::HookState, S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="hook_state-2"></a> <p>For controlling the HookState, to be used in a hook function, and called when the parser has parsed a complete entity. See <span class="bold_code"><a href="xmerl_examples.html">tutorial</a></span> on customization functions.</p> </p></div> <p><a name="rules_state-1"><span class="bold_code">rules_state(S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="rules_state-1"></a> <p>Equivalent to <span class="bold_code"><a href="#rules_state-2">rules_state(RulesState, S)</a></span>.</p> </p></div> <p><a name="rules_state-2"><span class="bold_code">rules_state(X::RulesState, S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="rules_state-2"></a> <p>For controlling the RulesState, to be used in a rules function, and called when the parser store scanner information in a rules database. See <span class="bold_code"><a href="xmerl_examples.html">tutorial</a></span> on customization functions.</p> </p></div> <p><a name="string-1"><span class="bold_code">string(Text::list()) -> {xmlElement(), Rest}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Rest = list()</span><br> </div> </div> <div class="REFBODY"><p><a name="string-1"></a> <p>Equivalent to <span class="bold_code"><a href="#string-2">string(Test, [])</a></span>.</p> </p></div> <p><a name="string-2"><span class="bold_code">string(Text::list(), Options::option_list()) -> {xmlElement(), Rest}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Rest = list()</span><br> </div> </div> <div class="REFBODY"><p><a name="string-2"></a> <p>Parse string containing an XML document</p> </p></div> <p><a name="user_state-1"><span class="bold_code">user_state(S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="user_state-1"></a> <p>Equivalent to <span class="bold_code"><a href="#user_state-2">user_state(UserState, S)</a></span>.</p> </p></div> <p><a name="user_state-2"><span class="bold_code">user_state(X::UserState, S::global_state()) -> global_state()</span></a><br></p> <div class="REFBODY"><p><a name="user_state-2"></a> <p>For controlling the UserState, to be used in a user function. See <span class="bold_code"><a href="xmerl_examples.html">tutorial</a></span> on customization functions.</p> </p></div> </div> <div class="footer"> <hr> <p>Copyright © 2004-2010 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>