Commit 10558c71 authored by David BAELDE's avatar David BAELDE

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

parents 0c2ab9f5 937abb73
# XPath 3.0 fragment of XQueryX in Relax NG compact syntax with only
# standard functions
#
# Copyright (C) 2016-2018
# 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"
fn.math = external "fn/math.rnc"
fn.std = external "fn/standard.rnc"
include "xpath-3.0.rnc" {
fun = element functionCallExpr {
element functionName { fn.math | fn.std },
element arguments {
( expr | element argumentPlaceholder { empty } )*
}?
}
}
\ No newline at end of file
......@@ -2,15 +2,25 @@
<html>
<head>
<meta charset="utf-8">
<title>XPath fragments in the benchmark</title>
<link rel="stylesheet" type="text/css" href="prettify.min.css">
<title>XPath Benchmark</title>
<!--link rel="stylesheet" type="text/css" href="prettify.min.css"-->
<link rel="stylesheet" type="text/css" href="xpp.min.css">
<link rel="stylesheet" type="text/css" href="chord.min.css">
<script type="text/javascript"
<!--script type="text/javascript"
src="https://cdn.rawgit.com/google/code-prettify/master/loader/prettify.js"></script>
<script type="text/javascript" src="lang-xpath.min.js"></script>
<script type="text/javascript" src="lang-xpath.min.js"></script-->
<script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="https://d3js.org/queue.v1.min.js"></script>
<!--script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>
<link rel="stylesheet" href="tinyscrollbar.min.css" type="text/css" media="screen"/>
<script type="text/javascript" src="jquery.tinyscrollbar.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
var $scrollbar = $("#scrollbar1");
$scrollbar.tinyscrollbar();
});
</script-->
<body>
<h1>XPath fragments in @BENCHMARK@</h1>
<h2>(<span style="color:red">preliminary version</span>)</h2>
......@@ -34,7 +44,7 @@
<div id="left">
<aside style="position: relative; top:2px">
<p>Order: <select id="order">
<option value="count" selected>by Frequency</option>
<option value="count" selected>by Coverage</option>
<option value="name">by Name</option>
<option value="group">by Cluster</option>
</select>
......@@ -53,14 +63,16 @@ var width = 650,
height = 650,
outerRadius = Math.min(width, height) / 2 - 10,
innerRadius = outerRadius - 24;
logwidth = 200;
d3.select("body")
.style("width", width + matrixw + margin.left + margin.right +"px");
.style("width", width + matrixw + margin.left + margin.right + logwidth
+"px");
d3.select("#links")
.style("width", width + "px")
.style("height", height + "px");
d3.select("#log")
.style("width", matrixw + margin.left + margin.right +"px");
.style("width", matrixw + margin.left + margin.right + logwidth +"px");
d3.select("aside")
.style("left", matrixw + margin.left -20 +"px");
......
......@@ -143,7 +143,7 @@ function matrixgraph(fragments, matrix, maxentries) {
.attr("class", "prettyprint lang-xpath")
.text(d.replace("&quot;","'"));
});
PR.prettyPrint();
//PR.prettyPrint();
}
function mouseovercell(p) {
......@@ -381,7 +381,7 @@ function chordgraph(fragments, matrix, maxentries) {
.attr("class", "prettyprint lang-xpath")
.text(d.replace("&quot;","'"));
});
PR.prettyPrint();
//PR.prettyPrint();
}
}
......
......@@ -9,7 +9,7 @@ a { text-decoration: none; color: black }
a:hover { color: #666; text-decoration: underline; }
#links, #left {
float: left;
float: right;
}
#left { font-size: 10px; }
......@@ -28,6 +28,10 @@ a:hover { color: #666; text-decoration: underline; }
transition: opacity 0.5s ease-in-out;
background-color: white;
margin-bottom: 50px;
position: relative;
top: 2px;
}
#log ul { padding-left: 1em; }
#log li { margin-bottom: .3ex; }
\ No newline at end of file
#log div { overflow-y: auto; height: 370px; direction: rtl; }
#log p { direction: ltr; }
#log ul { padding-left: 1em; direction: ltr; }
#log li { margin-bottom: .3ex; }
\ No newline at end of file
all: dist.dat axis-count.tex size-gte-100.tex matrices xslt.dat xqy.dat coverage-size.tex coverage-axis-step.tex numqueries.tex MAXcount.tex composition.tex composition_full.tex all-full-cov-pc.tex all-full-cov.tex
all: dist.dat axis-count.tex size-gte-100.tex matrices xslt.dat xqy.dat xslt-std.dat xqy-std.dat coverage-size.tex coverage-axis-step.tex numqueries.tex MAXcount.tex composition.tex composition_full.tex all-full-cov-pc.tex all-full-cov.tex
SHELL := /bin/bash
......@@ -77,6 +77,12 @@ xslt.dat: bench.sh xslt-full.cov xslt-orig.cov $(wildcard ../../benchmark/*-full
xqy.dat: bench.sh xquery-full.cov xquery-orig.cov $(wildcard ../../benchmark/*-full.xml) benchmarks-all-full.xml
./bench.sh xquery-full.cov xquery-orig.cov `grep 'type="xquery"' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'` > xqy.dat 2> minmax-xqy.tex
xslt-std.dat: bench-std.sh xslt-full.cov xslt-orig.cov $(wildcard ../../benchmark/*-full.xml) benchmarks-all-full.xml
./bench-std.sh xslt-full.cov xslt-orig.cov `grep 'type="xslt"' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'` > xslt.dat 2> minmax-std-xslt.tex
xqy-std.dat: bench-std.sh xquery-full.cov xquery-orig.cov $(wildcard ../../benchmark/*-full.xml) benchmarks-all-full.xml
./bench-std.sh xquery-full.cov xquery-orig.cov `grep 'type="xquery"' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'` > xqy.dat 2> minmax-std-xqy.tex
test.pdf: xslt.dat xqy.dat test.tex
pdflatex --shell-escape test.tex
......
#!/bin/bash
coverage_full=`cat $1`
shift
coverage_orig=`cat $1`
shift
# which files to take into account
files="$@"
# which XPath fragments to take into account
fragments=( `grep 'file=' ../../relaxng/fragments-full.xml | sed 's/.*file=\"\([\.a-zA-Z0-9\-]*.rnc\).*/\1/g'` )
names=( `grep 'nametex=' ../../relaxng/fragments-full.xml | sed 's/.*nametex=\"\([^\"]*\)\"/\1/g'` )
# which variants of each fragment (full variant is implicit)
variants=( "extra" "full" "orig" )
# the coverage of XPath 3.0
total=`grep 'xpath-3.0-std.rnc.*yes' $files | wc -l`
max=0
maxf=0
min=$total
minf=0
# main loop on every fragment
for ((f=0; f<${#fragments[@]}; ++f))
do
fname=`echo ${names[f]} | sed 's/~/ /'`
printf "\"\\\\\\\textsf{$fname}\"\t" # the fragment's name
if [ ${#fname} -lt 7 ]
then
printf "\t"
fi
for ((v=0; v<${#variants[@]}; ++v))
do
name=$(echo ${fragments[f]} | sed s/[a-z]*.rnc/${variants[v]}.rnc/)
if [ "${variants[v]}" = "full" ]
then
name=${fragments[f]}
fi
# reserve `extras' to the positive and core 1.0 fragments
if [ "${variants[v]}" = "extra" ]
then
if [ "${names[f]}" = "Positive" ] #-o "${names[f]}" = "Core~1.0" ]
then
:
else
name="thisisadummy"
fi
fi
count=`grep $name.*yes $files | wc -l`
percent=`echo "scale=2; 100*$count/$total" | bc`
printf "$percent\t"
# update min/max
if [ $v -eq 1 ]
then
if [ $min -gt $count ] && [ "${names[f]}" != "Downward" ] && [ "${names[f]}" != "Forward" ]
then
min=$count
minf=$f
fi
if [ $max -lt $count ]
then
max=$count
maxf=$f
fi
fi
done
echo
done
minpercent=`echo "scale=2; 100*$min/$total" | bc`
maxpercent=`echo "scale=2; 100*$max/$total" | bc`
printf "$minpercent\\\\%% for \\\\textsf{" >&2
if [ "${names[minf]}" != "Core~1.0" ] && [ "${names[minf]}" != "Core~2.0" ]
then
printf "${names[minf]}\\\\-XPath" >&2
else
mname=`echo "${names[minf]}" | sed -e 's/~/\\\\-XPath~/'`
printf "$mname" >&2
fi
printf "} and~" >&2
printf "$maxpercent\\\\%% for \\\\textsf{" >&2
if [ "${names[maxf]}" != "Core~1.0" ] && [ "${names[maxf]}" != "Core~2.0" ]
then
printf "${names[maxf]}\\\\-XPath" >&2
else
mname=`echo "${names[maxf]}" | sed -e 's/~/\\\\-XPath~/'`
printf "$mname" >&2
fi
printf "}" >&2
# printf '"\\\\textit{Combined}"'
# printf "\t0\t"
# percent=`echo "scale=2; 100*$coverage_full/$total" | bc`
# printf "$percent" > ext-overall-cov.tex
# percent=`echo "scale=2; 100*$coverage_orig/$total" | bc`
# printf "$percent\n"
......@@ -3,9 +3,10 @@
xslt=`grep 'xslt' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'`
xquery=`grep 'xquery' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'`
printf '\\begin{tabular}{lrrrr}\n'
printf '\\begin{tabular}{lrrrrr}\n'
printf '\\toprule\n'
printf 'Source & \\!\\!queries & \\!\\!XPath\\,1.0 & \\!\\!XPath\\,2.0 & \\!\\!XPath\,3.0\\\\\n'
printf 'Sources & Queries & \\multicolumn{4}{c}{Coverage}\\\\\n'
printf ' & & XPath\\,1.0 & XPath\\,2.0 & XPath\,3.0 & XPath\,3.0\,std\\\\\n'
printf '\\midrule\n'
# total number of XSLT queries
......@@ -25,6 +26,15 @@ do
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
done
count=0
for file in $xslt
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-3.0-std.rnc\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[4]=$count
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
printf '\\\\\n'
N=$n
......@@ -45,13 +55,22 @@ do
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
done
count=0
for file in $xquery
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-3.0-std.rnc\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[4]=$((count + counts[4]))
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
printf '\\\\\n'
N=$((N + n))
printf '\\midrule\n'
printf 'Total '
printf "& %'.0f " $N
for ((i=1; i < 4; ++i))
for ((i=1; i < 5; ++i))
do
count=${counts[i]}
percent=`echo "scale=1; 100*$count/$N" | bc`
......
#!/bin/bash
fragment='xpath-2.0-core-join.rnc'
std='xpath-3.0-std.rnc'
xslt=`grep 'xslt' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'`
xquery=`grep 'xquery' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'`
printf '\\begin{tabular}{lrrrrr}\n'
printf '\\begin{tabular}{lrrrrrr}\n'
printf '\\toprule\n'
printf 'Source & queries & XPath\\,1.0 & XPath\\,2.0 & XPath\,3.0 & \\textsf{CoreXPath~2.0}\\\\\n'
printf ' & & & & & extended\\\\\n'
printf 'Source & queries & XPath\\,1.0 & XPath\\,2.0 & XPath\,3.0 & XPath\,3.0\,std & \\textsf{Core~2.0}\\\\\n'
printf ' & & & & & & extended\\\\\n'
printf '\\midrule\n'
# XSLT files
......@@ -27,6 +28,9 @@ do
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
done
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$std\" and @valid=\"yes\"]])" $file`
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$fragment\" and @valid=\"yes\"]])" $file`
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
......@@ -42,25 +46,36 @@ printf "& %'.0f " $n
#coverage of standard XPath languages
for ((i=1; i < 4; ++i))
do
count=0
for file in $xslt
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-$i.0.rnc\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[$i]=$count
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
count=0
for file in $xslt
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-$i.0.rnc\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[$i]=$count
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
done
# std
count=0
for file in $xslt
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$fragment\" and @valid=\"yes\"]])" $file`
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$std\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[4]=$count
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
# Core 2.0
count=0
for file in $xslt
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$fragment\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[5]=$count
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
printf '\\\\\n'
printf '\\midrule\n'
......@@ -82,6 +97,9 @@ do
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
done
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$std\" and @valid=\"yes\"]])" $file`
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$fragment\" and @valid=\"yes\"]])" $file`
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
......@@ -97,58 +115,49 @@ printf "& %'.0f " $n
# coverage of standard XPath languages
for ((i=1; i < 4; ++i))
do
count=0
for file in $xquery
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-$i.0.rnc\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[$i]=$((count + counts[i]))
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
count=0
for file in $xquery
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-$i.0.rnc\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[$i]=$((count + counts[i]))
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
done
count=0
for file in $xquery
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$fragment\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[4]=$((count + counts[i]))
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
count=0
# std
for file in $xquery
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$std\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[4]=$((count + counts[4]))
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
# Core 2.0
count=0
for file in $xquery
do
c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"$fragment\" and @valid=\"yes\"]])" $file`
count=$((count+c))
done
counts[5]=$((count + counts[5]))
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
printf '\\\\\n'
N=$((N + n))
printf '\\midrule\n'
printf 'Total '
printf "& %'.0f " $N
for ((i=1; i < 5; ++i))
for ((i=1; i < 6; ++i))
do
count=${counts[i]}
percent=`echo "scale=1; 100*$count/$N" | bc`
printf "& $percent\\\\%% "
count=${counts[i]}
percent=`echo "scale=1; 100*$count/$N" | bc`
printf "& $percent\\\\%% "
done
printf '\\\\\n'
printf '\\bottomrule\n'
printf '\\end{tabular}\n'
# \begin{tabular}{lrrrr}
# \toprule
# Source & \!\!queries & \!\!XPath\,1.0 & \!\!XPath\,2.0 & \!\!XPath\,3.0\\
# % \midrule
# % W3C QT & 207 & 132 & 138 & 207\\
# % XPathMark & 38 & 38 & 38 & 38\\
# \midrule
# DocBook & 7,620 & 7,620 & 7,620 & 7,620 \\
# HTMLBook & 752 & 752 & 752 & 752 \\
# eXist-db & 1,236 & 955 & 1,105 & 1,236 \\
# HisTEI & 483 & 361 & 471 & 483 \\
# MarkLogic & 196 & 139 & 184 & 191 \\
# XQJSON & 90 & 67 & 90 & 90 \\
# \midrule
# Total & 10,377 & 9,894 & 10,222 & 10,372\\
# & & (95\%) & (98\%) & (100\%)\\
# \bottomrule
# \end{tabular}
......@@ -66,11 +66,13 @@
<xsl:text>{ "z": </xsl:text><xsl:value-of select="count($examples)"/>
<xsl:if test="$examples">
<xsl:text>, "examples": [</xsl:text>
<xsl:for-each select="$examples[position() &lt;= $nexamples]">
<!--xsl:for-each select="$examples[position() &lt;= $nexamples]"-->
<xsl:for-each select="$examples">
<xsl:text>"</xsl:text><xsl:value-of
select="replace(replace(normalize-space(current()/query),'&quot;',&quot;'&quot;),'\\','\\\\')"/>
<xsl:text>"</xsl:text>
<xsl:if test="position() != last() and position() &lt; $nexamples">
<!--xsl:if test="position() != last() and position() &lt; $nexamples"-->
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
......
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