Specific adapter limitations
Ox adapter
XPath limitations
The Ox adapter uses a custom "XPath-to-locate" translation engine.
The following XPath features are NOT supported:
-
Attribute value predicates:
//book[@id='123']❌ -
Logical operators:
//book[@id and @title]❌ -
Position predicates:
//book[1],//book[last()]❌ -
Text predicates:
//book[text()='Title']❌ -
Namespace queries:
//ns:element❌ -
Parent axis:
//child/..❌ -
Sibling axes:
following-sibling::*❌ -
XPath functions:
count(),concat(), etc. ❌
Workaround: Use Ruby enumerable methods after basic queries:
# Instead of: doc.xpath("//book[@id='123']")
# Use:
doc.xpath("//book").find { |book| book["id"] == "123" }| For complete XPath 1.0 specification with zero limitations today, use Nokogiri or Oga adapters. |
Element Ordering in Round-Trip Tests
| Round-trip tests for Ox are experimental Ox round-trip tests (
For production use with complex XML, prefer Nokogiri or Oga adapters. |
The Ox adapter produces elements in a different order than other adapters for certain fixtures with complex nested structures. In round-trip tests, this causes the elements_with_attributes array length comparison to fail, even though the semantic equivalence check (double round-trip) passes.
Known affected fixtures:
-
niso-jats/element_citation.xml -
niso-jats/pnas_sample.xml -
metanorma/collection1nested.xml
This is a known limitation tracked in the round-trip test suite via KNOWN_ELEMENT_ORDERING_ISSUES. The elements_with_attributes comparison is automatically skipped for these Ox adapter pairs.
See also:
-
HeadedOx adapter - Ox with full XPath support