Skip to content

Regression: contains(@attr, "value") fails in XPath under Xidel 0.9.9 but works in 0.9.8 #124

@hari-naga

Description

@hari-naga

Description
In Xidel version 0.9.9, the following XPath expression causes an error, whereas it works correctly in version 0.9.8:

cat sample.html | xidel - -s --xpath '//table[contains(@class, "history_table")]'

Error output:

Error:
err:XPTY0004: Invalid types for function contains#2.
Got: (attribute class {"history_table table "}, attribute class {"history_table"}), "history_table"
Expected: (string?, string?) as boolean
in pxp:contains(TXQTermNodeMatcher, TXQTermConstant)

in line 1 column 9
//table[contains(@class, "history_table")]
        ^^^^^^^^^^  error occurs around here

Possible backtrace:
  $000000000050A96D  RAISEERRORMESSAGE,  line 4736 of data/xquery.pas: perhaps Q{http://expath.org/ns/file}temp-dir + 607533 ? but unlikely
  $000000000050AC1E  CHECKORCONVERTTYPES,  line 4747 of data/xquery.pas: perhaps Q{http://expath.org/ns/file}temp-dir + 608222 ? but unlikely
  $000000000052F001  EVALUATE,  line 2807 of data/xquery_terms.inc: TXQTermNamedFunction + 417
  $000000000054DA7D  FILTERSEQUENCE,  line 9198 of data/xquery.pas: perhaps TXQTermTryCatch + 67933 ? but unlikely
  $000000000054F32E  FILTER,  line 9353 of data/xquery.pas: perhaps TXQTermTryCatch + 74254 ? but unlikely
  $000000000054EDA2  EXPANDSEQUENCE,  line 9554 of data/xquery.pas: perhaps TXQTermTryCatch + 72834 ? but unlikely
  $0000000000531F83  EVALUATE,  line 3267 of data/xquery_terms.inc: perhaps TXQTermBinaryOp + 3843 ? but unlikely
  $000000000051D2F3  EVALUATE,  line 7710 of data/xquery.pas: perhaps fn:concat + 47843 ? but unlikely
  $000000000051D0A5  EVALUATE,  line 7689 of data/xquery.pas: perhaps fn:concat + 47253 ? but unlikely
  $000000000045CE28  EVALUATEQUERY,  line 2236 of xidelbase.pas: perhaps ? ? but unlikely

Call xidel with --trace-stack to get an actual backtrace

Steps to Reproduce

  1. Use a simple HTML file containing: <table class="history_table table">...</table>
  2. Run
    cat sample.html | xidel - -s --xpath '//table[contains(@class, "history_table")]'
    

Expected Behavior
The XPath expression should return the table data as it did in version 0.9.8.
Actual Behavior
Xidel 0.9.9 throws an error indicating contains() received invalid types, suggesting a regression in how attribute values are treated.

Environment:

  • OS: Ubuntu 24.04 (aarch64 and x86_64)
  • Xidel Version: 0.9.9 (works in 0.9.8)
  • Terminal: Bash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions