Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/goto100/xpath
Browse files Browse the repository at this point in the history
  • Loading branch information
JLRishe committed Nov 25, 2017
2 parents cc56179 + 058aed6 commit e1b91b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
16 changes: 5 additions & 11 deletions docs/XPathEvaluator.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ The `xpath.parse()` method returns an `XPathEvaluator`, which contains the follo

Each of these methods takes an optional `options` object, which can contain any of the following properties:

`namespaces` - a namespace resolver. See the [documentation page](namespace resolvers.md) for details.
`namespaces` - a namespace resolver. See the [documentation page](namespace%20resolvers.md) for details.

`variables` - a variable resolver. See the [documentation page](variable resolvers.md) for details.
`variables` - a variable resolver. See the [documentation page](variable%20resolvers.md) for details.

`functions` - a function resolver. See the [documentation page](function resolvers.md) for details.
`functions` - a function resolver. See the [documentation page](function%20resolvers.md) for details.

`node` - the context node for evaluating the expression

Expand All @@ -19,7 +19,7 @@ var evaluator = xpath.parse('/characters/character[@greeting = $greeting]');
var character = evaluator.select1({
node: myCharacterDoc,
variables: {
greeting: 'Hello, I'm Harry, Harry Potter.`
greeting: "Hello, I'm Harry, Harry Potter."
}
});
```
Expand All @@ -28,7 +28,7 @@ var character = evaluator.select1({

`evaluate([options])`

Evaluates the XPath expression and returns the result. The resulting type is determined based on the type of the expression, using the same criteria as [`xpath.select`](xpath methods.md).
Evaluates the XPath expression and returns the result. The resulting type is determined based on the type of the expression, using the same criteria as [`xpath.select`](xpath%20methods.md).

`evaluateNumber([options])`

Expand All @@ -54,12 +54,6 @@ Evaluates the XPath expression and returns an array of the resulting nodes, in d

This is only valid for expressions that evaluate to a node set.

`select([options])`

Evaluates the XPath expression and returns an array of the resulting nodes, in document order.

This is only valid for expressions that evaluate to a node set.

`select1([options])`

Evaluates the XPath expression and the first node in the resulting node set, in document order. Returns `undefined`
Expand Down
2 changes: 1 addition & 1 deletion docs/parsed expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The `xpath.parse()` method allows pre-parsing an XPath expression and creating a

This can provide a performance benefit if you plan to evaluate the same XPath multiple times, because the expression only needs to be parsed once.

This also provides access to additional features such as the use of variables and custom XPath functinos, which are not available using the evaluation methods on the `xpath` object.
This also provides access to additional features such as the use of variables and custom XPath functions, which are not available using the evaluation methods on the `xpath` object.

#### xpath.parse(expression)

Expand Down
6 changes: 3 additions & 3 deletions docs/xpath methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Creates a parsed expression. See the [documentation page](parsed%20expressions.m

### `xpath.select(expression[, node[, single]])`

Evaluates an XPath expression and returns the result. The return value is determined based on the result type of the expression (which can always be predicted ahead of time):
Evaluates an XPath expression and returns the result. The return value is determined based on the result type of the expression (which can always be predicted ahead of time based on the expression's syntax):

- A boolean value if the expression evaluates to a boolean value.
- A number if the expression evaluates to a numeric value.
- A string if the expression evaluates to a string.
- If the expression evaluates to a nodeset:
- An array of nodes if `single` is unspecified or falsy
- An array of 0 or more nodes if `single` is unspecified or falsy
- A single node (the first node in document order) or `undefined` if `single` is truthy

`node` is optional and if specified, is used as the context node for evaluating the expression. (It is necessary if the expression includes any node tests.)
`node` is optional and if specified, is used as the context node for evaluating the expression. (It is necessary if the expression makes use of the current contex.)

`single` is optional and is ignored if the expression evaluates to anything other than a nodeset.

Expand Down

0 comments on commit e1b91b4

Please sign in to comment.