From 26411e4e289eba4c64b46f212d8919c075084e66 Mon Sep 17 00:00:00 2001 From: Jimmy Rishe Date: Sat, 2 Jan 2021 01:05:17 +0900 Subject: [PATCH] Update variable resolvers.md --- docs/variable resolvers.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/variable resolvers.md b/docs/variable resolvers.md index d3088a3..2394d61 100644 --- a/docs/variable resolvers.md +++ b/docs/variable resolvers.md @@ -25,14 +25,14 @@ A plain object with variable names as the keys and variable values as the values Example usage: -```` +````javascript var evaluator = xpath.parse('concat($character1, ", ", $character2, ", and ", $character3)'); var mainCharacters = evaluator.evaluateString({ - variables: { - character1: 'Harry', + variables: { + character1: 'Harry', character2: 'Ron', character3: 'Hermione' - } + } }); ```` @@ -43,10 +43,10 @@ and returns a value based on the name and namespace. Example usage: -```` +````javascript var evaluator = xpath.parse('concat($hp:character1, ", ", $hp:character2, ", and ", $hp:character3)'); var mainCharacters = evaluator.evaluateString({ - variables: function (name, namespace) { + variables: function (name, namespace) { if (namespace === 'http://sample.org/harrypotter/') { switch (name) { case 'character1': return 'Harry'; @@ -54,7 +54,7 @@ var mainCharacters = evaluator.evaluateString({ case 'character3': return 'Hermione'; } } - }, + }, namespaces: { hp: 'http://sample.org/harrypotter/' } @@ -68,10 +68,10 @@ described above. Example usage: -```` +````javascript var evaluator = xpath.parse('concat($hp:character1, ", ", $hp:character2, ", and ", $hp:character3)'); var mainCharacters = evaluator.evaluateString({ - variables: { + variables: { getVariable: function (name, namespace) { if (namespace === 'http://sample.org/harrypotter/') { switch (name) { @@ -80,7 +80,7 @@ var mainCharacters = evaluator.evaluateString({ case 'character3': return 'Hermione'; } } - } + } }, namespaces: { hp: 'http://sample.org/harrypotter/'