Class: Moxml::XPath::Engine
- Inherits:
-
Object
- Object
- Moxml::XPath::Engine
- Defined in:
- lib/moxml/xpath/engine.rb
Overview
XPath 1.0 evaluation engine
This engine provides complete XPath 1.0 support for Moxml documents, particularly useful for the Ox adapter which has limited native XPath.
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#evaluate(expression, context: nil) ⇒ Moxml::NodeSet, ...
Evaluate an XPath expression.
-
#initialize(document) ⇒ Engine
constructor
Initialize engine with a document.
-
#valid?(expression) ⇒ Boolean
Check if expression is valid XPath syntax.
Constructor Details
#initialize(document) ⇒ Engine
Initialize engine with a document
24 25 26 |
# File 'lib/moxml/xpath/engine.rb', line 24 def initialize(document) @document = document end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
19 20 21 |
# File 'lib/moxml/xpath/engine.rb', line 19 def document @document end |
Instance Method Details
#evaluate(expression, context: nil) ⇒ Moxml::NodeSet, ...
Evaluate an XPath expression
35 36 37 38 |
# File 'lib/moxml/xpath/engine.rb', line 35 def evaluate(expression, context: nil) raise ::NotImplementedError, "XPath engine implementation in progress (Phase 1.1+)" end |
#valid?(expression) ⇒ Boolean
Check if expression is valid XPath syntax
44 45 46 47 48 49 |
# File 'lib/moxml/xpath/engine.rb', line 44 def valid?(expression) evaluate(expression, context: document.root) true rescue Moxml::XPath::SyntaxError false end |