|
From: <pm_...@us...> - 2011-12-19 13:28:53
|
Revision: 4502
http://mxquery.svn.sourceforge.net/mxquery/?rev=4502&view=rev
Author: pm_fischer
Date: 2011-12-19 13:28:47 +0000 (Mon, 19 Dec 2011)
Log Message:
-----------
- Attribute Iterator is now also an Axis Iterator
- Projection for Attribute
- Test for complex conditionals
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2011-12-19 13:26:50 UTC (rev 4501)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2011-12-19 13:28:47 UTC (rev 4502)
@@ -15,6 +15,7 @@
package ch.ethz.mxquery.iterators;
+import java.util.Enumeration;
import java.util.Vector;
import ch.ethz.mxquery.contextConfig.Context;
@@ -32,6 +33,8 @@
import ch.ethz.mxquery.model.CurrentBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.KXmlSerializer;
+import ch.ethz.mxquery.util.ObjectObjectPair;
+import ch.ethz.mxquery.util.Set;
/**
* Event of an Attribute Declaration in XQuery ('@attributename')
@@ -39,7 +42,7 @@
* @author Matthias Braun
*
*/
-public class AttributeIterator extends CurrentBasedIterator {
+public class AttributeIterator extends CurrentBasedIterator implements AxisIterator{
private String local = null;
@@ -163,5 +166,34 @@
return super.staticInit();
}
+ public int getDirection() {
+ // TODO Auto-generated method stub
+ return AXIS_ATTRIBUTE;
+ }
+
+ public ObjectObjectPair getProjectionPaths() {
+ XDMIterator curSub; // TODO: deal with context item
+ curSub = subIters[0];
+ ObjectObjectPair paths = curSub.getProjectionPaths();
+ Set returnedBelow = (Set)paths.getFirst();
+ Set returned = new Set();
+ Enumeration pathEnum = returnedBelow.elements();
+ while (pathEnum.hasMoreElements()) {
+ String res = (String) pathEnum.nextElement();
+ if (res.endsWith("/"))
+ res = res.substring(0, res.length()-1);
+ if (namespace != null)
+ res = res+"/@{"+namespace+"}:";
+ if (local != null) {
+ if (namespace == null)
+ res = res+"/@";
+ res = res+local;
+ }
+ returned.add(res);
+ }
+ return new ObjectObjectPair(returned, paths.getSecond());
+ }
+
+
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java 2011-12-19 13:26:50 UTC (rev 4501)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java 2011-12-19 13:28:47 UTC (rev 4502)
@@ -15,7 +15,7 @@
public static final int AXIS_PRECEDING_SIBLING = 24;
public static final int BACKWARD_AXIS_MASK = 16;
public static final int SELF_AXIS_MASK = 1;
-
+ public static final int AXIS_ATTRIBUTE = 10;
public abstract int getDirection();
}
\ No newline at end of file
Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java
===================================================================
--- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java 2011-12-19 13:26:50 UTC (rev 4501)
+++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java 2011-12-19 13:28:47 UTC (rev 4502)
@@ -40,6 +40,54 @@
//assertEquals(resultBuffer.toString().trim(), "false");
}
+ public void test_Path3() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Path3.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ Hashtable ht = pi.getProjectionPaths();
+ handleProjectionPaths(ht);
+
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ }
+
+
+ public void test_Cond1() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Cond1.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ Hashtable ht = pi.getProjectionPaths();
+ handleProjectionPaths(ht);
+
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ }
+
+
+ public void test_Cond2() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Cond2.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ Hashtable ht = pi.getProjectionPaths();
+ handleProjectionPaths(ht);
+
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ }
+
+ public void test_Cond3() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Cond3.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ Hashtable ht = pi.getProjectionPaths();
+ handleProjectionPaths(ht);
+
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ }
+
+ public void test_Cond4() throws Exception{
+ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Cond4.xq");
+ PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
+ Hashtable ht = pi.getProjectionPaths();
+ handleProjectionPaths(ht);
+
+ //assertEquals(resultBuffer.toString().trim(), "false");
+ }
+
+
public void test_FLWOR1() throws Exception{
String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"FLWOR1.xq");
PreparedStatement pi = prepareQuery(query, false,false, false, false, false);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|