README.md 3.22 KB
Newer Older
1
# XPath Parser and XPath Benchmark
Sylvain Schmitz's avatar
Sylvain Schmitz committed
2

Sylvain Schmitz's avatar
Sylvain Schmitz committed
3 4 5 6 7
__XPath Parser__ extracts [XPath expressions](https://www.w3.org/TR/xpath-30/)
from within [XQuery](https://www.w3.org/TR/xquery-30/) files or XML files, in
particular [XSLT](https://www.w3.org/TR/xslt-30/) files, and returns an XML
abstract syntax tree in [XQueryX](https://www.w3.org/TR/xqueryx-30/) for them.  
The program also provides facilities for checking this XQueryX output against
Sylvain Schmitz's avatar
Sylvain Schmitz committed
8 9
multiple [XML Schemas](https://www.w3.org/standards/techs/xmlschema) and
[RelaxNG Compact Schemas](http://relaxng.org/compact.html).
10

11 12 13 14 15
__XPath Parser__ has been used to construct a __benchmark__ of XPath
queries extracted from XSLT or XQuery files from several open-source
projects.  The lastest release of this benchmark is
[xpath-benchmark-1.0](http://www.lsv.fr/~schmitz/code/xpath-benchmark-1.0.tar.bz2).

Sylvain Schmitz's avatar
Sylvain Schmitz committed
16
This software development was funded in part by the
Sylvain Schmitz's avatar
Sylvain Schmitz committed
17
[ANR PRODAQ](http://projects.lsv.ens-cachan.fr/prodaq/) project.
Sylvain Schmitz's avatar
Sylvain Schmitz committed
18

19

20
## Building the Parser
21

Sylvain Schmitz's avatar
Sylvain Schmitz committed
22 23
Build with [Apache Ant](http://ant.apache.org/) by running `ant compile`.
This will download [Jing](http://www.thaiopensource.com/relaxng/jing.html).
24

Sylvain Schmitz's avatar
Sylvain Schmitz committed
25 26 27
If you wish to modify the XQuery 3.0 grammar in the [xgrammar](xgrammar/)
directory, running `ant javacc` will download the necessary libraries and
regenerate the parser sources.
28 29


30
## Building the Benchmark
31 32 33 34 35 36 37

The benchmark can be compiled and checked against Relax NG
specifications by running `ant` in the `benchmark` subdirectory. On
some machines an "out of memory" error may happen while building the
benchmark; in that case, it may help to tweak `MAX_AST_SIZE` in
`src/main/java/fr/lsv/xpparser/XPathEntry.java`.

38
The Relax NG specifications are defined in `relaxng/*rnc`. They are
39
briefly described, by group, in `relaxng/fragments-*.rnc` files.
40 41 42 43 44 45

The subdirectory `tools` contains utilities for extracting statistics
from the benchmark results. Check `tools/README.md` for more details.


## Running manually
46

Sylvain Schmitz's avatar
Sylvain Schmitz committed
47
Use the provided [xpparser](xpparser) script.  Typical examples: 
Sylvain Schmitz's avatar
Sylvain Schmitz committed
48

Sylvain Schmitz's avatar
Sylvain Schmitz committed
49
```shell
Sylvain Schmitz's avatar
Sylvain Schmitz committed
50
./xpparser --xslt xgrammar/*.xsl --xsd xgrammar/xquery-3.0.xsd --rnc relaxng/xpath*.rnc
Sylvain Schmitz's avatar
Sylvain Schmitz committed
51
echo '//foo/bar' | ./xpparser --xquery xslt/xqx2xql.xsl
Sylvain Schmitz's avatar
Sylvain Schmitz committed
52
```
Sylvain Schmitz's avatar
Sylvain Schmitz committed
53

Sylvain Schmitz's avatar
Sylvain Schmitz committed
54
Run `./xpparser -h` for command-line usage. 
55 56


Sylvain Schmitz's avatar
Sylvain Schmitz committed
57
## License
58

59 60
Copyright (C) 2016-2019
  David Baelde, Anthony Lick and Sylvain Schmitz (ENS Paris-Saclay).
Sylvain Schmitz's avatar
Sylvain Schmitz committed
61 62 63 64 65 66 67 68 69

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Sylvain Schmitz's avatar
Sylvain Schmitz committed
70 71
General Public License in [LICENSE](LICENSE) or http://www.gnu.org/licenses/
for more details.
Sylvain Schmitz's avatar
Sylvain Schmitz committed
72 73

This software or document includes material copied from or derived
Sylvain Schmitz's avatar
Sylvain Schmitz committed
74 75 76
from the [XPath/XQuery Applets](https://www.w3.org/2013/01/qt-applets/)
and the [XQueryX 3.0 W3C Recommendation of 08 April
2014](https://www.w3.org/TR/2014/REC-xqueryx-30-20140408/).  Copyright
Sylvain Schmitz's avatar
Sylvain Schmitz committed
77 78 79
(C) 2013-2014 W3C(R) (MIT, ERCIM, Keio, Beihang).  See
[xgrammar/LICENSE](xgrammar/LICENSE) or
http://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
80
for more details.