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
56341b5585
Cleaned up lexing of comments/cdata.
...
Thanks to @whitequark for suggesting the use of the "--" operator.
2014-08-16 16:03:55 +02:00
Yorick Peterse
0d7609da88
Support for parsing XML processing instructions.
2014-08-15 22:23:26 +02:00
Yorick Peterse
2c488f92be
Cleaned up marking of comments/cdata tags.
2014-08-15 22:05:09 +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
4e8cca258c
Fixed lexing of XML CDATA tags.
2014-08-15 20:47:58 +02:00
Yorick Peterse
81edce2eb8
Fixed lexing of XML comments.
...
The previous setup would consume too much. For example the following HTML:
<a><!--foo--><b><!--bar--></b></a>
would result in the following T_COMMENT token:
"foo--><b><!--bar"
The new setup requires the marking of a start position. I'm not a huge fan of
this but there doesn't appear to be a way around this.
2014-08-15 20:42:32 +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
f2fe2a4b47
Failing XPath spec for double slashes.
...
The lexer doesn't lex things correctly due to "//" and "/" both being separate
rules. As a result the lexer emits two T_SLASH tokens for queries such as
".//foo".
2014-08-13 00:37:12 +02:00
Yorick Peterse
f4ae83498e
Eval specs for the self axis short form.
2014-08-11 09:35:01 +02:00
Yorick Peterse
ffcefa92a7
Eval specs for the descendant-or-self short axis.
...
This currently fails due to the node() function not being implemented just yet.
2014-08-11 09:33:09 +02:00
Yorick Peterse
aef3e0f27e
Evaluator specs for the attribute axis short form.
2014-08-11 09:32:45 +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
78da274452
Updated XPath specs for better namespace handling.
2014-08-11 00:42:06 +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