Erlang -- xmerl_xpath

xmerl

Reference Manual

Version 1.3.19

- User's Guide
- Reference Manual
- Release Notes
- PDF
- Top

- 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_xpath

### Module

xmerl_xpath

### Module Summary

The xmerl_xpath module handles the entire XPath 1.0 spec.

### Description

The xmerl_xpath module handles the entire XPath 1.0 spec. XPath expressions typically occur in XML attributes and are used to address parts of an XML document. The grammar is defined in xmerl_xpath_parse.yrl. The core functions are defined in xmerl_xpath_pred.erl.

Some useful shell commands for debugging the XPath parser

     c(xmerl_xpath_scan).
     yecc:yecc("xmerl_xpath_parse.yrl", "xmerl_xpath_parse", true, []).
     c(xmerl_xpath_parse).

     xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("position() > -1")).
     xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 * 6 div 2")).
     xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 + 6 mod 2")).
     xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 * 6")).
     xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("-----6")).
     xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("parent::node()")).
     xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("descendant-or-self::node()")).
     xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("parent::processing-instruction('foo')")).

### DATA TYPES

docEntity() = #xmlDocument{} | [docNodes()]

docNodes() = #xmlElement{} | #xmlAttribute{} | #xmlText{} | #xmlPI{} | #xmlComment{} | #xmlNsNode{}

nodeEntity() = #xmlElement{} | #xmlAttribute{} | #xmlText{} | #xmlPI{} | #xmlComment{} | #xmlNsNode{} | #xmlDocument{}

option_list()

  Options allows to customize the behaviour of the XPath scanner.

  Possible options are:

  {namespace, #xmlNamespace}

    Set namespace nodes, from XmlNamspace, in xmlContext

  {namespace, Nodes}

    Set namespace nodes in xmlContext.

parentList() = [{atom(), integer()}]

xPathString() = string()

### Exports

string(Str, Doc) -> [docEntity()] | Scalar |

Equivalent to string(Str, Doc, []).

string(Str, Doc, Options) -> [docEntity()] | Scalar |

Equivalent to string(Str, Doc, [], Doc, Options).

string(Str, Node, Parents, Doc, Options) -> [docEntity()] | Scalar |

### Types

Str = xPathString()
Node = nodeEntity()
Parents = parentList()
Doc = nodeEntity()
Options = option_list()
Scalar = #xmlObj{}

Extracts the nodes from the parsed XML tree according to XPath. xmlObj is a record with fields type and value, where type is boolean | number | string