Module xmerl_scan

The XML parser is activated through xmerl_scan:string/[1,2] or xmerl_scan:file/[1,2].

Description

The XML parser is activated through xmerl_scan:string/[1,2] or xmerl_scan:file/[1,2]. It returns records of the type defined in xmerl.hrl. See also tutorial on customization functions.

Data Types

global_state()

abstract datatype: global_state()

The global state of the scanner, represented by the #xmerl_scanner{} record.

option_list()

abstract datatype: option_list()

Options allows to customize the behaviour of the scanner. See also tutorial on customization functions.

Possible options are:
{acc_fun, Fun}
Call back function to accumulate contents of entity.
{continuation_fun, Fun} | {continuation_fun, Fun, ContinuationState}
Call back function to decide what to do if the scanner runs into eof before the document is complete.
{event_fun, Fun} | {event_fun, Fun, EventState}
Call back function to handle scanner events.
{fetch_fun, Fun} | {fetch_fun, Fun, FetchState}
Call back function to fetch an external resource.
{hook_fun, Fun} | {hook_fun, Fun, HookState}
Call back function to process the document entities once identified.
{close_fun, Fun}
Called when document has been completely parsed.
{rules, ReadFun, WriteFun, RulesState} | {rules, Rules}
Handles storing of scanner information when parsing.
{user_state, UserState}
Global state variable accessible from all customization functions
{fetch_path, PathList}
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.
{prolog, Flag}
'continue' (default) if scanning should continue after prolog in XML document, 'stop' otherwise.
{space, Flag}
'preserve' (default) to preserve spaces, 'normalize' to accumulate consecutive whitespace and replace it with one space.
{line, Line}
To specify starting line for scanning in document which contains fragments of XML.
{namespace_conformant, Flag}
Controls whether to behave as a namespace conformant XML parser, 'false' (default) to not otherwise 'true'.
{validation, Flag}
Controls whether to process as a validating XML parser, 'false' (default) to not otherwise 'true'.
{quiet, Flag}
Set to 'true' if xmerl should behave quietly and not output any info to standard output, 'false' (default) otherwise 'true'.
{doctype_DTD, DTD}
Allows to specify DTD name when it isn't available in the XML document.

Function Index

Exported Functions
accumulate_whitespace/4Function to accumulate and normalize whitespace.
cont_state/1See cont_state/2.
cont_state/2For controlling the ContinuationState, to be used in a continuation function, and called when the parser encounters the end of the byte stream.
event_state/1See event_state/2.
event_state/2For controlling the EventState, to be used in an event function, and called at the beginning and at the end of a parsed entity.
fetch_state/1See fetch_state/2.
fetch_state/2For controlling the FetchState, to be used in a fetch function, and called when the parser fetch an external resource (eg.
file/1See file/2.
file/2Parse file containing an XML document.
hook_state/1See hook_state/2.
hook_state/2For controlling the HookState, to be used in a hook function, and called when the parser has parsed a complete entity.
rules_state/1See rules_state/2.
rules_state/2For controlling the RulesState, to be used in a rules function, and called when the parser store scanner information in a rules database.
string/1See string/2.
string/2Parse string containing an XML document.
user_state/1See user_state/2.
user_state/2For controlling the UserState, to be used in a user function.

Exported Functions

accumulate_whitespace/4

accumulate_whitespace(T::string(), S::global_state(), atom(), Acc::string()) -> {Acc, T1, S1}

Function to accumulate and normalize whitespace.

cont_state/1

cont_state(S::global_state()) -> global_state()

Equivalent to cont_state(ContinuationState, S) .

cont_state/2

cont_state(ContinuationState, S::global_state()) -> global_state()

For controlling the ContinuationState, to be used in a continuation function, and called when the parser encounters the end of the byte stream. See tutorial on customization functions.

event_state/1

event_state(S::global_state()) -> global_state()

Equivalent to event_state(EventState, S) .

event_state/2

event_state(EventState, S::global_state()) -> global_state()

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 tutorial on customization functions.

fetch_state/1

fetch_state(S::global_state()) -> global_state()

Equivalent to fetch_state(FetchState, S) .

fetch_state/2

fetch_state(FetchState, S::global_state()) -> global_state()

For controlling the FetchState, to be used in a fetch function, and called when the parser fetch an external resource (eg. a DTD). See tutorial on customization functions.

file/1

file(Filename::string()) -> xmlElement()

Equivalent to file(Name, []) .

file/2

file(Filename::string(), Options::option_list()) -> xmlElement()

Parse file containing an XML document

hook_state/1

hook_state(S::global_state()) -> global_state()

Equivalent to hook_state(HookState, S) .

hook_state/2

hook_state(HookState, S::global_state()) -> global_state()

For controlling the HookState, to be used in a hook function, and called when the parser has parsed a complete entity. See tutorial on customization functions.

rules_state/1

rules_state(S::global_state()) -> global_state()

Equivalent to rules_state(RulesState, S) .

rules_state/2

rules_state(RulesState, S::global_state()) -> global_state()

For controlling the RulesState, to be used in a rules function, and called when the parser store scanner information in a rules database. See tutorial on customization functions.

string/1

string(Text::list()) -> xmlElement()

Equivalent to string(Test, []) .

string/2

string(Text::list(), Options::option_list()) -> xmlElement()

Parse string containing an XML document

user_state/1

user_state(S::global_state()) -> global_state()

Equivalent to user_state(UserState, S) .

user_state/2

user_state(UserState, S::global_state()) -> global_state()

For controlling the UserState, to be used in a user function. See tutorial on customization functions.