ilinsky / xpath2.js Goto Github PK
View Code? Open in Web Editor NEWxpath.js - Open source XPath 2.0 implementation in JavaScript (DOM agnostic)
License: MIT License
xpath.js - Open source XPath 2.0 implementation in JavaScript (DOM agnostic)
License: MIT License
Hi,
can you please let me know on how to include these files to work on XPath 2.0 expressions?
Thanks,
Jeya
Hello,
Great library! How can I get a copy-paste-able version of this library minified? Breaking it up into many files is not practical for my use case (Chrome developer console).
Thanks!
Hi,
I would like to use a custom function in xpath, but I don't see any clear documentation on how to do that.
Let's say that I want to use a custom match for regular expressions. How can I write one?
I looked at StaticContext, but it is not clear for me.
Thanks,
Alex.
Hey. Is there support for regular expressions in your library?
I tried:
document.evaluate("//*[matches(@Class, 'ars')]", document, null, XPathResult.ANY_TYPE, null).iterateNext();
error:
Uncaught DOMException: Failed to execute 'evaluate' on 'Document': The string '//*[matches(@Class, 'ars')]' is not a valid XPath expression.
Thank you
This looks like a very interesting project. Before looking into this deeper, is there anything missing in the implementation?
It seems that the engine is not parsing/executing processing-instruction('foo')
paths properly (i.e. PIs with a custom name). I noticed the tests for this are commented out. Is this by design?
I'm trying to use your library with my nodeJS application, but when I try to use the snippet you have on your front page (README.md page is the one I'm referring to) I cannot access to the domClasses attribute from the xmldom library.
I've check I'm using the latest version of the xmldom (0.1.22) and the latest of your library too (0.3.2)
Anything that I'm missing? Something have change that makes your snippets unusable?
Thx!
const xpath = require("xpath2.js");
const xmldom = require("xmldom");
const document = new xmldom.DOMParser().parseFromString("<div><button>Click me</button></div>");
const result = xpath.evaluate("//button[starts-with(., 'Click')]", document);
> node a.js
C:\project\node_modules\xpath2.js\lib\expressions\primary\FunctionCall.js:71
throw new cException("XPST0017"
^
Error
at Object.<anonymous> (C:\project\node_modules\xpath2.js\lib\classes\Exception.js:17:24)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\project\node_modules\xpath2.js\lib\types\schema\simple\atomic\XSDateTime.js:1:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) {
code: 'XPST0017',
message: 'Unknown user function: starts-with()'
}
Are you familiar with xqib?
Hi Sergey,
I have found one little bug in your library. Within a file XSInteger.js in method cXSInteger.cast you have used unreferenced class cXSUntypedAtomic.
so only needed to solve of this problem is add one line of code with reference to it on top of this file.
var cXSUntypedAtomic = require('./../XSUntypedAtomic');
thank you in advance
Ivan
The Spec explicitly indicates two signatures:
fn:string-join($arg1 as xs:anyAtomicType*) as xs:string
fn:string-join($arg1 as xs:anyAtomicType*, $arg2 as xs:string) as xs:string
If I pass an xpath like the following: fn:string-join(fn:reverse(fn:tokenize(fn:replace(/Row/IBAG, "(.)", "$1 "), "\s+")))
it will fail unless I explicitly add an empty string for the second parameter fn:string-join(fn:reverse(fn:tokenize(fn:replace(/Row/IBAG, "(.)", "$1 "), "\s+")), "")
.
As stated in the spec:
The effect of calling the single-argument version of this function is the same as calling the two-argument version with $arg2 set to a zero-length string.
The function returns an xs:string created by casting each item in the sequence $arg1 to an xs:string, and then concatenating the result strings in order, using the value of $arg2 as a separator between adjacent strings. If the value of $arg2 is the zero-length string, then the members of $arg1 are concatenated without a separator.
Reported at ilinsky/jquery-xpath#22
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.