---
name: "xmerl_eventp"
section: "3erl"
platform: "linux"
package: "erlang-manpages"
version: "1:25.2.3+dfsg-1+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/xmerl_eventp"
---

# xmerl\_eventp(3erl)

Simple event-based front-ends to xmerl\_scan for processing of XML documents in streams and for parsing in SAX style.

## NAME

xmerl\_eventp - Simple event-based front-ends to xmerl\_scan for processing\
   of XML documents in streams and for parsing in SAX style.

## DESCRIPTION

Simple event-based front-ends to xmerl\_scan for processing of XML documents in streams and for parsing in SAX style. Each contain more elaborate settings of xmerl\_scan that makes usage of the customization functions.

## DATA TYPES

- **option\_list():**

  Options allow 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.

  - ***{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: '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'.

  - ***{schemaLocation, \[{Namespace,Link}\|...\]}*:**

    Tells explicitly which XML Schema documents to use to validate the XML document. Used together with the *{validation,schema}* option.

  - ***{quiet, Flag}*:**

    Set to 'true' if xmerl should behave quietly and not output any information to standard output (default 'false').

  - ***{doctype\_DTD, DTD}*:**

    Allows to specify DTD name when it isn't available in the XML document. This option has effect only together with *{validation,'dtd'* option.

  - ***{xmlbase, Dir}*:**

    XML Base directory. If using string/1 default is current directory. If using file/1 default is directory of given file.

  - ***{encoding, Enc}*:**

    Set default character set used (default UTF-8). This character set is used only if not explicitly given by the XML declaration.

  - ***{document, Flag}*:**

    Set to 'true' if xmerl should return a complete XML document as an xmlDocument record (default 'false').

  - ***{comments, Flag}*:**

    Set to 'false' if xmerl should skip comments otherwise they will be returned as xmlComment records (default 'true').

  - ***{default\_attrs, Flag}*:**

    Set to 'true' if xmerl should add to elements missing attributes with a defined default value (default 'false').

- **xmlElement() = #xmlElement{}:**

  ## EXPORTS

**file\_sax(Fname::string(), CallBackModule::atom(), UserState, Options::option\_list()) -\> NewUserState**\

Parse file containing an XML document, SAX style. Wrapper for a call to the XML parser *xmerl\_scan* with a *hook\_fun* for using xmerl export functionality directly after an entity is parsed.

**stream(Fname::string(), Options::option\_list()) -\> xmlElement()**\

Parse file containing an XML document as a stream, DOM style. Wrapper for a call to the XML parser *xmerl\_scan* with a *continuation\_fun* for handling streams of XML data. Note that the *continuation\_fun*, *acc\_fun*, *fetch\_fun*, *rules* and *close\_fun* options cannot be user defined using this parser.

**stream\_sax(Fname, CallBack::CallBackModule, UserState, Options) -\> xmlElement()**\

Types:

Fname = string()\
 CallBackModule = atom()\
 Options = option\_list()\

Parse file containing an XML document as a stream, SAX style. Wrapper for a call to the XML parser *xmerl\_scan* with a *continuation\_fun* for handling streams of XML data. Note that the *continuation\_fun*, *acc\_fun*, *fetch\_fun*, *rules*, *hook\_fun*, *close\_fun* and *user\_state* options cannot be user defined using this parser.

**string\_sax(String::list(), CallBackModule::atom(), UserState, Options::option\_list()) -\> xmlElement()**\

Parse file containing an XML document, SAX style. Wrapper for a call to the XML parser *xmerl\_scan* with a *hook\_fun* for using xmerl export functionality directly after an entity is parsed.

## AUTHORS

*\<\>*
