<!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</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="loadscrollpos" title="xmerl " expanded="true">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</h1></center> <h3>MODULE</h3> <div class="REFBODY">xmerl</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">Functions for exporting XML data to an external format.</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p>Functions for exporting XML data to an external format. </p></p></div> <h3>EXPORTS</h3> <p><a name="callbacks-1"><span class="bold_code">callbacks(Module) -> Result</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Result = [atom()]</span><br> </div> </div> <div class="REFBODY"><p><a name="callbacks-1"></a> <p>Find the list of inherited callback modules for a given module.</p> </p></div> <p><a name="export-2"><span class="bold_code">export(Content, Callback) -> ExportedFormat</span></a><br></p> <div class="REFBODY"><p><a name="export-2"></a> <p>Equivalent to <span class="bold_code"><a href="#export-3">export(Data, Callback, [])</a></span>.</p> </p></div> <p><a name="export-3"><span class="bold_code">export(Content, Callback, RootAttributes) -> ExportedFormat</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Content = [Element]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Callback = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">RootAttributes = [XmlAttributes]</span><br> </div> </div> <div class="REFBODY"><p><a name="export-3"></a> <p>Exports normal, well-formed XML content, using the specified callback-module. </p><p><span class="code">Element</span> is any of:</p> <ul> <li><p><span class="code">#xmlText{}</span></p></li> <li><p><span class="code">#xmlElement{}</span></p></li> <li><p><span class="code">#xmlPI{}</span></p></li> <li><p><span class="code">#xmlComment{}</span></p></li> <li><p><span class="code">#xmlDecl{}</span></p></li> </ul> <p>(See <span class="code">xmerl.hrl</span> for the record definitions.) Text in <span class="code">#xmlText{}</span> elements can be deep lists of characters and/or binaries.</p> <p><span class="code">RootAttributes</span> is a list of <span class="code">#xmlAttribute{}</span> attributes for the <span class="code">#root#</span> element, which implicitly becomes the parent of the given <span class="code">Content</span>. The tag-handler function for <span class="code">#root#</span> is thus called with the complete exported data of <span class="code">Content</span>. Root attributes can be used to specify e.g. encoding or other metadata of an XML or HTML document.</p> <p>The <span class="code">Callback</span> module should contain hook functions for all tags present in the data structure. A hook function must have the following format:</p> <div class="example"><pre> Tag(Data, Attributes, Parents, E)</pre></div> <p>where <span class="code">E</span> is the corresponding <span class="code">#xmlElement{}</span>, <span class="code">Data</span> is the already-exported contents of <span class="code">E</span> and <span class="code">Attributes</span> is the list of <span class="code">#xmlAttribute{}</span> records of <span class="code">E</span>. Finally, <span class="code">Parents</span> is the list of parent nodes of <span class="code">E</span>, on the form <span class="code">[{ParentTag::atom(), ParentPosition::integer()}]</span>.</p> <p>The hook function should return either the data to be exported, or a tuple <span class="code">{'#xml-alias#', NewTag::atom()}</span>, or a tuple <span class="code">{'#xml-redefine#', Content}</span>, where <span class="code">Content</span> is a content list (which can be on simple-form; see <span class="code">export_simple/2</span> for details).</p> <p>A callback module can inherit definitions from other callback modules, through the required function <span class="code">'#xml-interitance#() -> [ModuleName::atom()]</span>.</p> <p><strong>See also:</strong> <span class="bold_code"><a href="#export-2">export/2</a></span>, <span class="bold_code"><a href="#export_simple-3">export_simple/3</a></span>.</p> </p></div> <p><a name="export_content-2"><span class="bold_code">export_content(Es::Content, Callbacks) -> term()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Content = [Element]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Callback = [atom()]</span><br> </div> </div> <div class="REFBODY"><p><a name="export_content-2"></a> <p>Exports normal XML content directly, without further context.</p> </p></div> <p><a name="export_element-2"><span class="bold_code">export_element(E, CB) -> term() </span></a><br></p> <div class="REFBODY"><p><a name="export_element-2"></a> <p>Exports a normal XML element directly, without further context.</p> </p></div> <p><a name="export_element-3"><span class="bold_code">export_element(E, CallbackModule, CallbackState) -> ExportedFormat</span></a><br></p> <div class="REFBODY"><p><a name="export_element-3"></a> <p>For on-the-fly exporting during parsing (SAX style) of the XML document.</p> </p></div> <p><a name="export_simple-2"><span class="bold_code">export_simple(Content, Callback) -> ExportedFormat</span></a><br></p> <div class="REFBODY"><p><a name="export_simple-2"></a> <p>Equivalent to <span class="bold_code"><a href="#export_simple-3">export_simple(Content, Callback, [])</a></span>.</p> </p></div> <p><a name="export_simple-3"><span class="bold_code">export_simple(Content, Callback, RootAttrs::RootAttributes) -> ExportedFormat</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Content = [Element]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Callback = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">RootAttributes = [XmlAttributes]</span><br> </div> </div> <div class="REFBODY"><p><a name="export_simple-3"></a> <p>Exports "simple-form" XML content, using the specified callback-module. </p><p><span class="code">Element</span> is any of:</p> <ul> <li><p><span class="code">{Tag, Attributes, Content}</span></p></li> <li><p><span class="code">{Tag, Content}</span></p></li> <li><p><span class="code">Tag</span></p></li> <li><p><span class="code">IOString</span></p></li> <li><p><span class="code">#xmlText{}</span></p></li> <li><p><span class="code">#xmlElement{}</span></p></li> <li><p><span class="code">#xmlPI{}</span></p></li> <li><p><span class="code">#xmlComment{}</span></p></li> <li><p><span class="code">#xmlDecl{}</span></p></li> </ul> <p>where</p> <ul> <li><p><span class="code">Tag = atom()</span></p></li> <li><p><span class="code">Attributes = [{Name, Value}]</span></p></li> <li><p><span class="code">Name = atom()</span></p></li> <li><p><span class="code">Value = IOString | atom() | integer()</span></p></li> </ul> <p>Normal-form XML elements can thus be included in the simple-form representation. Note that content lists must be flat. An <span class="code">IOString</span> is a (possibly deep) list of characters and/or binaries.</p> <p><span class="code">RootAttributes</span> is a list of:</p> <ul> <li><p><span class="code">XmlAttributes = #xmlAttribute{}</span></p></li> </ul> <p>See <span class="code">export/3</span> for details on the callback module and the root attributes. The XML-data is always converted to normal form before being passed to the callback module.</p> <p><strong>See also:</strong> <span class="bold_code"><a href="#export-3">export/3</a></span>, <span class="bold_code"><a href="#export_simple-2">export_simple/2</a></span>.</p> </p></div> <p><a name="export_simple_content-2"><span class="bold_code">export_simple_content(Content, Callback) -> term() </span></a><br></p> <div class="REFBODY"><p><a name="export_simple_content-2"></a> <p>Exports simple XML content directly, without further context.</p> </p></div> <p><a name="export_simple_element-2"><span class="bold_code">export_simple_element(Content, Callback) -> term() </span></a><br></p> <div class="REFBODY"><p><a name="export_simple_element-2"></a> <p>Exports a simple XML element directly, without further context.</p> </p></div> </div> <div class="footer"> <hr> <p>Copyright © 2004-2010 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>