<!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_xsd</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="no" title="xmerl_scan " expanded="false">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="loadscrollpos" title="xmerl_xsd " expanded="true">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_xsd</h1></center> <h3>MODULE</h3> <div class="REFBODY">xmerl_xsd</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">Interface module for XML Schema vlidation.</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p>Interface module for XML Schema vlidation. It handles the W3.org <span class="bold_code"><a href="http://www.w3.org/XML/Schema#dev">specifications</a></span> of XML Schema second edition 28 october 2004. For an introduction to XML Schema study <span class="bold_code"><a href="http://www.w3.org/TR/xmlschema-0/">part 0.</a></span> An XML structure is validated by xmerl_xsd:validate/[2,3].</p></p></div> <h3><a name="id2263119">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 validator. It is representated by the <span class="code">#xsd_state{}</span> 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 validation. </p> Possible options are : <dl> <dt><strong><span class="code">{tab2file,boolean()}</span></strong></dt> <dd><p>Enables saving of abstract structure on file for debugging purpose.</p></dd> <dt><strong><span class="code">{xsdbase,filename()}</span></strong></dt> <dd><p>XSD Base directory.</p></dd> <dt><strong><span class="code">{fetch_fun,FetchFun}</span></strong></dt> <dd><p>Call back function to fetch an external resource.</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">{state,State}</span></strong></dt> <dd><p>It is possible by this option to provide a state with process information from an earlier validation.</p></dd> </dl> ------------------------------------------------------------------- </dd> </dl> </div> <h3>EXPORTS</h3> <p><a name="file2state-1"><span class="bold_code">file2state(FileName) -> {ok, State} | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">State = global_state()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">FileName = filename()</span><br> </div> </div> <div class="REFBODY"><p><a name="file2state-1"></a> <p>Reads the schema state with all information of the processed schema from a file created with <span class="code">state2file/[1,2]</span>. The format of this file is internal. The state can then be used validating an XML document.</p> </p></div> <p><a name="format_error-1"><span class="bold_code">format_error(L::Errors) -> Result</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Errors = error_tuple() | [error_tuple()]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Result = string() | [string()]</span><br> </div> </div> <div class="REFBODY"><p><a name="format_error-1"></a> <p>Formats error descriptions to human readable strings.</p> </p></div> <p><a name="process_schema-1"><span class="bold_code">process_schema(Schema) -> Result</span></a><br></p> <div class="REFBODY"><p><a name="process_schema-1"></a> <p>Equivalent to <span class="bold_code"><a href="#process_schema-2">process_schema(Schema, [])</a></span>.</p> </p></div> <p><a name="process_schema-2"><span class="bold_code">process_schema(Schema, Options) -> term() </span></a><br></p> <div class="REFBODY"><p><a name="process_schema-2"></a> </p></div> <p><a name="process_schemas-1"><span class="bold_code">process_schemas(Schemas) -> Result</span></a><br></p> <div class="REFBODY"><p><a name="process_schemas-1"></a> <p>Equivalent to <span class="bold_code"><a href="#process_schema-2">process_schema(Schemas, [])</a></span>.</p> </p></div> <p><a name="process_schemas-2"><span class="bold_code">process_schemas(Schemas, Options) -> term() </span></a><br></p> <div class="REFBODY"><p><a name="process_schemas-2"></a> </p></div> <p><a name="process_validate-2"><span class="bold_code">process_validate(Schema, Xml::Element) -> Result</span></a><br></p> <div class="REFBODY"><p><a name="process_validate-2"></a> <p>Equivalent to <span class="bold_code"><a href="#process_validate-3">process_validate(Schema, Xml, [])</a></span>.</p> </p></div> <p><a name="process_validate-3"><span class="bold_code">process_validate(Schema, Xml, Opts) -> term() </span></a><br></p> <div class="REFBODY"><p><a name="process_validate-3"></a> </p></div> <p><a name="state2file-1"><span class="bold_code">state2file(S::State) -> ok | {error, Reason}</span></a><br></p> <div class="REFBODY"><p><a name="state2file-1"></a> <p>Same as state2file(State,SchemaName)</p> <p>The name of the saved file is the same as the name of the schema, but with <span class="code">.xss</span> extension.</p> </p></div> <p><a name="state2file-2"><span class="bold_code">state2file(S::State, FileName) -> ok | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">State = global_state()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">FileName = filename()</span><br> </div> </div> <div class="REFBODY"><p><a name="state2file-2"></a> <p>Saves the schema state with all information of the processed schema in a file. You can provide the file name for the saved state. FileName is saved with the <span class="code">.xss</span> extension added.</p> </p></div> <p><a name="validate-2"><span class="bold_code">validate(Xml::Element, State) -> Result</span></a><br></p> <div class="REFBODY"><p><a name="validate-2"></a> <p>Equivalent to <span class="bold_code"><a href="#validate-3">validate(Element, State, [])</a></span>.</p> </p></div> <p><a name="validate-3"><span class="bold_code">validate(Xml::Element, State, Opts::Options) -> Result</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Element = XmlElement</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = option_list()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Result = {ValidElement, global_state()} | {error, Reasons}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">ValidElement = XmlElement</span><br> </div> <div class="REFTYPES"> <span class="bold_code">State = global_state()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reasons = [ErrorReason] | ErrorReason</span><br> </div> </div> <div class="REFBODY"><p><a name="validate-3"></a> <p>Validates a parsed well-formed XML element (Element). </p><p>A call to validate/2 or validate/3 must provide a well formed parsed XML element <span class="code">#xmlElement{}</span> and a State, <span class="code">global_state()</span>, which holds necessary information from an already processed schema. Thus validate enables reuse of the schema information and therefore if one shall validate several times towards the same schema it reduces time consumption.</p> <p>The result, ValidElement, is the valid element that conforms to the post-schema-validation infoset. When the validator finds an error it tries to continue and reports a list of all errors found. In those cases an unexpected error is found it may cause a single error reason. </p> <p> Usage example:</p> <p> <span class="code">1>{E,_} = xmerl_scan:file("my_XML_document.xml").</span><br> <span class="code">2>{ok,S} = xmerl_xsd:process_schema("my_XML_Schema.xsd").</span><br> <span class="code">3>{E2,_} = xmerl_xsd:validate(E,S).</span> </p> <p> Observe that E2 may differ from E if for instance there are default values defined in <span class="code">my_XML_Schema.xsd</span>.</p> </p></div> </div> <div class="footer"> <hr> <p>Copyright © 2004-2010 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>