Crystal XPath2

CI GitHub release Docs

Crystal XPath2 Shard provide XPath implementation in Pure Crystal. Performs the compilation of XPath expression and provides mechanism to select/evaluate nodes from HTML or other documents using XPath expression

Supported Features

The basic XPath patterns.

The basic XPath patterns cover 90% of the cases that most stylesheets will need.

Node Axes

Expressions

Shard supports three types: number, boolean, string.

| Function | Supported | | ---------------------- | --------- | | abs() | ✓ | | boolean() | ✓ | | ceiling() | ✓ | | compare() | ✓ | | concat() | ✓ | | contains() | ✓ | | count() | ✓ | | distinct-values() | ✓ | | empty() | ✓ | | ends-with() | ✓ | | exists() | ✓ | | false() | ✓ | | floor() | ✓ | | function-available() | ✓ | | generate-id() | ✓ | | id() | ✓ | | index-of() | ✓ | | insert-before() | ✓ | | lang() | ✓ | | last() | ✓ | | local-name() | ✓ | | lower-case() | ✓ | | matches() | ✓ | | name() | ✓ | | namespace-uri() | ✓ | | normalize-space() | ✓ | | not() | ✓ | | number() | ✓ | | position() | ✓ | | remove() | ✓ | | replace() | ✓ | | reverse() | ✓ | | round() | ✓ | | starts-with() | ✓ | | string() | ✓ | | string-join() | ✓ | | string-length() | ✓ | | subsequence() | ✓ | | substring() | ✓ | | substring-after() | ✓ | | substring-before() | ✓ | | sum() | ✓ | | tokenize() | ✓ | | translate() | ✓ | | true() | ✓ | | upper-case() | ✓ |

Note: XSLT-specific functions (choose, current, document, element-available, format-number, key, system-property, unparsed-entity-url) are not supported as they require an XSLT processing context.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      xpath2:
        github: naqvis/crystal-xpath2
  2. Run shards install

Usage

refer to spec for usage examples refer to spec or refer to Crystal HTML5 and JSON XPath for implementation details.

Development

To run all tests:

crystal spec

Contributing

  1. Fork it (https://github.com/naqvis/crystal-xpath2/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors