<commit_before>XPathQuery: query (remote) XML documents with XPath
==================================================

XPathQuery makes is easy to make queries on XML documents using various
engines. Right now [eXist-db](http://exist-db.org) and Nokogiri are supported.


Examples
--------

The main use of XPathQuery is to query remote XML databases without dealing
with the details such as request envelopes, deserialization and so on.

    # first we set up the query engine
    require 'xpathquery/exist'
    xml_remote = XPathQuery::Exist.new('http://localhost:8080/exist/rest/db')

    # then we perform the query and we get back an array of XML nodes
    results = xml_remote.query('//patron')
    results.map { |result| p result.class }
    # => [Nokogiri::XML::Element, Nokogiri::XML::Element, ...]


Rails logger integration
------------------------

If a logger is supplied during the engine initialization it will be used
to log the queries made and the results received.

The Rails logger can be easily integrated passing `Rails.logger` to the
engine constructor.

    xml = XPathQuery::Exist.new('http://localhost:8080/...', Rails.logger)

The messages will be logged at the `:debug` level.


Requirements
------------

The `xpathquery` gem depends on the `nokogiri` gem, even when the Nokogiri
engine is not used.

Additionally, the eXist-db backend depends on the `rest_client` gem.

This gem requires a modern Ruby implementation as MRI 2.1, JRuby or Rubinious.


Install
-------
<commit_msg>Example of query with namespaces<commit_after>XPathQuery: query (remote) XML documents with XPath
==================================================

XPathQuery makes is easy to make queries on XML documents using various
engines. Right now [eXist-db](http://exist-db.org) and Nokogiri are supported.


Examples
--------

The main use of XPathQuery is to query remote XML databases without dealing
with the details such as request envelopes, deserialization and so on.

    # first we set up the query engine
    require 'xpathquery/exist'
    xml_remote = XPathQuery::Exist.new('http://localhost:8080/exist/rest/db')

    # then we perform the query and we get back an array of XML nodes
    results = xml_remote.query('//patron')
    results.map { |result| p result.class }
    # => [Nokogiri::XML::Element, Nokogiri::XML::Element, ...]

Namespaces are supported and are simple to use

    ns = { 'foaf' => 'http://xmlns.com/foaf/0.1/' }
    results = nokogiri.query('//foaf:name', ns)


Rails logger integration
------------------------

If a logger is supplied during the engine initialization it will be used
to log the queries made and the results received.

The Rails logger can be easily integrated passing `Rails.logger` to the
engine constructor.

    xml = XPathQuery::Exist.new('http://localhost:8080/...', Rails.logger)

The messages will be logged at the `:debug` level.


Requirements
------------

The `xpathquery` gem depends on the `nokogiri` gem, even when the Nokogiri
engine is not used.

Additionally, the eXist-db backend depends on the `rest_client` gem.

This gem requires a modern Ruby implementation as MRI 2.1, JRuby or Rubinious.


Install
-------

{'fraction_non_alphanumeric': 0.14281230382925297, 'fraction_numerical': 0.006905210295040804, 'mean_word_length': 3.501412429378531, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6754233', 'n_tokens_mistral': 931, 'n_tokens_neox': 877, 'n_words': 368}