User's Guide
Reference Manual
Release Notes
PDF
Top

xmerl
Reference Manual
Version 1.3.9

Expand All
Contract All

Table of Contents

- xmerl_scan
  - Top of manual page
  - accumulate_whitespace/4
  - cont_state/1
  - cont_state/2
  - event_state/1
  - event_state/2
  - fetch_state/1
  - fetch_state/2
  - file/1
  - file/2
  - hook_state/1
  - hook_state/2
  - rules_state/1
  - rules_state/2
  - string/1
  - string/2
  - user_state/1
  - user_state/2
- xmerl
  - Top of manual page
  - callbacks/1
  - export/2
  - export/3
  - export_content/2
  - export_element/2
  - export_element/3
  - export_simple/2
  - export_simple/3
  - export_simple_content/2
  - export_simple_element/2
- xmerl_xs
  - Top of manual page
  - built_in_rules/2
  - select/2
  - value_of/1
  - xslapply/2
- xmerl_eventp
  - Top of manual page
  - file_sax/4
  - stream/2
  - stream_sax/4
  - string_sax/4
- xmerl_xpath
  - Top of manual page
  - string/2
  - string/3
  - string/5
- xmerl_xsd
  - Top of manual page
  - file2state/1
  - format_error/1
  - process_schema/1
  - process_schema/2
  - process_schemas/1
  - process_schemas/2
  - process_validate/2
  - process_validate/3
  - state2file/1
  - state2file/2
  - validate/2
  - validate/3
- xmerl_sax_parser
  - Top of manual page
  - file/2
  - stream/2
  - ContinuationFun/1
  - EventFun/3

# xmerl

### MODULE

xmerl

### MODULE SUMMARY

Functions for exporting XML data to an external format.

### DESCRIPTION

Functions for exporting XML data to an external format.

### EXPORTS

callbacks(Module) -> Result

Types:

Module = atom()
Result = [atom()]

Find the list of inherited callback modules for a given module.

export(Content, Callback) -> ExportedFormat

Equivalent to export(Data, Callback, []).

export(Content, Callback, RootAttributes) -> ExportedFormat

Types:

Content = [Element]
Callback = atom()
RootAttributes = [XmlAttributes]

Exports normal, well-formed XML content, using the specified callback-module.

Element is any of:

- #xmlText{}

- #xmlElement{}

- #xmlPI{}

- #xmlComment{}

- #xmlDecl{}

(See xmerl.hrl for the record definitions.) Text in #xmlText{} elements can be deep lists of characters and/or binaries.

RootAttributes is a list of #xmlAttribute{} attributes for the #root# element, which implicitly becomes the parent of the given Content. The tag-handler function for #root# is thus called with the complete exported data of Content. Root attributes can be used to specify e.g. encoding or other metadata of an XML or HTML document.

The Callback module should contain hook functions for all tags present in the data structure. A hook function must have the following format:

        Tag(Data, Attributes, Parents, E)

where E is the corresponding #xmlElement{}, Data is the already-exported contents of E and Attributes is the list of #xmlAttribute{} records of E. Finally, Parents is the list of parent nodes of E, on the form [{ParentTag::atom(), ParentPosition::integer()}].

The hook function should return either the data to be exported, or a tuple {'#xml-alias#', NewTag::atom()}, or a tuple {'#xml-redefine#', Content}, where Content is a content list (which can be on simple-form; see export_simple/2 for details).

A callback module can inherit definitions from other callback modules, through the required function '#xml-interitance#() -> [ModuleName::atom()].

See also: export/2, export_simple/3.

export_content(Es::Content, Callbacks) -> term()

Types:

Content = [Element]
Callback = [atom()]

Exports normal XML content directly, without further context.

export_element(E, CB) -> term()

Exports a normal XML element directly, without further context.

export_element(E, CallbackModule, CallbackState) -> ExportedFormat

For on-the-fly exporting during parsing (SAX style) of the XML document.

export_simple(Content, Callback) -> ExportedFormat

Equivalent to export_simple(Content, Callback, []).

export_simple(Content, Callback, RootAttrs::RootAttributes) -> ExportedFormat

Types:

Content = [Element]
Callback = atom()
RootAttributes = [XmlAttributes]

Exports "simple-form" XML content, using the specified callback-module.

Element is any of:

- {Tag, Attributes, Content}

- {Tag, Content}

- Tag

- IOString

- #xmlText{}

- #xmlElement{}

- #xmlPI{}

- #xmlComment{}

- #xmlDecl{}

where

- Tag = atom()

- Attributes = [{Name, Value}]

- Name = atom()

- Value = IOString | atom() | integer()

Normal-form XML elements can thus be included in the simple-form representation. Note that content lists must be flat. An IOString is a (possibly deep) list of characters and/or binaries.

RootAttributes is a list of:

- XmlAttributes = #xmlAttribute{}

See export/3 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.

See also: export/3, export_simple/2.

export_simple_content(Content, Callback) -> term()

Exports simple XML content directly, without further context.

export_simple_element(Content, Callback) -> term()

Exports a simple XML element directly, without further context.