Skip to content

Commit

Permalink
Extend XML::Reader with more LibXML methods (#5740)
Browse files Browse the repository at this point in the history
* Extend XML::Reader with more LibXML methods

This adds a couple of method bindings that come in handy when doing
pull parsing or hybrid parsing (search with pull then expand node).

* Work around incomplete xmlTextReaderNextSibling()

The current implementation of xmlTextReaderNextSibling() only works on
preparsed documents, so we need to detect the error returned if the
reader is not using a preparsed document and implement our own
next sibling by looking at reader internals.

* Fix XML::Reader#name/#value when not on node

This avoids segfaults when those methods are called before the first or
after the last read.

* Add XML::Type::NONE for XML::Reader#node_type

This fixes a problem where XML::Reader#node_type would return zero
before the first or after the last read, which previously had no
mapping in the XML::Type enum, so the value couldn't be checked.

* Document all XML::Reader methods

* Add specs for all XML::Reader methods

* Avoid Nil for XML::Reader string getters

instead return an empty string if the methods are called in an invalid
reader state (before the first or after the last read).

A special case is the #value method, which could also return nil if
called on a node without a text value, like `<tag>`, but here an empty
string also makes sense.

* Use explicit type for XML:Reader attribute methods

* Rename XML::Reader#attribute to #[]/#[]?

and implement behavior similar to XML::Node.
  • Loading branch information
felixbuenemann authored and RX14 committed Jun 29, 2018
1 parent 89b3867 commit 3696bb1
Show file tree
Hide file tree
Showing 4 changed files with 551 additions and 2 deletions.

0 comments on commit 3696bb1

Please sign in to comment.