Commit 7110e044 authored by Sylvain Schmitz's avatar Sylvain Schmitz

improved ast-size cutoff

parent 697d6032
......@@ -27,7 +27,7 @@ import org.w3c.xqparser.SimpleNode;
public abstract class XPathEntry {
final static int MAX_AST_SIZE = 1000;
final static int MAX_AST_SIZE = 345;
/**
* The name of the file from which this entry was extracted.
......@@ -74,6 +74,8 @@ public abstract class XPathEntry {
xxc.transform(getASTNode(), ast, eb);
domnode = ast.getFirstChild();
astSize = eb.getCount();
ast.setAttributeNS(XMLConstants.NULL_NS_URI,
"size", String.valueOf(astSize));
}
return domnode;
}
......@@ -91,8 +93,6 @@ public abstract class XPathEntry {
"line", getLine());
xpath.setAttributeNS(XMLConstants.NULL_NS_URI,
"column", getColumn());
xpath.setAttributeNS(XMLConstants.NULL_NS_URI,
"ast-size", String.valueOf(astSize));
for (Map.Entry<String,String> pair : getNamespaces().entrySet()) {
if (pair.getKey().equals(XMLConstants.DEFAULT_NS_PREFIX))
xpath.setAttributeNS
......@@ -105,16 +105,18 @@ public abstract class XPathEntry {
XMLConstants.XMLNS_ATTRIBUTE+":"+pair.getKey(),
pair.getValue());
}
if (!getEntryText().isEmpty()) {
Text text = doc.createTextNode(getEntryText());
Element query = doc.createElementNS
(XMLConstants.NULL_NS_URI, "query");
query.appendChild(text);
xpath.appendChild(query);
}
xpath.appendChild(ast);
if (astSize < MAX_AST_SIZE) {
if (!getEntryText().isEmpty()) {
Text text = doc.createTextNode(getEntryText());
Element query = doc.createElementNS
(XMLConstants.NULL_NS_URI, "query");
query.appendChild(text);
xpath.appendChild(query);
}
xpath.appendChild(ast);
Element schemas = doc.createElementNS
(XMLConstants.NULL_NS_URI, "schemas");
// validate
for (Map.Entry<String,String> result : sf.validate(domnode)) {
Element val = doc.createElementNS
......@@ -140,11 +142,12 @@ public abstract class XPathEntry {
"valid", "no");
val.appendChild(doc.createTextNode(msg));
}
xpath.appendChild(val);
schemas.appendChild(val);
}
xpath.appendChild(schemas);
}
else
xpath.appendChild(doc.createComment("AST too large for validation!"));
xpath.appendChild(doc.createComment("AST size "+astSize+" exceeds XPathEntry.MAX_AST_SIZE; no validation"));
// print
printer.transform(doc, os);
}
......
......@@ -5,11 +5,11 @@ path=$1
echo "\\toprule"
echo "Source & queries & XPath~1.0 & XPath~2.0 & XPath~3.0\\\\"
echo "\\midrule"
echo "DocBook `./numbers.sh $path/docbook.xml '<query>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "HTMLBook `./numbers.sh $path/htmlbook.xml '<query>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "DocBook `./numbers.sh $path/docbook.xml '<schemas>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "HTMLBook `./numbers.sh $path/htmlbook.xml '<schemas>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "\\midrule"
echo "eXist-db `./numbers.sh $path/existdb.xml '<query>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "HisTEI `./numbers.sh $path/histei.xml '<query>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "MarkLogic `./numbers.sh $path/marklogic.xml '<query>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "XQJSON `./numbers.sh $path/xqjson.xml '<query>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "eXist-db `./numbers.sh $path/existdb.xml '<schemas>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "HisTEI `./numbers.sh $path/histei.xml '<schemas>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "MarkLogic `./numbers.sh $path/marklogic.xml '<schemas>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "XQJSON `./numbers.sh $path/xqjson.xml '<schemas>' 'xpath-1.0.rnc.*yes' 'xpath-2.0.rnc.*yes' 'xpath-3.0.rnc.*yes'`\\\\"
echo "\\bottomrule"
......@@ -9,4 +9,4 @@ do
shift
done
#echo "& `grep '<query>' $1 | wc -l` & `grep 'xpath-1.0.rnc' $1 | grep 'yes' | wc -l` & `grep 'xpath-2.0.rnc' $1 | grep 'yes' | wc -l` & `grep 'xpath-3.0.rnc' $1 | grep 'yes' | wc -l`\\\\"
#echo "& `grep '<schemas>' $1 | wc -l` & `grep 'xpath-1.0.rnc' $1 | grep 'yes' | wc -l` & `grep 'xpath-2.0.rnc' $1 | grep 'yes' | wc -l` & `grep 'xpath-3.0.rnc' $1 | grep 'yes' | wc -l`\\\\"
......@@ -59,7 +59,7 @@
<xsl:param name="source"/>
<xsl:param name="target"/>
<xsl:param name="root"/>
<xsl:variable name="examples" select="$root//xpath[validation[@schema=$source/@file and @valid='yes'] and validation[@schema=$target/@file and @valid='no'] and ast/descendant::*[local-name() = 'xpathAxis']]"/>
<xsl:variable name="examples" select="$root//xpath[schemas/validation[@schema=$source/@file and @valid='yes'] and schemas/validation[@schema=$target/@file and @valid='no'] and ast/descendant::*[local-name() = 'xpathAxis']]"/>
<xsl:text>{ "z": </xsl:text><xsl:value-of select="count($examples)"/>
<xsl:if test="$examples">
<xsl:text>, "examples": [</xsl:text>
......@@ -87,6 +87,6 @@
<xsl:text>,</xsl:text>
<xsl:value-of select="$f/@color"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="count($root//xpath[validation[@schema=$f/@file and @valid='yes'] and ast/descendant::*[local-name() = 'xpathAxis']])"/>
<xsl:value-of select="count($root//xpath[schemas/validation[@schema=$f/@file and @valid='yes'] and ast/descendant::*[local-name() = 'xpathAxis']])"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
......@@ -63,7 +63,7 @@
<xsl:param name="source"/>
<xsl:param name="target"/>
<xsl:param name="root"/>
<xsl:value-of select="count($root//xpath[validation[@schema=$source/@file and @valid='yes'] and validation[@schema=$target/@file and @valid='no'] and ast/descendant::*[local-name() = 'xpathAxis']])"/>
<xsl:value-of select="count($root//xpath[schemas/validation[@schema=$source/@file and @valid='yes'] and schemas/validation[@schema=$target/@file and @valid='no'] and ast/descendant::*[local-name() = 'xpathAxis']])"/>
<xsl:if test="not($target is $fragments[last()])">
<xsl:text> &amp; </xsl:text>
</xsl:if>
......
......@@ -61,7 +61,7 @@
</xsl:call-template>
</xsl:for-each>
<!-- total number of entries in the fragment -->
<xsl:value-of select="count(document($benchmarks//benchmark/@href)//xpath[validation[@schema=$fragment/@file and @valid='yes'] and ast/descendant::*[local-name() = 'xpathAxis']])" />
<xsl:value-of select="count(document($benchmarks//benchmark/@href)//xpath[schemas/validation[@schema=$fragment/@file and @valid='yes'] and ast/descendant::*[local-name() = 'xpathAxis']])" />
<xsl:if test="not($fragment is $fragments[last()])">
<xsl:text> \\</xsl:text>
</xsl:if>
......@@ -72,7 +72,7 @@
<xsl:template name="entry">
<xsl:param name="fragment"/>
<xsl:param name="benchmark"/>
<xsl:value-of select="count(document($benchmark/@href)//xpath[validation[@schema=$fragment/@file and @valid='yes'] and ast/descendant::*[local-name() = 'xpathAxis']])"/>
<xsl:value-of select="count(document($benchmark/@href)//xpath[schemas/validation[@schema=$fragment/@file and @valid='yes'] and ast/descendant::*[local-name() = 'xpathAxis']])"/>
<xsl:text> &amp; </xsl:text>
</xsl:template>
......
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