Closed GoogleCodeExporter closed 9 years ago
Thanks for the feature request. The support of XPath without exceptions is in
my todo
list. It's likely to make it into the next major release (which I expect to do
in a
month or so). I'll update this issue once there is something to report.
Original comment by arseny.k...@gmail.com
on 27 May 2010 at 4:14
Hello, I'm really interested in such enhancement in the main source tree. Some
month ago (v 0.5), I had to do it for our project (using macros) and I just
finished to redo it for 0.9
Here is the diff patch file
In short, all method which return node* now return NULL instead of exception if
PUGIXML_NO_EXCEPTIONS is set
xpath_lexer::next() assert false
I haven't tested a lot, only compile with/without PUGIXML_NO_EXCEPTIONS and run
a very basic test using pugixml but I don't think I have broke something
Original comment by renaud.g...@gmail.com
on 20 Jul 2010 at 8:34
Attachments:
Original comment by arseny.k...@gmail.com
on 21 Jul 2010 at 7:21
I'm increasing the issue priority - XPath without exceptions will definitely be
available in the next version. It may be available in the trunk soon, no
promises though.
Your patch is not ideal - it should work as long as all XPath queries are
valid, but otherwise you will experience invalid query results or even null
pointer dereferences. I am going to take a slightly different approach - the
internals of query compilation will not use exceptions at all, and the root
function (compile()) will get the compilation result - with error message and
error location - and either throw it in an exception object or store in query.
select_nodes and select_single_node will return empty node set and empty node,
respectively, if the query compilation failed or if the return type is not node
set.
Original comment by arseny.k...@gmail.com
on 21 Jul 2010 at 7:29
I agree it's a trivial patch to rapidly solve my problem (compile with
-fno-exception). As you say, I assume my queries are valid and never fall in
the exception case :)
Original comment by renaud.g...@gmail.com
on 23 Jul 2010 at 4:59
XPath implementation was considerably redesigned; as a result, it can now work
without exceptions, without STL or without both.
Using PUGIXML_NO_EXCEPTIONS now changes the XPath error handling mechanism: no
exceptions are ever thrown, all evaluate and select* calls return the default
value for incorrect queries, and you can check if the query compiled fine using
xpath_query as a boolean object (i.e. if (query)) or by calling result() method
and inspecting the error message/offset.
You can grab the updated source from trunk (note that there is no pugixpath.cpp
any more - just remove it from your project), or you can wait for the next
release (which is expected in November).
Original comment by arseny.k...@gmail.com
on 20 Sep 2010 at 7:16
pugixml-1.0 is out; it no longer requires exceptions to work, as noted above -
the error handling mechanism depends on whether PUGIXML_NO_EXCEPTIONS is on.
The documentation has additional details.
Original comment by arseny.k...@gmail.com
on 31 Oct 2010 at 6:20
Original issue reported on code.google.com by
flying.l...@gmail.com
on 27 May 2010 at 2:23