--- /dev/null
+//import javax.xml.xpath.*;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathException;
+import net.sf.saxon.xpath.XPathFactoryImpl;
+import net.sf.saxon.om.NodeInfo;
+import net.sf.saxon.type.Type;
+import org.xml.sax.*;
+import org.w3c.dom.*;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.*;
+import javax.xml.transform.stream.*;
+import java.util.ArrayList;
+
+public class XPathEvalSaxon {
+
+
+ public static void main(String args[]) {
+ try {
+
+
+ XPath xpath = (new XPathFactoryImpl()).newXPath();
+ String expression = args[1];
+ InputSource inputSource = new InputSource(args[0]);
+ long startTime = System.nanoTime();
+ @SuppressWarnings("unchecked")
+ ArrayList<NodeInfo> nodes = (ArrayList<NodeInfo>) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
+ long evalTime = (System.nanoTime() - startTime) / 1000000;
+ Transformer serializer = TransformerFactory.newInstance().newTransformer();
+ serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ StreamResult o = new StreamResult(System.out);
+ startTime = System.nanoTime();
+ System.out.println("<xml_result num=\"1\">");
+ for(int i = 0; i < nodes.size(); i++){
+ NodeInfo n = nodes.get(i);
+ switch (n.getNodeKind()) {
+ case Type.ATTRIBUTE:
+ System.out.print (n.getLocalPart() + "=" + n.getStringValue());
+ break;
+ default:
+ serializer.transform(n, o);
+ break;
+ };
+ System.out.println();
+ };
+ System.out.println("</xml_result>");
+ long printTime = (System.nanoTime() - startTime) / 1000000;
+ System.err.println("evaluation time: " + evalTime + "ms");
+ System.err.println("serialization time: " + printTime + "ms");
+ } catch (XPathException e) {
+ System.out.println (e.getCause());
+ } catch (Exception e) {
+ System.out.println(e);
+ };
+
+
+ }
+}
--- /dev/null
+#!/bin/sh
+
+javac XPathEval.java
+for xml in *.xml
+do
+ QUERIES="${xml}.queries"
+ RESULTS="${xml}.results"
+ cat "$QUERIES" | grep -v '^#' | while read qname query
+ do
+ printf "Generating reference for %s, %s ... " "${xml}" "${qname}"
+ java XPathEval "${xml}" "${query}" > "$RESULTS"/"${qname}_reference.xml" 2> "$RESULTS"/"${qname}_reference.log"
+ if [ $? -eq 0 ]
+ then
+ printf "ok\\n"
+ else
+ printf "ERROR\\n"
+ fi
+ done
+done
--- /dev/null
+#!/bin/sh
+
+javac -cp .:/tmp/saxon9he.jar XPathEvalSaxon.java
+for xml in *.xml
+do
+ QUERIES="${xml}.queries"
+ RESULTS="${xml}.results"
+ cat "$QUERIES" | grep -v '^#' | while read qname query
+ do
+ printf "Generating reference for %s, %s ... " "${xml}" "${qname}"
+ java -cp .:/tmp/saxon9he.jar XPathEvalSaxon "${xml}" "${query}" > "$RESULTS"/"${qname}_saxon.xml" 2> "$RESULTS"/"${qname}_saxon.log"
+ if [ $? -eq 0 ]
+ then
+ printf "ok\\n"
+ else
+ printf "ERROR\\n"
+ fi
+ done
+done
--- /dev/null
+#!/bin/sh
+
+MSG="Test 1 (single query: tatoo vs java implementation)"
+echo "$MSG" >> "$target"
+echo "$MSG"
+cat ${xml}.queries | grep -v '^#' | while read q query; do
+ echo -n "${xml} $q $query ... "
+ REF=${xml}.results/"$q"_jaxp.xml
+ OUTPUT=${xml}.results/"$q"_"$PACKAGE"_test1.xml
+ LOG=${xml}.results/"$q"_"$PACKAGE"_test1.log
+ "$BIN" -s -d ${xml} "$query" -o "$OUTPUT" > "$LOG" 2>&1
+ echo "Query: $q : $query" >> "$target"
+ cat "$LOG" | grep '^STATS' >> "$target"
+ echo -n "Diff: " >> "$target"
+ if $XMLDIFF "$REF" "$OUTPUT" >/dev/null 2>&1; then
+ echo ok
+ echo ok >> "$target"
+ else
+ echo failed
+ echo failed >> "$target"
+ exit 1
+ fi
+ echo '-------------------------------------------' >> "$target"
+done
--- /dev/null
+#!/bin/sh
+
+MSG="Test 2 (all queries sequentially vs all queries in parallel)"
+echo "$MSG" >> "$target"
+echo "$MSG"
+allqueries=`cat "${xml}".queries | grep -v '^#' | while read q query; do echo "'$query'"; done`
+echo -n "Running all queries ... "
+OUTPUTA="$xml".results/test2a_"$PACKAGE".xml
+LOG="$xml".results/test2a_"$PACKAGE".log
+echo -n "sequential ... "
+echo "$allqueries" | xargs $BIN -s -d "$xml" -o "$OUTPUTA" > "$LOG" 2>&1
+cat "$LOG" | grep '^STATS' >> "$target"
+
+OUTPUTB="$xml".results/test2b_"$PACKAGE".xml
+LOG="$xml".results/test2b_"$PACKAGE".log
+echo -n "parallel ... "
+echo "$allqueries" | xargs $BIN -p -s -d "$xml" -o "$OUTPUTB" > "$LOG" 2>&1
+cat "$LOG" | grep '^STATS' >> "$target"
+echo -n "Diff: " >> "$target"
+if diff "$OUTPUTA" "$OUTPUTB" >/dev/null 2>&1; then
+ echo ok
+ echo ok >> "$target"
+else
+ echo failed
+ echo failed >> "$target"
+ exit 1
+fi
+echo '-------------------------------------------' >> "$target"
--- /dev/null
+#!/bin/sh
+
+MSG="Test 3 (multiple queries composition: sequential vs parallel)"
+echo "$MSG" >> "$target"
+echo "$MSG"
+cat "${xml}".queries | grep -v '^#' | while read q query; do
+ echo -n "${xml} $q $query ... sequential ... "
+ OUTPUTA="${xml}".results/"$q"_"$PACKAGE"_test3a.xml
+ LOG="${xml}".results/"$q"_"$PACKAGE"_test3a.log
+ $SPLIT "$query" | xargs $BIN -s -C -d "${xml}" -o "$OUTPUTA" > "$LOG" 2>&1
+ echo "Query: $q : $query" >> "$target"
+ cat "$LOG" | grep '^STATS' >> "$target"
+
+ echo -n "parallel ... "
+ OUTPUTB="${xml}".results/"$q"_"$PACKAGE"_test3b.xml
+ LOG="${xml}".results/"$q"_"$PACKAGE"_test3b.log
+ $SPLIT "$query" | xargs $BIN -s -p -C -d "${xml}" -o "$OUTPUTB" > "$LOG" 2>&1
+ echo "Query: $q : $query" >> "$target"
+ cat "$LOG" | grep '^STATS' >> "$target"
+
+ echo -n "Diff: " >> "$target"
+ if diff "$OUTPUTA" "$OUTPUTB" >/dev/null 2>&1; then
+ echo ok
+ echo ok >> "$target"
+ else
+ echo failed
+ echo failed >> "$target"
+ exit 1
+ fi
+ echo '-------------------------------------------' >> "$target"
+done
--- /dev/null
+#!/bin/sh
+
+S="//M/ancestor::A"
+Q="$S"
+
+for i in `seq 1 30`
+do
+ src/tatoo.native -s -d tests/alphabet.xml -o /dev/null -c "$Q" 2> /tmp/log
+ ST=`grep 'Number of states' /tmp/log | cut -f 2 -d :`
+ TM=`grep 'evaluating query in' /tmp/log | cut -f 3 -d : | cut -f 1 -d m`
+ RU=`grep 'traversals' /tmp/log | cut -f 2 -d :`
+ echo "$i", "$ST", "$TM", "$RU"
+ Q="$Q""$S"
+done
+rm -f /tmp/log
--- /dev/null
+#!/bin/sh
+
+
+PROG="$1"
+BASEDIR="$2"
+SUMMARY=""
+
+output ()
+{
+ echo "$1"
+ if [ -f "$SUMMARY" ]
+ then
+ echo "$1" >> "$SUMMARY"
+ fi
+}
+
+for xml in "$BASEDIR"/*.xml
+do
+ QUERIES="$xml".queries
+ RESULTS="$xml".results
+ if [ -f "$QUERIES" -a -d "$RESULTS" ]
+ then
+ SUMMARY="$xml".summary
+ rm -f "$SUMMARY"
+ touch "$SUMMARY"
+ output "-- Testing file ${xml} -----------------"
+
+ cat "$QUERIES" | grep -v '^#' | while read QNAME QUERY
+ do
+
+ done
+
+
+ fi
+
+
+done
--- /dev/null
+A1 /site/closed_auctions/closed_auction/annotation/description/text/keyword
+A2 //closed_auction//keyword
+A3 /site/closed_auctions/closed_auction//keyword
+A4 /site/closed_auctions/closed_auction[annotation/description/text/keyword]/date
+A5 /site/closed_auctions/closed_auction[descendant::keyword]/date
+A6 /site/people/person[profile/gender and profile/age]/name
+A7 /site/people/person[phone or homepage]/name
+A8 /site/people/person[address and (phone or homepage) and (creditcard or profile)]/name
+B1 /site/regions/*/item[parent::namerica or parent::samerica]/name
+B2 //keyword/ancestor::listitem/text/keyword
+B3 /site/open_auctions/open_auction/bidder[following-sibling::bidder]
+B4 /site/open_auctions/open_auction/bidder[preceding-sibling::bidder]
+B5 /site/regions/*/item[following::item]/name
+B6 /site/regions/*/item[preceding::item]/name
+B7 //person[profile/@income]/name
+B8 /site/open_auctions/open_auction[bidder and not(bidder/preceding-sibling::bidder)]/interval
+B9 /site/open_auctions/open_auction[(not(bidder/following::bidder) or not(bidder/preceding::bidder)) or (bidder/following::bidder and bidder/preceding::bidder)]/interval
+B10 /site/open_auctions/open_auction[(not(bidder/following::bidder) or not(bidder/preceding::bidder)) and (bidder/following::bidder and bidder/preceding::bidder)]/interval
+B11 //open_auction/bidder/../bidder/../bidder/../interval
+B12 //item/@id/../@id/../@id/../@id/../name
+B13 //keyword/ancestor::parlist/descendant::keyword/ancestor::parlist/descendant::keyword/ancestor::parlist/descendant::keyword
--- /dev/null
+A1 /site/closed_auctions/closed_auction/annotation/description/text/keyword
+A2 //closed_auction//keyword
+A3 /site/closed_auctions/closed_auction//keyword
+A4 /site/closed_auctions/closed_auction[annotation/description/text/keyword]/date
+A5 /site/closed_auctions/closed_auction[descendant::keyword]/date
+A6 /site/people/person[profile/gender and profile/age]/name
+A7 /site/people/person[phone or homepage]/name
+A8 /site/people/person[address and (phone or homepage) and (creditcard or profile)]/name
+B1 /site/regions/*/item[parent::namerica or parent::samerica]/name
+B2 //keyword/ancestor::listitem/text/keyword
+B3 /site/open_auctions/open_auction/bidder[following-sibling::bidder]
+B4 /site/open_auctions/open_auction/bidder[preceding-sibling::bidder]
+B5 /site/regions/*/item[following::item]/name
+B6 /site/regions/*/item[preceding::item]/name
+B7 //person[profile/@income]/name
+B8 /site/open_auctions/open_auction[bidder and not(bidder/preceding-sibling::bidder)]/interval
+B9 /site/open_auctions/open_auction[(not(bidder/following::bidder) or not(bidder/preceding::bidder)) or (bidder/following::bidder and bidder/preceding::bidder)]/interval
+B10 /site/open_auctions/open_auction[(not(bidder/following::bidder) or not(bidder/preceding::bidder)) and (bidder/following::bidder and bidder/preceding::bidder)]/interval
+B11 //open_auction/bidder/../bidder/../bidder/../interval
+B12 //item/@id/../@id/../@id/../@id/../name
+B13 //keyword/ancestor::parlist/descendant::keyword/ancestor::parlist/descendant::keyword/ancestor::parlist/descendant::keyword
--- /dev/null
+A1 /site/closed_auctions/closed_auction/annotation/description/text/keyword
+A2 //closed_auction//keyword
+A3 /site/closed_auctions/closed_auction//keyword
+A4 /site/closed_auctions/closed_auction[annotation/description/text/keyword]/date
+A5 /site/closed_auctions/closed_auction[descendant::keyword]/date
+A6 /site/people/person[profile/gender and profile/age]/name
+A7 /site/people/person[phone or homepage]/name
+A8 /site/people/person[address and (phone or homepage) and (creditcard or profile)]/name
+B1 /site/regions/*/item[parent::namerica or parent::samerica]/name
+B2 //keyword/ancestor::listitem/text/keyword
+B3 /site/open_auctions/open_auction/bidder[following-sibling::bidder]
+B4 /site/open_auctions/open_auction/bidder[preceding-sibling::bidder]
+B5 /site/regions/*/item[following::item]/name
+B6 /site/regions/*/item[preceding::item]/name
+B7 //person[profile/@income]/name
+B8 /site/open_auctions/open_auction[bidder and not(bidder/preceding-sibling::bidder)]/interval
+B9 /site/open_auctions/open_auction[(not(bidder/following::bidder) or not(bidder/preceding::bidder)) or (bidder/following::bidder and bidder/preceding::bidder)]/interval
+B10 /site/open_auctions/open_auction[(not(bidder/following::bidder) or not(bidder/preceding::bidder)) and (bidder/following::bidder and bidder/preceding::bidder)]/interval
+B11 //open_auction/bidder/../bidder/../bidder/../interval
+B12 //item/@id/../@id/../@id/../@id/../name
+B13 //keyword/ancestor::parlist/descendant::keyword/ancestor::parlist/descendant::keyword/ancestor::parlist/descendant::keyword
--- /dev/null
+A1 /site/closed_auctions/closed_auction/annotation/description/text/keyword
+A2 //closed_auction//keyword
+A3 /site/closed_auctions/closed_auction//keyword
+A4 /site/closed_auctions/closed_auction[annotation/description/text/keyword]/date
+A5 /site/closed_auctions/closed_auction[descendant::keyword]/date
+A6 /site/people/person[profile/gender and profile/age]/name
+A7 /site/people/person[phone or homepage]/name
+A8 /site/people/person[address and (phone or homepage) and (creditcard or profile)]/name
+B1 /site/regions/*/item[parent::namerica or parent::samerica]/name
+B2 //keyword/ancestor::listitem/text/keyword
+B3 /site/open_auctions/open_auction/bidder[following-sibling::bidder]
+B4 /site/open_auctions/open_auction/bidder[preceding-sibling::bidder]
+B5 /site/regions/*/item[following::item]/name
+B6 /site/regions/*/item[preceding::item]/name
+B7 //person[profile/@income]/name
+B8 /site/open_auctions/open_auction[bidder and not(bidder/preceding-sibling::bidder)]/interval
+B9 /site/open_auctions/open_auction[(not(bidder/following::bidder) or not(bidder/preceding::bidder)) or (bidder/following::bidder and bidder/preceding::bidder)]/interval
+B10 /site/open_auctions/open_auction[(not(bidder/following::bidder) or not(bidder/preceding::bidder)) and (bidder/following::bidder and bidder/preceding::bidder)]/interval
+B11 //open_auction/bidder/../bidder/../bidder/../interval
+B12 //item/@id/../@id/../@id/../@id/../name
+B13 //keyword/ancestor::parlist/descendant::keyword/ancestor::parlist/descendant::keyword/ancestor::parlist/descendant::keyword