Commit 1338f057 authored by David BAELDE's avatar David BAELDE

Merge branch 'master' of git.lsv.fr:schmitz/xpparser

parents 73a67dab 4bd889e7
......@@ -35,7 +35,6 @@ last.fun = element functionCallExpr {
},
element arguments { empty }?
}
| int
# Allowed axes before a [last()] predicate.
# Should be modified to a safe value when including this file.
......
# XPath fragment of XQueryX in Relax NG compact syntax
# Xpath expressions involving the function last() and intergers.
#
# Copyright (C) 2016-2017
# David Baelde, Anthony Lick and Sylvain Schmitz (ENS Cachan)
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
default namespace = "http://www.w3.org/2005/XQueryX"
namespace xqx = "http://www.w3.org/2005/XQueryX"
include "last.rnc"
last.fun |= int
......@@ -27,7 +27,7 @@ include "xpath-1.0-core-join.rnc" {
# primary |= varref
# join.primary |= varref
include "expr/last.rnc" {
include "expr/last_first.rnc" {
last.axis = axis
}
last.primary |= varref
......
......@@ -24,7 +24,7 @@ include "xpath-1.0-core-basic.rnc" {
}
# Allowing some use of last()
include "expr/last.rnc" {
include "expr/last_first.rnc" {
# Allowed axes before a [last()] predicate.
last.axis = axis # We have Regular XPath
}
......
......@@ -30,7 +30,7 @@ include "xpath-1.0-vertical-id.rnc" {
}
# Allowing some use of last()
include "expr/last.rnc" {
include "expr/last_first.rnc" {
# Allowed axes before a [last()] predicate.
last.axis = deterministic.axis | element xpathAxis {
string "ancestor" # With 'parent' and regular XPath
......
......@@ -24,7 +24,7 @@ include "xpath-1.0-vertical-basic.rnc" {
}
# Allowing some use of last()
include "expr/last.rnc" {
include "expr/last_first.rnc" {
# Allowed axes before a [last()] predicate.
last.axis = deterministic.axis | element xpathAxis {
string "ancestor" # With 'parent' and regular XPath
......
......@@ -22,7 +22,7 @@ namespace xqx = "http://www.w3.org/2005/XQueryX"
include "misc/join.rnc"
include "xpath-2.0-core-basic.rnc" {
start = join.expr
start = join.expr | last.dummy
}
join.op |= element ( intersectOp | isOp | nodeBeforeOp | nodeAfterOp ) {
......
......@@ -23,7 +23,9 @@
default namespace = "http://www.w3.org/2005/XQueryX"
namespace xqx = "http://www.w3.org/2005/XQueryX"
include "xpath-1.0-core-orig.rnc"
include "xpath-1.0-core-orig.rnc" {
start = expr | last.dummy
}
include "expr/varref.rnc"
primary |= varref
......@@ -40,5 +42,5 @@ op |= element ( intersectOp | exceptOp # path intersection
}
# Allow last() on arbitrary paths
include "expr/last.rnc"
include "expr/last_first.rnc"
predicates |= last.predicate
......@@ -62,3 +62,15 @@ benchmarks-xslt-full.xml: benchmarks-all-full.xml
grep -v 'type="xquery"' $< > $@
benchmarks-xquery-full.xml: benchmarks-all-full.xml
grep -v 'type="xslt"' $< > $@
contingency-size.dat: contingency-size.sh benchmarks-all-full.xml $(wildcard ../../benchmark/*-full.xml)
./contingency-size.sh `grep 'href' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'` > contingency-size.dat
chisquare-size: contingency-size.dat chisquare.R
./chisquare.R contingency-size.dat
contingency-axis-step.dat: contingency-axis-step.sh benchmarks-all-full.xml $(wildcard ../../benchmark/*-full.xml)
./contingency-axis-step.sh `grep 'href' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'` > contingency-axis-step.dat
chisquare-axis-step: contingency-axis-step.dat chisquare.R
./chisquare.R contingency-axis-step.dat
#!/usr/bin/Rscript
# compute Pearson's chi square of the contingency table provided as arg1
args <- commandArgs(TRUE)
contingency = read.table(args[1])
library(MASS)
chisq.test(contingency)
q(status=0)
#!/bin/bash
# compute contingency table of benchmark results
# with rows = `accepted by at least one full fragment'
# and cols = `contains at least one axis step'
# using list of files provided on command-line
fragments=( `grep 'file=' ../../relaxng/fragments-full.xml | sed 's/.*file=\"\([\.a-zA-Z0-9\-]*.rnc\).*/\1/g'` )
accepted="@schema=\"${fragments[0]}\""
for ((f = 1; f < ${#fragments[@]}; ++f))
do
accepted="$accepted or @schema=\"${fragments[f]}\""
done
# first row: accepted
value=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[ast//xqx:xpathAxis and schemas/validation[$accepted and @valid=\"yes\"]])" $@`
printf "$value\t"value=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[not(ast//xqx:xpathAxis) and schemas/validation[$accepted and @valid=\"yes\"]])" $@`
printf "$value\t"
echo
# second row: not accepted
value=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[ast//xqx:xpathAxis and not(schemas/validation[$accepted and @valid=\"yes\"])])" $@`
printf "$value\t"
value=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[not(ast//xqx:xpathAxis) and not(schemas/validation[$accepted and @valid=\"yes\"])])" $@`
printf "$value\t"
echo
#!/bin/bash
# compute contingency table of benchmark results
# with rows = `accepted by at least one full fragment'
# and cols = `query size'
# using list of files provided on command-line
MAX=`grep 'MAX_AST_SIZE =' ../../src/main/java/fr/lsv/xpparser/XPathEntry.java| sed -e 's/[^0-9]*\([0-9]*\).*/\1/'`
fragments=( `grep 'file=' ../../relaxng/fragments-full.xml | sed 's/.*file=\"\([\.a-zA-Z0-9\-]*.rnc\).*/\1/g'` )
accepted="@schema=\"${fragments[0]}\""
for ((f = 1; f < ${#fragments[@]}; ++f))
do
accepted="$accepted or @schema=\"${fragments[f]}\""
done
# first row: accepted
for ((i = 1; i < $MAX; ++i))
do
value=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[ast/@size=\"$i\" and schemas/validation[$accepted and @valid=\"yes\"]])" $@`
printf "$value\t"
done
echo
# second row: not accepted
for ((i = 1; i < $MAX; ++i))
do
value=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[ast/@size=\"$i\" and not(schemas/validation[$accepted and @valid=\"yes\"])])" $@`
printf "$value\t"
done
echo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment