Yorick Peterse
2b96d65103
XPath "self" axis inside predicates.
...
The "self" axis should use the current context node when inside a predicate.
2014-09-03 09:40:17 +02:00
Yorick Peterse
71f2b42074
Convenience methods for parsing XML/HTML.
2014-09-03 09:31:48 +02:00
Yorick Peterse
d92133ef43
Benchmark Oga XPath evaluation without the parser.
...
This gives better insight in the performance of the evaluator itself.
2014-09-02 20:55:42 +02:00
Yorick Peterse
9649b50cc9
XML module for more easily querying using XPath.
2014-09-02 20:16:52 +02:00
Yorick Peterse
ad34ab47a0
Support for binding/evaluating XPath variables.
2014-09-02 19:04:02 +02:00
Yorick Peterse
5a0e8c5480
Lexing/parsing of XPath variable references.
2014-09-02 10:52:08 +02:00
Yorick Peterse
5de37bdf81
Support for the XPath ">=" operator.
2014-09-01 22:45:01 +02:00
Yorick Peterse
099227901a
Support for the XPath "<=" operator.
2014-09-01 22:40:50 +02:00
Yorick Peterse
6eacf74da4
Fixed comparing node equality in XPath expressions
...
Previously this would take the text of the entire node set, not of the first
node in the set.
2014-09-01 22:34:18 +02:00
Yorick Peterse
8884db8cb6
Support for the XPath ">" operator.
2014-09-01 22:23:35 +02:00
Yorick Peterse
6b45a03cb4
Support for the XPath "<" operator.
2014-09-01 22:20:32 +02:00
Yorick Peterse
e1d9e62b72
Support for the XPath "!=" operator.
2014-09-01 20:48:11 +02:00
Yorick Peterse
9e5f15787d
Support for the XPath "=" operator.
2014-09-01 18:57:12 +02:00
Yorick Peterse
a70645fb89
Support for the XPath sub/- operator.
2014-08-29 09:41:17 +02:00
Yorick Peterse
89686b6cff
Support for the XPath mul/* operator.
2014-08-29 09:36:40 +02:00
Yorick Peterse
034b360d13
Support for the XPath "mod" operator.
2014-08-29 09:31:11 +02:00
Yorick Peterse
78c8cd1323
Support for the XPath "div" operator.
2014-08-28 23:05:12 +02:00
Yorick Peterse
ced7f739fc
Support for the XPath "add" / "+" operator.
2014-08-28 21:18:09 +02:00
Yorick Peterse
4fa40b58cf
Support for the XPath "or" operator.
2014-08-28 21:01:12 +02:00
Yorick Peterse
4f189d9218
Support for the XPath "and" operator.
2014-08-28 09:42:55 +02:00
Yorick Peterse
809ed9bfa6
Handle boolean values in the boolean() function.
2014-08-28 09:36:21 +02:00
Yorick Peterse
8fb8fb17b6
Clarified docs for floor(), ceiling() and round().
2014-08-28 00:01:33 +02:00
Yorick Peterse
543112dcdc
Support for the XPath round() function.
2014-08-28 00:00:25 +02:00
Yorick Peterse
a2b8e3c954
Support for the XPath ceiling() function.
2014-08-27 23:56:43 +02:00
Yorick Peterse
c8fb1ad202
Support for the XPath floor() function.
2014-08-27 23:52:23 +02:00
Yorick Peterse
7c68f2a49b
Raise for non node sets in the sum() function.
...
According to the XPath spec this function *can only* take node sets, nothing
else. Lets actually enforce that.
2014-08-27 23:47:19 +02:00
Yorick Peterse
ac06670c24
Better conversion of types to numbers.
...
The XPath number() function should also be capable of converting booleans to
numbers, something it previously was not able to do. In order to do this
reliably we can't rely on the string() function as this would make it impossible
to distinguish between literal string values and booleans. This is due to
true(), which returns a TrueClass, being converted to the string "true". This
string in turn can't be converted to a float.
2014-08-27 23:38:47 +02:00
Yorick Peterse
fcb28d5ae8
Specs for various XPath evaluator helper methods.
2014-08-27 23:37:12 +02:00
Yorick Peterse
30a5d01ebd
Support for the XPath sum() function.
2014-08-27 23:05:04 +02:00
Yorick Peterse
585b3535b2
Support for the XPath lang() function.
2014-08-27 20:26:27 +02:00
Yorick Peterse
10e82de87b
Handle boolean values in predicate results.
2014-08-27 20:26:10 +02:00
Yorick Peterse
7c41fa814f
Default attribute namespaces.
...
When an attribute is prefixed with "xml" the default namespace should be used
automatically. This namespace is not registered on element level by default as
this namespace isn't registered manually, instead it's a "magic" namespace. This
also ensures we match the behaviour of libxml more closely, hopefully reducing
confusion.
2014-08-27 20:24:40 +02:00
Yorick Peterse
d2f991538d
Support for the XPath true()/false() functions.
2014-08-27 09:37:28 +02:00
Yorick Peterse
4ef79bad90
Support for the XPath not() function.
2014-08-27 09:35:02 +02:00
Yorick Peterse
338aeeb514
Work around JRuby issue #1923 .
...
String#start_with?() returns false on JRuby when used with an empty string. See
https://github.com/jruby/jruby/issues/1923 for more information.
2014-08-26 21:08:50 +02:00
Yorick Peterse
29870c21f2
Use char Arrays in on_call_translate().
...
When running a 1.9 based Ruby Enumerable doesn't have the method #[].
2014-08-26 20:41:16 +02:00
Yorick Peterse
e288ab88f5
Support for the XPath boolean() function.
2014-08-26 20:22:28 +02:00
Yorick Peterse
bcd138a15a
Lexing of explicit negative/positive XPath numbers
2014-08-26 20:21:30 +02:00
Yorick Peterse
8295fa5783
Support for the XPath translate() function.
2014-08-26 18:14:44 +02:00
Yorick Peterse
7f3f626744
Support for the XPath normalize-space() function.
2014-08-26 00:06:58 +02:00
Yorick Peterse
06bed1cfdd
Support for the XPath string-length() function.
2014-08-25 23:46:18 +02:00
Yorick Peterse
a60057db5c
Proper handling of decimals for string() calls.
...
When calling the string() XPath function floats with zero decimals (10.0, 5.0,
etc) should result in a string without any decimals. Ruby converts 10.0 to
"10.0" whereas XPath expects "10".
2014-08-25 23:21:36 +02:00
Yorick Peterse
6c0c5ab720
Revert "Return XPath integers as actual integers."
...
The particular case of string(10) having to return "10" instead of "10.0" will
be handled separately. Returning integers breaks behaviour/expectations
elsewhere.
This reverts commit 431a253000
.
2014-08-25 23:14:22 +02:00
Yorick Peterse
a1a2190fe2
Support for the XPath substring() function.
2014-08-25 23:13:34 +02:00
Yorick Peterse
5382891106
Support for the XPath number() function.
2014-08-25 23:13:03 +02:00
Yorick Peterse
ba058627f2
Corrected docs for on_call_string().
2014-08-25 23:12:45 +02:00
Yorick Peterse
b2ca18e127
Support for the XPath substring-after() function.
2014-08-25 22:19:13 +02:00
Yorick Peterse
b9cdb4a72b
Support for the XPath substring-before() function.
2014-08-25 22:11:05 +02:00
Yorick Peterse
83b873e3c1
Support for the XPath contains() function.
2014-08-25 21:52:33 +02:00
Yorick Peterse
5b65d6c31a
Support for the xpath starts-with() function.
2014-08-25 09:43:06 +02:00
Yorick Peterse
276a5ab83b
Support for lexing empty XPath strings.
2014-08-25 09:42:51 +02:00
Yorick Peterse
b688c6dc1b
Support for the XPath concat() function.
2014-08-23 20:24:18 +02:00
Yorick Peterse
431a253000
Return XPath integers as actual integers.
...
This is to ensure that calls such as string(10) return "10" and not "10.0". It
also saves integer -> float conversions when they're not needed.
2014-08-23 20:22:58 +02:00
Yorick Peterse
b316fd3e1c
Support for the XPath string() function.
2014-08-22 11:06:10 +02:00
Yorick Peterse
ff8a4ad3aa
Ignore comment nodes in NodeSet#text.
2014-08-22 11:05:39 +02:00
Yorick Peterse
99be3182ae
Support for evaluating XPath floats.
2014-08-22 10:59:03 +02:00
Yorick Peterse
6ac3408a71
Match all node types when using node()
...
Previously this would only match element and text nodes.
2014-08-22 10:58:36 +02:00
Yorick Peterse
da09f1296c
Support for using namespace-uri() with attributes.
2014-08-21 22:36:18 +02:00
Yorick Peterse
0d41693bfc
Support for using name() with attributes.
2014-08-21 21:05:06 +02:00
Yorick Peterse
acc056eea4
Support for using local-name() on attributes.
2014-08-21 21:03:28 +02:00
Yorick Peterse
1dd6416bea
Basic support for the XPath name() function.
2014-08-21 20:47:20 +02:00
Yorick Peterse
e7019ceb4c
Renamed context_node to function_node.
2014-08-21 19:06:14 +02:00
Yorick Peterse
8cc0db2283
Support for the XPath namespace-uri() function.
2014-08-21 19:02:41 +02:00
Yorick Peterse
9e20b5ca3e
Support for the XPath local-name() function.
2014-08-21 10:21:02 +02:00
Yorick Peterse
2deb7a6d84
Support for the XPath id() function.
...
This comes with the limitation that it *always* uses the "id" attribute. This is
due to Oga not supporting DTD parsing/evaluation.
2014-08-20 21:06:35 +02:00
Yorick Peterse
d351bc26cc
Support for the XPath count() function.
2014-08-20 10:16:06 +02:00
Yorick Peterse
709fa365e0
XPath support for last() + evaluator docs.
...
I really dislike using a stack as it introduces an internal state. Sadly there
doesn't seem to be an easy way around this.
2014-08-19 22:59:26 +02:00
Yorick Peterse
e0895be675
Better setup for XPath predicates.
...
This allows filtering of nodes by indexes (e.g. using last() or a literal
number) and uses the correct index range (1 to N in XPath). The function
position() is not yet supported as this requires access to the current node,
which isn't passed down the call stack just yet.
2014-08-19 19:56:56 +02:00
Yorick Peterse
202f74a8eb
on_call_last() should return an index, not a node.
2014-08-19 19:56:41 +02:00
Yorick Peterse
423af37422
Basic support for the XPath last() function.
2014-08-18 19:00:32 +02:00
Yorick Peterse
2817784e6b
Support for the XPath pipe operator.
2014-08-17 22:04:08 +02:00
Yorick Peterse
d1735750c1
Only store unique nodes in XML::NodeSet.
...
It's called a "set" after all.
2014-08-17 22:03:44 +02:00
Yorick Peterse
bb503728af
XPath support for processing instructions.
2014-08-16 22:37:57 +02:00
Yorick Peterse
0d7609da88
Support for parsing XML processing instructions.
2014-08-15 22:23:26 +02:00
Yorick Peterse
8f4eaf3823
Lexing of XML processing instructions.
2014-08-15 22:04:45 +02:00
Yorick Peterse
ccd95d69d8
Support for the XPath comment() test.
2014-08-15 20:49:13 +02:00
Yorick Peterse
4d7f224892
Support for the XPath text() type test.
2014-08-15 10:46:00 +02:00
Yorick Peterse
14aa420091
Use a new base class for XML text nodes.
...
The classes Text, Cdata and Comment now extend CharacterData instead of Text.
2014-08-15 10:43:16 +02:00
Yorick Peterse
24bc84e15e
Added XML::Element#text_nodes.
...
This method returns all the text nodes directly nested in an element.
2014-08-15 10:07:49 +02:00
Yorick Peterse
d0092b434d
Removed Document#available_namespaces.
...
Namespaces aren't scoped per document but instead per element, thus this method
doesn't make that much sense. This also fixes the remaining, failing XPath test.
2014-08-14 23:12:33 +02:00
Yorick Peterse
d34e4697de
Match node types in node_matches?
...
The method XPath::Evaluator#node_matches? now has a special case to handle
"type-test" nodes. This in turn fixes a bunch of failing tests such as those for
the XPath query "parent::node()".
2014-08-14 22:54:19 +02:00
Yorick Peterse
a437d67573
Renamed node_type to type_test.
2014-08-14 22:35:41 +02:00
Yorick Peterse
05f6fc2f8d
Implement node() as a type test, not a function.
2014-08-14 22:30:14 +02:00
Yorick Peterse
6ad5170476
Support for lexing/parsing XPath type tests.
...
Unlike what I thought before syntax such as "node()" is not a function call.
Instead this is a special node test that tests the *types* of nodes, not their
names.
2014-08-14 21:51:58 +02:00
Yorick Peterse
23441bb5a4
Basic support for the XPath node() function.
2014-08-14 18:17:08 +02:00
Yorick Peterse
a133b923a2
Only emit extra T_SLASH tokens for "//".
2014-08-13 01:28:43 +02:00
Yorick Peterse
4d956c9ef0
Support for the XPath "namespace" axis.
2014-08-11 00:58:57 +02:00
Yorick Peterse
873bd82273
Stricted matching of namespaced elements.
2014-08-11 00:47:07 +02:00
Yorick Peterse
33c28f633b
Proper namespace support for elements.
...
This is still a bit rough on the edges but already way better than the broken
setup I had before.
2014-08-11 00:41:36 +02:00
Yorick Peterse
04cbbdcf9e
Proper namespace support for attributes.
...
This separates namespace handling into namespace names and namespace objects.
The namespace objects are retrieved from the element an attribute belongs to.
Once retrieved the namespace is cached, due to the overhead of retrieving
namespaces in large documents.
2014-08-11 00:40:17 +02:00
Yorick Peterse
fe8f77cf45
Basic work for supporting namespace URIs.
2014-08-08 19:03:42 +02:00
Yorick Peterse
f002061aaa
Extra type validation for XML::Element options.
2014-08-07 21:10:01 +02:00
Yorick Peterse
b1388ff84a
Ripped out inspect fuckery.
...
The old code used for generating Object#inspect values has been ripped out (for
the most part). The result is a non indented but far more compact #inspect
output. The code for this is also easier and doesn't break the signature of
Object#inspect.
2014-08-07 21:09:10 +02:00
Yorick Peterse
3b2279e410
Don't create empty Namespace nodes.
2014-08-07 20:16:46 +02:00
Yorick Peterse
4e18989972
Remove the uri attribute from Namespace.
...
Oga won't be handling URIs any time soon. The rationale is that they server zero
purpose when it comes to just parsing XML. Another goal of Oga is to make it
easy to modify and reserialize documents back to XML. If namespaces would also
store the URIs this would make this process more difficult.
2014-08-07 20:11:17 +02:00
Yorick Peterse
97e59fe449
Use the Namespace class for namespaces vs Strings.
2014-08-07 20:03:26 +02:00
Yorick Peterse
f653203220
Tests for the Namespace class.
2014-08-07 20:02:56 +02:00
Yorick Peterse
8e8ea64206
Fixed serializing of elements to XML.
2014-08-06 00:04:42 +02:00
Yorick Peterse
e0bbc81351
Added a very basic Namespace class.
2014-08-06 00:00:08 +02:00
Yorick Peterse
d7df908649
Trimmed XML inspect values.
2014-08-05 23:57:12 +02:00