|
From: <pm_...@us...> - 2012-02-07 08:59:31
|
Revision: 4524
http://mxquery.svn.sourceforge.net/mxquery/?rev=4524&view=rev
Author: pm_fischer
Date: 2012-02-07 08:59:24 +0000 (Tue, 07 Feb 2012)
Log Message:
-----------
- Merge updated projection tests
- Adapt classpath to refer to the up-to-date QName class
- consider fixed context scoping in order by also for projection
Modified Paths:
--------------
trunk/MXQuery/.classpath
trunk/MXQuery/src/ch/ethz/mxquery/iterators/GOrderByIterator.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionXMarkTests.java
Modified: trunk/MXQuery/.classpath
===================================================================
--- trunk/MXQuery/.classpath 2012-02-07 08:57:31 UTC (rev 4523)
+++ trunk/MXQuery/.classpath 2012-02-07 08:59:24 UTC (rev 4524)
@@ -1,16 +1,15 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry exported="true" kind="lib" path="lib/tagsoup-1.2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/jax-1_1-fr-qname-class.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/kxml2-min-2.3.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/xmlpull_1_1_3_4c.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/jsr173_1.0_api.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/servlet-api.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/xqjapi.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/xercesImpl.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/commons-cli-1.2.jar"/>
- <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry exported="true" kind="lib" path="lib/tagsoup-1.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jax-1_1-fr-qname-class.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/kxml2-min-2.3.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/xmlpull_1_1_3_4c.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/servlet-api.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/xqjapi.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/xercesImpl.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-cli-1.2.jar"/>
+ <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/GOrderByIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/GOrderByIterator.java 2012-02-07 08:57:31 UTC (rev 4523)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/GOrderByIterator.java 2012-02-07 08:59:24 UTC (rev 4524)
@@ -316,6 +316,22 @@
}
public ObjectObjectPair getProjectionPaths() throws StaticException {
+
+ // order by re-binds variables, so we need to assign
+ // the projection path of the original variables to them
+
+ for (int i = 0; i < orderedVarsQNames.length; i++) {
+ VariableHolder varholder = context
+ .getVariable(orderedVarsQNames[i]);
+ // use parent context for original variables (given the FLWOR nesting
+ // TODO: does this always work?
+ VariableHolder origvar = context.getParent()
+ .getVariable(orderedVarsQNames[i]);
+ varholder.setProjectionPaths(origvar.getProjectionPaths());
+ }
+
+
+
Set returned = new Set();
Set used = new Set();
Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java
===================================================================
--- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java 2012-02-07 08:57:31 UTC (rev 4523)
+++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java 2012-02-07 08:59:24 UTC (rev 4524)
@@ -3,14 +3,27 @@
*/
package ch.ethz.mxquery.test;
+import java.io.StringReader;
import java.util.Enumeration;
+import java.util.Vector;
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.XQName;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.model.AbstractStep;
+import ch.ethz.mxquery.model.StepInformation;
+import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.query.PreparedStatement;
import ch.ethz.mxquery.testsuite.XQueryTestBase;
import ch.ethz.mxquery.util.Hashtable;
import ch.ethz.mxquery.util.ObjectObjectPair;
import ch.ethz.mxquery.util.Set;
+import ch.ethz.mxquery.xdmio.XDMInputFactory;
+import ch.ethz.mxquery.xdmio.XDMSerializer;
+import ch.ethz.mxquery.xdmio.XDMSerializerSettings;
+import ch.ethz.mxquery.xdmio.XMLSource;
/**
@@ -21,7 +34,578 @@
private static final String TEST_PROJECTION_PREFIX = "ProjectionTests";
private static final String TEST_PROJECTION_QUERY_PREFIX = TEST_PROJECTION_PREFIX+"/queries/";
+ private static final String TEST_PROJECTION_DOC_PREFIX = TEST_PROJECTION_PREFIX+"/docs/";
+ public void test_SinglePath_RootOnly() throws MXQueryException{
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ String xmlDoc = "<a/>";
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(setUpPath1Keep());
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("", res);
+
+}
+
+
+
+ public void test_SinglePath_OneChild() throws MXQueryException{
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ String xmlDoc = "<a><b/></a>";
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("", res);
+ }
+
+ public void test_SinglePath_SingleKeepNoChilds() throws MXQueryException{
+ String xmlDoc = "<a><b><c/></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+ public void test_SinglePath_SingleNoChilds() throws MXQueryException{
+ String xmlDoc = "<a><b><c/></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+
+ public void test_SinglePath_SingleKeepTextChild() throws MXQueryException{
+ String xmlDoc = "<a><b><c>Text</c></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c>Text</c></b></a>", res);
+
+ }
+
+ public void test_SinglePath_SingleTextChild() throws MXQueryException{
+ String xmlDoc = "<a><b><c>Text</c></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+
+ public void test_SinglePath_SingleKeepElementChild1() throws MXQueryException{
+ String xmlDoc = "<a><b><c><d/></c></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c><d/></c></b></a>", res);
+
+ }
+
+ public void test_SinglePath_SingleElementChild1() throws MXQueryException{
+ String xmlDoc = "<a><b><c><d/></c></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+
+ public void test_SinglePath_SingleKeepElementChild2() throws MXQueryException{
+ String xmlDoc = "<a><b><c><d/><e/></c></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c><d/><e/></c></b></a>", res);
+
+ }
+
+
+ public void test_SinglePath_SingleElementChild2() throws MXQueryException{
+ String xmlDoc = "<a><b><c><d/><e/></c></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+
+ public void test_SinglePath_BeforeAfterKeep() throws MXQueryException{
+ String xmlDoc = "<a><x/><b><c><d/><e/></c></b><y/></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c><d/><e/></c></b></a>", res);
+
+ }
+
+
+ public void test_SinglePath_BeforeAfter() throws MXQueryException{
+ String xmlDoc = "<a><x/><b><c><d/><e/></c></b><y/></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+
+ public void test_SinglePath_OneEmptyKeep() throws MXQueryException{
+ String xmlDoc = "<a><b><c><d/><e/></c></b><b/></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c><d/><e/></c></b></a>", res);
+// showProjectedQuery(reader, projPaths);
+
+ }
+
+
+ public void test_SinglePath_OneEmpty() throws MXQueryException{
+ String xmlDoc = "<a><b><c><d/><e/></c></b><b/></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+ //showProjectedQuery(reader, projPaths);
+
+ }
+
+
+ public void test_SinglePath_TwoEmptyKeep() throws MXQueryException{
+ String xmlDoc = "<a><b/><b><c><d/><e/></c></b><b/></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c><d/><e/></c></b></a>", res);
+// showProjectedQuery(reader, projPaths);
+
+ }
+
+
+ public void test_SinglePath_TwoEmpty() throws MXQueryException{
+ String xmlDoc = "<a><b/><b><c><d/><e/></c></b><b/></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+ //showProjectedQuery(reader, projPaths);
+
+ }
+
+
+ public void test_SinglePath_SingleKeepTwoElementChild() throws MXQueryException{
+ String xmlDoc = "<a><b><c><d/></c><c></c></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c><d/></c><c/></b></a>", res);
+
+ }
+
+ public void test_SinglePath_SingleTwoElementChild() throws MXQueryException{
+ String xmlDoc = "<a><b><c><d/></c><c/></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/><c/></b></a>", res);
+ //showProjectedQuery(reader, projPaths);
+
+ }
+
+
+ public void test_TwoPaths_SingleKeepNoChilds1() throws MXQueryException{
+ String xmlDoc = "<a><b><c/></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+ Vector path2 = setUpPath2();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ projPaths.addElement(path2);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+
+ public void test_TwoPaths_SingleKeepNoChilds2() throws MXQueryException{
+ String xmlDoc = "<a><d><e/></d></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+ Vector path2 = setUpPath2();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ projPaths.addElement(path2);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><d/></a>", res);
+
+ }
+
+
+ public void test_TwoPaths_PaperSample1() throws MXQueryException{
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"proj1.xml", true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpPath1Keep();
+ Vector path2 = setUpPath2();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ projPaths.addElement(path2);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c><f/></c></b><d/></a>", res);
+
+ }
+
+
+ // Test for kept node above, not produced below: Paths={/a/b, /a/b/c/d}, <a><b><c/></b></a> => <a><b/></a>
+
+ public void test_TwoPaths_KeepAbove1() throws MXQueryException{
+
+ String xmlDoc = "<a><b><c/></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = new Vector();
+ path1.addElement(AbstractStep.ROOT_STEP);
+ path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a")));
+ path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("b")));
+ path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("c")));
+ path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("d")));
+
+ Vector path2 = new Vector();
+ path2.addElement(AbstractStep.ROOT_STEP);
+ path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a")));
+ path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("b")));
+
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ projPaths.addElement(path2);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b/></a>", res);
+// showProjectedQuery(reader, projPaths);
+ }
+
+
+ public void test_SingleDescPath_SingleKeepNoChilds() throws MXQueryException{
+ String xmlDoc = "<a><b><c/></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpDescPath1Keep();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+ public void test_SingleDescPath_SingleNoChilds() throws MXQueryException{
+ String xmlDoc = "<a><b><c/></b></a>";
+
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null);
+ Vector path1 = setUpDescPath1();
+
+ Vector projPaths = new Vector();
+ projPaths.addElement(path1);
+ //projPaths.addElement(path2);
+
+ String res = runProjectedQuery(reader, projPaths);
+ assertEquals("<a><b><c/></b></a>", res);
+
+ }
+
+
+
+
+// public void test_Load1() {
+// Context ctx = new Context();
+// ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+// try {
+// XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"proj1.xml", true, Context.NO_VALIDATION, null);
+// Vector path1 = new Vector();
+// path1.addElement(AbstractStep.ROOT_STEP);
+// path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a")));
+// path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("b")));
+// path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("c")));
+// path1.addElement(AbstractStep.KEEP_SUBTREE);
+//
+// Vector path2 = new Vector();
+// path2.addElement(AbstractStep.ROOT_STEP);
+// path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a")));
+// path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("d")));
+//
+//
+// Vector projPaths = new Vector();
+// projPaths.addElement(path1);
+// //projPaths.addElement(path2);
+//
+// reader.setProjectionPaths(projPaths);
+//
+// XDMSerializer ser = new XDMSerializer();
+// ser.eventsToXML(new PrintStream(System.out),reader);
+// } catch (MXQueryException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// }
+//
+//
+// public void test_Load2() {
+// Context ctx = new Context();
+// ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+// try {
+// XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"proj1b.xml", true, Context.NO_VALIDATION, null);
+// Vector path1 = setUpPath1();
+//
+// setUpPath2();
+//
+//
+// Vector projPaths = new Vector();
+// projPaths.addElement(path1);
+// //projPaths.addElement(path2);
+//
+// reader.setProjectionPaths(projPaths);
+//
+// XDMSerializer ser = new XDMSerializer();
+// ser.eventsToXML(new PrintStream(System.out),reader);
+// } catch (MXQueryException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// }
+
+
+ private Vector setUpPath1() throws MXQueryException {
+ Vector path1 = new Vector();
+ path1.addElement(AbstractStep.ROOT_STEP);
+ path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a")));
+ path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("b")));
+ path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("c")));
+ return path1;
+ }
+
+ private Vector setUpPath1Keep() throws MXQueryException {
+ Vector path1 = setUpPath1();
+ path1.addElement(AbstractStep.KEEP_SUBTREE);
+ return path1;
+ }
+
+
+ private Vector setUpDescPath1() throws MXQueryException {
+ Vector path1 = new Vector();
+ path1.addElement(AbstractStep.ROOT_STEP);
+ path1.addElement(new AbstractStep(StepInformation.AXIS_DESCENDANT,new QName("b")));
+ path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("c")));
+ return path1;
+ }
+
+ private Vector setUpDescPath1Keep() throws MXQueryException {
+ Vector path1 = setUpDescPath1();
+ path1.addElement(AbstractStep.KEEP_SUBTREE);
+ return path1;
+ }
+
+
+ private Vector setUpPath2() throws MXQueryException {
+ Vector path2 = new Vector();
+ path2.addElement(AbstractStep.ROOT_STEP);
+ path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a")));
+ path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("d")));
+ return path2;
+ }
+
+ private String runProjectedQuery(XMLSource reader, Vector projPaths)
+ throws MXQueryException {
+ reader.setProjectionPaths(projPaths);
+ XDMSerializerSettings set = new XDMSerializerSettings();
+ set.setOmitXMLDeclaration(true);
+ XDMSerializer ser = new XDMSerializer(set);
+ String res = ser.eventsToXML(reader);
+ return res;
+ }
+
+
+ private void showProjectedQuery(XMLSource reader, Vector projPaths)
+ throws MXQueryException {
+ reader.setProjectionPaths(projPaths);
+ XDMSerializerSettings set = new XDMSerializerSettings();
+ set.setOmitXMLDeclaration(true);
+ XDMSerializer ser = new XDMSerializer(set);
+ ser.eventsToXML(System.out,reader);
+ }
+
+
public void test_Path1() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Path1.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
@@ -29,7 +613,7 @@
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
- }
+ }
public void test_Path2() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Path2.xq");
@@ -171,20 +755,44 @@
//assertEquals(resultBuffer.toString().trim(), "false");
}
- private void handleProjectionPaths(Hashtable projPaths) {
+ private void handleProjectionPaths(Hashtable projPaths) throws Exception{
ObjectObjectPair paths = (ObjectObjectPair) projPaths.get("DOC");
Set returned = (Set) paths.getFirst();
Set used = (Set) paths.getSecond();
Enumeration en = returned.elements();
while (en.hasMoreElements()) {
- String curPath = (String) en.nextElement();
+ String curPath = translateProjectionPath(en);
System.out.println(curPath+" #");
}
en = used.elements();
while (en.hasMoreElements()) {
- String curPath = (String) en.nextElement();
+ String curPath = translateProjectionPath(en);
System.out.println(curPath);
}
+ }
+
+ private String translateProjectionPath(Enumeration en) throws Exception {
+ Vector curPath = (Vector) en.nextElement();
+ StringBuffer pathString = new StringBuffer();
+ for (int i=0;i<curPath.size();i++) {
+ AbstractStep as = (AbstractStep)curPath.elementAt(i);
+ if (as == AbstractStep.ROOT_STEP)
+ pathString.append("/");
+ else if (as == AbstractStep.KEEP_SUBTREE)
+ pathString.append(" #");
+ else
+ {
+ pathString.append(as.getDirectionString(true));
+ XQName xq = as.getNodeTest().getXQName();
+ if (xq != null)
+ // TODO: What about namespace URIs?
+ pathString.append(xq.toString());
+ else throw new Exception("Unsupported node test for projection - please report");
+ if (i<curPath.size()-2 || ( (AbstractStep)curPath.elementAt(curPath.size()-1) != AbstractStep.KEEP_SUBTREE && i<curPath.size()-1) )
+ pathString.append("/");
+ }
+ }
+ return pathString.toString();
};
}
Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionXMarkTests.java
===================================================================
--- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionXMarkTests.java 2012-02-07 08:57:31 UTC (rev 4523)
+++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionXMarkTests.java 2012-02-07 08:59:24 UTC (rev 4524)
@@ -4,13 +4,24 @@
package ch.ethz.mxquery.test;
import java.util.Enumeration;
+import java.util.Vector;
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.XQName;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.StaticException;
+import ch.ethz.mxquery.model.AbstractStep;
import ch.ethz.mxquery.query.PreparedStatement;
import ch.ethz.mxquery.testsuite.XQueryTestBase;
import ch.ethz.mxquery.util.Hashtable;
import ch.ethz.mxquery.util.ObjectObjectPair;
import ch.ethz.mxquery.util.Set;
+import ch.ethz.mxquery.xdmio.XDMInputFactory;
+import ch.ethz.mxquery.xdmio.XDMSerializer;
+import ch.ethz.mxquery.xdmio.XDMSerializerSettings;
+import ch.ethz.mxquery.xdmio.XMLSource;
/**
@@ -21,28 +32,110 @@
private static final String TEST_PROJECTION_PREFIX = "ProjectionTests";
private static final String TEST_PROJECTION_QUERY_PREFIX = TEST_PROJECTION_PREFIX+"/queries/";
-
- public void test_XMark01() throws Exception{
+ private static final String TEST_PROJECTION_DOC_PREFIX = TEST_PROJECTION_PREFIX+"/docs/";
+
+ public void test_XMark01_Paths() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+
+
+ public void test_XMark01_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+// System.out.println(res);
+ showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+
+ public void test_XMark01_Normal() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+
+ System.out.println(resultBuffer.toString());
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ }
+
+
+
+ public void test_XMark01_Projected() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runWithProjection(query, fileName);
+
+ System.out.println(resultBuffer.toString());
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ }
+
+
+ public void test_XMark01_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark02() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark02.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark02_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark02.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+
+ public void test_XMark02_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark02.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark03() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark03.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
@@ -50,28 +143,111 @@
};
+ public void test_XMark03_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark03.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+
+ public void test_XMark03_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark03.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark04() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark04.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+
+ public void test_XMark04_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark04.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+
+ public void test_XMark04_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark04.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark05() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark05.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+
+ public void test_XMark05_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark05.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+ public void test_XMark05_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark05.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
public void test_XMark06() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
@@ -79,38 +255,145 @@
};
+ public void test_XMark06_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.item.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark06_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark07() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark07.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+
+ public void test_XMark07_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark07_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark08() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark08.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark08_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark08.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark08_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark08.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
public void test_XMark09() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark09.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark09_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark09.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark09_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark09.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
public void test_XMark10() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark10.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
@@ -118,47 +401,181 @@
};
+ public void test_XMark10_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark10.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark10_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark10.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark11() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark11.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark11_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark11.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark11_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark11.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark12() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark12.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark12_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark12.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark12_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark12.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark13() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark13.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark13_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark13.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark13_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark13.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
public void test_XMark14() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark14.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+
+ public void test_XMark14_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark14.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+ public void test_XMark14_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark14.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark15() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark15.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
@@ -166,66 +583,353 @@
};
+ public void test_XMark15_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark15.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+// String inputfile = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ String inputfile = "D:/Git-Repos/Projection_Data/10MB/auction-simplified.xml";
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, inputfile, true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark15_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark15.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
+
public void test_XMark16() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark16.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark16_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark16.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+ public void test_XMark16_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark16.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark17() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark17.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark17_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark17.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+
+ public void test_XMark17_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark17.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark18() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark18.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+ public void test_XMark18_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark18.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
+ Hashtable ht = pi.getProjectionPaths();
+ Context ctx = new Context();
+ ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION);
+ XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null);
+// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht));
+ System.out.println(res);
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ };
+
+
+ public void test_XMark18_Compare() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark18.xq");
+ String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml";
+ runQueryNormal(query, fileName);
+ String normalRes = resultBuffer.toString();
+ runWithProjection(query, fileName);
+ String projRes = resultBuffer.toString();
+ System.out.println();
+ assertEquals(normalRes,projRes);
+ }
+
+
public void test_XMark19() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark19.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new QName("input"), getRootProjectionPaths());
Hashtable ht = pi.getProjectionPaths();
handleProjectionPaths(ht);
//assertEquals(resultBuffer.toString().trim(), "false");
};
+
+ public void test_XMark19_Load() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark19.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ pi.setProjectionInformation(new ...
[truncated message content] |