Crystal XPath2

Build Status 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.

* a `=` b	    `true` if a equals b.
* a `!=` b	`true` if a is not equal to b.
* a `<` b	    `true` if a is less than b.
* a `<=` b	`true` if a is less than or equal to b.
* a `>` b	    `true` if a is greater than b.
* a `>=` b	`true` if a is greater than or equal to b.
* `- a`	Unary minus
* a `+` b	Add
* a `-` b	Substract
* a `*` b	Multiply
* a `div` b	Divide
* a `mod` b	Floating point mod, like Java.

| Function | Supported | | --- | --- | boolean()| ✓ | ceiling()| ✓ | choose()| ✗ | concat()| ✓ | contains()| ✓ | count()| ✓ | current()| ✗ | document()| ✗ | element-available()| ✗ | ends-with()| ✓ | false()| ✓ | floor()| ✓ | format-number()| ✗ | function-available()| ✗ | generate-id()| ✗ | id()| ✗ | key()| ✗ | lang()| ✗ | last()| ✓ | local-name()| ✓ | name()| ✓ | namespace-uri()| ✓ | normalize-space()| ✓ | not()| ✓ | number()| ✓ | position()| ✓ | replace()| ✓ | reverse()| ✓ | round()| ✓ | starts-with()| ✓ | string()| ✓ | string-length()| ✓ | substring()| ✓ | substring-after()| ✓ | substring-before()| ✓ | sum()| ✓ | system-property()| ✗ | translate()| ✓ | true()| ✓ | unparsed-entity-url() | ✗ |

Installation

  1. Add the dependency to your shard.yml:

`yaml dependencies:

 xpath2:
   github: naqvis/crystal-xpath2

`

  1. Run shards install

Usage

refer to spec for usage examples 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