ilinsky / jquery-xpath

jQuery XPath plugin (with full XPath 2.0 language support)
180 stars 64 forks source link

Does not use internal result of xpath expression #22

Open yshrini opened 6 years ago

yshrini commented 6 years ago

I am exploring use of this library and found that if there is sub xpath expression, evaluation throws error.

e.g 1: $(document).xpath("replace(replace('This is the test string','the',''), 'test', 'best')") throws error { Code:"XPTY0004" message:"Type is not appropriate for the context in which the expression occurs" } e.g 2: $(document).xpath("contcat(concat('a', 'b'),'c')") throws error Code:"XPST0017" message : Expanded QName and number of arguments in a function call do not match the name and arity of a function signature"

ilinsky commented 6 years ago

concerning 1 - there is a bug in the implementation: https://github.com/ilinsky/xpath.js/blob/master/src/functions/string.js#L353 , where replace function returns boolean instead of a string (because of a typo)!, hence passing boolean second time in a replace throws error.. concerning 2 - when you correct spelling error: contcat -> concat, the return will be correct.

So, there is generally no problem with nested xpath expressions.

ilinsky commented 6 years ago

Filled an issue https://github.com/ilinsky/xpath.js/issues/11