You can subscribe to this list here.
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(71) |
Jun
(43) |
Jul
(9) |
Aug
(10) |
Sep
(21) |
Oct
(38) |
Nov
|
Dec
(11) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2012 |
Jan
|
Feb
(21) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <tim...@us...> - 2011-05-23 07:03:53
|
Revision: 4364
http://mxquery.svn.sourceforge.net/mxquery/?rev=4364&view=rev
Author: timchurch
Date: 2011-05-23 07:03:46 +0000 (Mon, 23 May 2011)
Log Message:
-----------
Added Eclipse project files to SVN
Added Paths:
-----------
trunk/MXQuery_Android_App/.classpath
trunk/MXQuery_Android_App/.project
Added: trunk/MXQuery_Android_App/.classpath
===================================================================
--- trunk/MXQuery_Android_App/.classpath (rev 0)
+++ trunk/MXQuery_Android_App/.classpath 2011-05-23 07:03:46 UTC (rev 4364)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="lib" path="/MXQuery/dist/mxquery-android.jar" sourcepath="/MXQuery/dist/mxquery-android-source.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/MXQuery_Android_App/.project
===================================================================
--- trunk/MXQuery_Android_App/.project (rev 0)
+++ trunk/MXQuery_Android_App/.project 2011-05-23 07:03:46 UTC (rev 4364)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>MXQuery_Android_App</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-22 22:31:33
|
Revision: 4363
http://mxquery.svn.sourceforge.net/mxquery/?rev=4363&view=rev
Author: maxspeicher
Date: 2011-05-22 22:31:26 +0000 (Sun, 22 May 2011)
Log Message:
-----------
added methods and sample queries for using XQuery Updating Facility
Modified Paths:
--------------
trunk/MXQuery_Android_App/AndroidManifest.xml
trunk/MXQuery_Android_App/res/values/strings.xml
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
Modified: trunk/MXQuery_Android_App/AndroidManifest.xml
===================================================================
--- trunk/MXQuery_Android_App/AndroidManifest.xml 2011-05-22 22:29:55 UTC (rev 4362)
+++ trunk/MXQuery_Android_App/AndroidManifest.xml 2011-05-22 22:31:26 UTC (rev 4363)
@@ -4,6 +4,7 @@
android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"></uses-sdk>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
+ <uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="@drawable/xquery_icon" android:label="@string/app_name" android:permission="android.permission.READ_CONTACTS" android:debuggable="true">
<activity android:name="Start">
Modified: trunk/MXQuery_Android_App/res/values/strings.xml
===================================================================
--- trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-22 22:29:55 UTC (rev 4362)
+++ trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-22 22:31:26 UTC (rev 4363)
@@ -23,7 +23,9 @@
<item>@string/native_java</item>
<item>@string/manipulate_ui</item>
<item>@string/fn_doc</item>
- <item>@string/android_doc</item>
+ <item>@string/fn_doc2</item>
+ <item>@string/updating</item>
+ <item>@string/updating2</item>
</string-array>
<string name="hello_world">Hello World</string>
@@ -34,8 +36,10 @@
<string name="fibonacci">Fibonacci</string>
<string name="native_java">Native Java</string>
<string name="manipulate_ui">Manipulate UI</string>
- <string name="fn_doc">fn:doc()</string>
- <string name="android_doc">android:doc()</string>
+ <string name="fn_doc">fn:doc() - local</string>
+ <string name="fn_doc2">fn:doc() - Internet</string>
+ <string name="updating">Updating 1</string>
+ <string name="updating2">Updating 2</string>
<string name="hello_world_xquery">\"Hello World\"</string>
<string name="addition_xquery">5+5</string>
@@ -76,9 +80,16 @@
<string name="fn_doc_xquery">
fn:doc(\"test.xml\")
</string>
- <string name="android_doc_xquery">
- declare namespace android = \"java:ch.ethz.mxquery.android.MXQuery\";\n
- fn:parse(android:doc(\"test.xml\"))
+ <string name="fn_doc2_xquery">
+ fn:doc(\"http://mxquery.org/\")
</string>
+ <string name="updating_xquery">
+ copy $x := <test></test>\n
+ modify( insert node <bla/> into $x )\n
+ return $x
+ </string>
+ <string name="updating2_xquery">
+ insert node <blub/> as last into fn:doc(\"test.xml\")/test
+ </string>
</resources>
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java 2011-05-22 22:29:55 UTC (rev 4362)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java 2011-05-22 22:31:26 UTC (rev 4363)
@@ -1,11 +1,22 @@
package ch.ethz.mxquery.android;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
+import ch.ethz.mxquery.contextConfig.CompilerOptions;
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.query.PreparedStatement;
+import ch.ethz.mxquery.query.XQCompiler;
+import ch.ethz.mxquery.query.impl.CompilerImpl;
+import ch.ethz.mxquery.xdmio.XDMSerializer;
import ch.ethz.mxquery.xqj.MXQueryXQDataSource;
import ch.ethz.repackaged.xquery.XQConnection;
import ch.ethz.repackaged.xquery.XQDataSource;
@@ -37,8 +48,8 @@
}
/** public method for clients */
- public void runQuery(String query, XQueryListener listener) {
- QueryThread queryThread = new QueryThread(query, listener);
+ public void runQuery(String query, XQueryListener listener, boolean updating) {
+ QueryThread queryThread = new QueryThread(query, listener, updating);
queryThread.start();
}
@@ -48,13 +59,17 @@
private class QueryThread extends Thread {
private String query;
private XQueryListener listener;
- public QueryThread(String query, XQueryListener listener) {
+ private boolean updating;
+
+ public QueryThread(String query, XQueryListener listener, boolean updating) {
this.query = query;
this.listener = listener;
+ this.updating = updating;
}
public void run() {
- String result = doQuery(this.query);
+ String result = updating ? doUpdatingQuery(this.query)
+ : doQuery(this.query);
lastResult = result;
System.out.println("QueryThread - saving result: " + result);
listener.queryResult(result);
@@ -77,5 +92,43 @@
return result.toString();
}
+
+ protected String doUpdatingQuery(String query) {
+ Context ctx = new Context();
+ CompilerOptions co = new CompilerOptions();
+ XQCompiler comp = new CompilerImpl();
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ String s = new String();
+
+ ctx.getStores().setSerializeStores(true);
+ co.setUpdate(true);
+
+ try {
+ PreparedStatement statement = comp.compile(ctx, query, co, null, null);
+ XDMIterator result = statement.evaluate();
+ XDMSerializer ser = new XDMSerializer();
+
+ ser.eventsToXML(out, result);
+ statement.applyPUL();
+ statement.serializeStores(false);
+ result.close(false);
+ statement.close();
+ } catch (MXQueryException err) {
+ MXQueryException.printErrorPosition(query, err.getLocation());
+ err.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ ctx.getStores().freeRessources();
+
+ try {
+ s = out.toString("utf-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+
+ return s;
+ }
}
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-22 22:29:55 UTC (rev 4362)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-22 22:31:26 UTC (rev 4363)
@@ -59,6 +59,7 @@
// private XQueryAsyncTask mTask;
protected MXQueryService mService;
protected boolean mIsBound = false;
+ protected boolean mUpdating = false;
protected ProgressDialog mDialog;
protected XQDataSource xqjd = new MXQueryXQDataSource();
@@ -164,6 +165,8 @@
int pos, long id) {
String item = parent.getItemAtPosition(pos).toString();
+ mUpdating = false;
+
if (item.equals(getString(R.string.hello_world))) {
mInputView.setText(getString(R.string.hello_world_xquery));
} else if (item.equals(getString(R.string.addition))) {
@@ -182,8 +185,14 @@
mInputView.setText(getString(R.string.manipulate_ui_xquery));
} else if (item.equals(getString(R.string.fn_doc))) {
mInputView.setText(getString(R.string.fn_doc_xquery));
- } else if (item.equals(getString(R.string.android_doc))) {
- mInputView.setText(getString(R.string.android_doc_xquery));
+ } else if (item.equals(getString(R.string.fn_doc2))) {
+ mInputView.setText(getString(R.string.fn_doc2_xquery));
+ } else if (item.equals(getString(R.string.updating))) {
+ mInputView.setText(getString(R.string.updating_xquery));
+ mUpdating = true;
+ } else if (item.equals(getString(R.string.updating2))) {
+ mInputView.setText(getString(R.string.updating2_xquery));
+ mUpdating = true;
}
}
@@ -279,7 +288,7 @@
doBindService();
}
- mService.runQuery(query, queryListener);
+ mService.runQuery(query, queryListener, mUpdating);
}
void doBindService() {
@@ -397,7 +406,7 @@
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
- //inflater.inflate(R.menu.menu, menu);
+ inflater.inflate(R.menu.menu, menu);
return true;
}
@@ -405,9 +414,9 @@
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
-// case R.id.generate_contacts_XML:
-// new GenerateContactsXMLAsyncTask().execute();
-// return true;
+ case R.id.generate_contacts_XML:
+ new GenerateContactsXMLAsyncTask().execute();
+ return true;
default:
return super.onOptionsItemSelected(item);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-22 22:30:02
|
Revision: 4362
http://mxquery.svn.sourceforge.net/mxquery/?rev=4362&view=rev
Author: maxspeicher
Date: 2011-05-22 22:29:55 +0000 (Sun, 22 May 2011)
Log Message:
-----------
minor changes to IOLib of Android branch
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-22 11:10:21 UTC (rev 4361)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-22 22:29:55 UTC (rev 4362)
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.OutputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URI;
@@ -32,39 +31,40 @@
import java.net.URL;
import java.net.URLConnection;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+
import android.content.Context;
import ch.ethz.mxquery.android.MXQuery;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.exceptions.QueryLocation;
-import ch.ethz.mxquery.util.Utils;
public class IOLib {
public static void copyFile(String source, String destination) throws MXQueryException{
+ Context ctx = MXQuery.getContext();
FileInputStream in = null;
FileOutputStream out = null;
+
+ source = convertToAndroid(source);
+ destination = convertToAndroid(destination);
+
try {
- File src = new File(new URI(source));
- File dst = new File(new URI(destination));
- if (src.exists()) {
- // create a copy of the file, possibly overwriting previous copies
- in = new FileInputStream(src);
- out = new FileOutputStream(dst, false);
- byte[] buf = new byte[4096];
- int len;
- while ((len = in.read(buf)) > 0){
- out.write(buf, 0, len);
- }
- }
-
+ // create a copy of the file, possibly overwriting previous copies
+ in = ctx.openFileInput(source);
+ out = ctx.openFileOutput(destination, 0);
+ byte[] buf = new byte[4096];
+ int len;
+ while ((len = in.read(buf)) > 0){
+ out.write(buf, 0, len);
+ }
} catch (IOException io) {
throw new DynamicException(ErrorCodes.A0007_EC_IO,"I/O Error copying file "+io.toString(),QueryLocation.OUTSIDE_QUERY_LOC);
- } catch (URISyntaxException e) {
- throw new DynamicException(ErrorCodes.A0007_EC_IO,"I/O Error copying file "+e.toString(),QueryLocation.OUTSIDE_QUERY_LOC);
- }
- finally {
+ } finally {
if (in != null)
try {
in.close();
@@ -165,14 +165,9 @@
public static Reader getInput (String toOpen, boolean xquery,String encoding, QueryLocation loc) throws MXQueryException {
if (encoding == null)
- encoding = "utf-8";
+ encoding = "utf-8";
InputStream ins = null;
- //android-specific treatment of local/file URIs:
- //Strip all but the the last part
- if (toOpen.startsWith("file:/")||toOpen.indexOf(":") < 0) {
- String [] parts = Utils.split(toOpen, "/", true);
- toOpen = parts[parts.length-1];
- }
+ toOpen = convertToAndroid(toOpen);
URI uri;
try {
uri = new URI(toOpen);
@@ -181,16 +176,21 @@
}
if (uri.isAbsolute()) {
try {
- URL url = uri.toURL();
- URLConnection conn = url.openConnection();
- conn.setRequestProperty("User-Agent", "MXQuery");
- ins = conn.getInputStream();
- // try to use content-type specific
- String contentType = conn.getContentType();
- int encPos = contentType.indexOf("charset=");
- if (encPos > 0)
- encoding = contentType.substring(encPos+8); //lenght of "charset="
- //encoding = "iso-8859-1";
+ HttpClient client = new DefaultHttpClient();
+ HttpGet get = new HttpGet(toOpen);
+
+ get.setHeader("User-Agent", "MXQuery");
+
+ HttpResponse resp = client.execute(get);
+ String contentType = resp.getEntity().getContentType().getValue();
+ int encPos = contentType.indexOf("charset=");
+
+ if (encPos > 0) {
+ encoding = contentType.substring(encPos+8); //lenght of "charset="
+ }
+
+ ins = resp.getEntity().getContent();
+
BufferedInputStream bufs = new BufferedInputStream(ins);
bufs.mark(16384);
String tempEncoding = IOLib.snoopEncoding8bit(bufs, xquery);
@@ -205,7 +205,7 @@
}
}
bufs.reset();
- return new BufferedReader(new UnicodeReader(bufs, encoding));
+ return new BufferedReader(new UnicodeReader(bufs, encoding));
} catch (IOException e) {
throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "I/O Error - Remote Data cannot be accessed: " + e, loc);
}
@@ -251,13 +251,10 @@
}
public static PrintStream getOutput(String url, boolean append, String encoding) throws IOException, MXQueryException {
- URI uri = null;
- try {
- uri = new URI(url);
- } catch (URISyntaxException e) {
- throw new DynamicException(ErrorCodes.A0007_EC_IO,"Error Creating output file - invalid file name/URI: "+url,QueryLocation.OUTSIDE_QUERY_LOC);
- }
- OutputStream outw = new FileOutputStream(new File(uri), append);
+ Context ctx = MXQuery.getContext();
+ url = convertToAndroid(url);
+ int mode = append ? Context.MODE_APPEND : Context.MODE_PRIVATE;
+ FileOutputStream outw = ctx.openFileOutput(url, mode);
return new PrintStream(outw,false,encoding);
}
@@ -266,4 +263,17 @@
File fl = new File(curDir);
return fl.toURI().toString();
}
+
+ private static String convertToAndroid(String toOpen) {
+ String result = toOpen;
+
+ //android-specific treatment of local/file URIs:
+ //Strip all but the the last part
+ if (result.startsWith("file:/")||result.indexOf(":") < 0) {
+ String [] parts = Utils.split(result, "/", true);
+ result = parts[parts.length-1];
+ }
+
+ return result;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <et...@us...> - 2011-05-22 11:10:28
|
Revision: 4361
http://mxquery.svn.sourceforge.net/mxquery/?rev=4361&view=rev
Author: etterth
Date: 2011-05-22 11:10:21 +0000 (Sun, 22 May 2011)
Log Message:
-----------
- Refactored NativeFunctionImporter to allow support for different languages
Modified Paths:
--------------
trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
Added Paths:
-----------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-19 21:50:35 UTC (rev 4360)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-22 11:10:21 UTC (rev 4361)
@@ -9,8 +9,13 @@
public class NativeFunctionImporter {
- public static Context getNativeMethods(String className) throws MXQueryException{
+ public static Context getNativeMethods(String uri) throws MXQueryException{
+ String className = uri.substring(5);
Context ctx = new Context();
throw new MXQueryException(ErrorCodes.A0002_EC_NOT_SUPPORTED, "Import of native methods not supported", QueryLocation.OUTSIDE_QUERY_LOC);
}
+
+ public static boolean isNativeUri(String uri) {
+ return uri.startsWith("java:");
+ }
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-19 21:50:35 UTC (rev 4360)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-22 11:10:21 UTC (rev 4361)
@@ -1,219 +1,21 @@
package ch.ethz.mxquery.functions;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.Map;
import ch.ethz.mxquery.contextConfig.Context;
-import ch.ethz.mxquery.datamodel.QName;
-import ch.ethz.mxquery.datamodel.types.Type;
-import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.exceptions.QueryLocation;
-import ch.ethz.mxquery.exceptions.StaticException;
-import ch.ethz.mxquery.iterators.NativeFuncCall;
-import ch.ethz.mxquery.model.XDMIterator;
public class NativeFunctionImporter {
- static class MethodData {
- Class baseClass;
- String methodName;
- TypeInfo [] paramTypes;
- TypeInfo returnType;
-
- public MethodData(Class baseClass, String methodName,
- TypeInfo[] paramTypes, TypeInfo returnType) {
- super();
- this.baseClass = baseClass;
- this.methodName = methodName;
- this.paramTypes = paramTypes;
- this.returnType = returnType;
- }
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((baseClass == null) ? 0 : baseClass.hashCode());
- result = prime * result
- + ((methodName == null) ? 0 : methodName.hashCode());
- result = prime * result + paramTypes.length;
- return result;
- }
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- MethodData other = (MethodData) obj;
- if (baseClass == null) {
- if (other.baseClass != null)
- return false;
- } else if (!baseClass.equals(other.baseClass))
- return false;
- if (methodName == null) {
- if (other.methodName != null)
- return false;
- } else if (!methodName.equals(other.methodName))
- return false;
- if (paramTypes == null) {
- if (other.paramTypes != null)
- return false;
- }else if (paramTypes.length != other.paramTypes.length)
- return false;
- return true;
- }
-
- }
- public static Context getNativeMethods(String className) throws MXQueryException{
+ public static Context getNativeMethods(String uri) throws MXQueryException{
+ String className = uri.substring(5);
Context ctx = new Context();
-
- try {
- Class toImport = Class.forName(className);
-
- Map functions = new HashMap();
-
- Constructor [] constructors = toImport.getConstructors();
- for (int i=0;i<constructors.length;i++) {
- Constructor cur = constructors[i];
- int mod = cur.getModifiers();
- if (Modifier.isPublic(mod)) {
- TypeInfo [] params;
- Class [] paramTypes = cur.getParameterTypes();
- params = new TypeInfo[paramTypes.length];
- for (int j=0;j<params.length;j++) {
- params[j] = getXQueryType(paramTypes[j]);
- }
- MethodData md = new MethodData(toImport, "new", params, new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE));
- if (!functions.containsKey(md))
- functions.put(md,md);
- else {
- MethodData existingMd = (MethodData)functions.get(md);
- for (int j=0;j<existingMd.paramTypes.length;j++) {
- if (!params[j].equals(existingMd.paramTypes [j])) {
- if (Type.isNumericPrimitiveType(params[j].getType()) && Type.isNumericPrimitiveType(existingMd.paramTypes[j].getType()))
- existingMd.paramTypes[j] = new TypeInfo(Type.NUMBER,Type.OCCURRENCE_IND_EXACTLY_ONE);
- else
- if (Type.isAtomicType(params[j].getType(), Context.getDictionary()) && Type.isAtomicType(existingMd.paramTypes[j].getType(),Context.getDictionary()))
- existingMd.paramTypes[j] = new TypeInfo(Type.ANY_ATOMIC_TYPE,Type.OCCURRENCE_IND_EXACTLY_ONE);
- else
- existingMd.paramTypes[j] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
- }
- }
- }
-
- }
- }
-
- Method [] methods = toImport.getMethods();
-
- for (int i=0;i<methods.length;i++) {
- Method cur = methods[i];
- int mod = cur.getModifiers();
- if (Modifier.isPublic(mod)) {
- String name = cur.getName();
- Class [] paramTypes = cur.getParameterTypes();
- TypeInfo [] params = new TypeInfo[paramTypes.length];
- if (Modifier.isStatic(mod)) {
- params = new TypeInfo[paramTypes.length];
- for (int j=0;j<params.length;j++) {
- params[j] = getXQueryType(paramTypes[j]);
- }
- }
- else {
- params = new TypeInfo[paramTypes.length+1];
- params[0] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
- for (int j=1;j<params.length;j++) {
- params[j] = getXQueryType(paramTypes[j-1]);
- }
- }
- TypeInfo resultType = getXQueryType(cur.getReturnType());
- MethodData md = new MethodData(toImport, name, params, resultType);
- if (!functions.containsKey(md))
- functions.put(md,md);
- else {
- MethodData existingMd = (MethodData)functions.get(md);
- for (int j=0;j<existingMd.paramTypes.length;j++) {
- if (!params[j].equals(existingMd.paramTypes [j])) {
- if (Type.isNumericPrimitiveType(params[j].getType()) && Type.isNumericPrimitiveType(existingMd.paramTypes[j].getType()))
- existingMd.paramTypes[j] = new TypeInfo(Type.NUMBER,Type.OCCURRENCE_IND_EXACTLY_ONE);
- else
- existingMd.paramTypes[j] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
- //throw new StaticException(ErrorCodes.A0020_Incompatible_Overload, "Overloaded Java Function "+className+"."+name+" could not be mapped", QueryLocation.OUTSIDE_QUERY_LOC);
- }
- }
- }
-
- }
- }
-
- Field [] fields = toImport.getFields();
-
- for (int i=0;i<fields.length;i++) {
- Field cur = fields[i];
- int mod = cur.getModifiers();
- if (Modifier.isPublic(mod)) {
- String name = cur.getName();
- TypeInfo[] params;
- if (Modifier.isStatic(mod)) {
- params = new TypeInfo[0];
- }
- else {
- params = new TypeInfo[1];
- params[0] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
- }
- TypeInfo resultType = getXQueryType(cur.getType());
- MethodData md = new MethodData(toImport, name, params, resultType);
- if (!functions.containsKey(md))
- functions.put(md,md);
- }
- }
-
- java.util.Iterator allFuncts = functions.values().iterator();
- while (allFuncts.hasNext()) {
- MethodData md = (MethodData)allFuncts.next();
- QName qn = new QName("java:"+className,"javamethod",md.methodName);
- FunctionSignature fs = new FunctionSignature(qn, md.paramTypes,FunctionSignature.EXTERNAL_FUNCTION,XDMIterator.EXPR_CATEGORY_SEQUENTIAL,true,false);
- Function fn = new Function(null, fs, new NativeFuncCall(ctx, md.paramTypes, toImport, md.methodName, md.returnType, null, XDMIterator.EXPR_CATEGORY_SIMPLE, QueryLocation.OUTSIDE_QUERY_LOC), null, null);
- ctx.addFunction(fn);
- }
- } catch (ClassNotFoundException e) {
- throw new StaticException(ErrorCodes.A0019_Unknown_Class, "Class "+className+" could not be found", QueryLocation.OUTSIDE_QUERY_LOC);
- }
- return ctx;
+ throw new MXQueryException(ErrorCodes.A0002_EC_NOT_SUPPORTED, "Import of native methods not supported", QueryLocation.OUTSIDE_QUERY_LOC);
}
- private static TypeInfo getXQueryType(Class class1) {
-
- if (class1.isPrimitive()) {
- if (class1.getName().equals("long"))
- return new TypeInfo(Type.LONG,Type.OCCURRENCE_IND_EXACTLY_ONE);
- if (class1.getName().equals("double"))
- return new TypeInfo(Type.DOUBLE,Type.OCCURRENCE_IND_EXACTLY_ONE);
- if (class1.getName().equals("float"))
- return new TypeInfo(Type.FLOAT,Type.OCCURRENCE_IND_EXACTLY_ONE);
- if (class1.getName().equals("int"))
- return new TypeInfo(Type.INT,Type.OCCURRENCE_IND_EXACTLY_ONE);
- if (class1.getName().equals("boolean"))
- return new TypeInfo(Type.BOOLEAN,Type.OCCURRENCE_IND_EXACTLY_ONE);
- System.out.println(class1.getPackage()+" "+class1.getName());
- return new TypeInfo(Type.UNTYPED_ATOMIC,Type.OCCURRENCE_IND_EXACTLY_ONE);
- }
- if (class1.getName().equals("java.lang.String"))
- return new TypeInfo(Type.STRING,Type.OCCURRENCE_IND_EXACTLY_ONE);
- if (class1.getName().equals("java.lang.CharSequence"))
- return new TypeInfo(Type.STRING,Type.OCCURRENCE_IND_EXACTLY_ONE);
- if (class1.getName().equals("java.lang.Double"))
- return new TypeInfo(Type.DOUBLE,Type.OCCURRENCE_IND_EXACTLY_ONE);
- if (class1.getName().equals("java.lang.Float"))
- return new TypeInfo(Type.FLOAT,Type.OCCURRENCE_IND_EXACTLY_ONE);
- return new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE);
- }
+ public static boolean isNativeUri(String uri) {
+ return uri.startsWith("java:");
+ }
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-05-19 21:50:35 UTC (rev 4360)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-05-22 11:10:21 UTC (rev 4361)
@@ -940,8 +940,8 @@
ErrorCodes.E0033_STATIC_MODULE_MULTIPLE_BINDINGS_FOR_SAME_PREFIX,
"Multiple declarations of Namespace " + name);
ctx.addNamespace(new Namespace(name, uri));
- if (uri.startsWith("java:")) {
- Context javamod = NativeFunctionImporter.getNativeMethods(uri.substring(5));
+ if (NativeFunctionImporter.isNativeUri(uri)) {
+ Context javamod = NativeFunctionImporter.getNativeMethods(uri);
importModuleFunctionsVariables(uri, name, javamod);
}
declaredNamespaces.add(name);
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-22 11:10:21 UTC (rev 4361)
@@ -0,0 +1,21 @@
+package ch.ethz.mxquery.functions;
+
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+
+public class NativeFunctionImporter {
+
+
+ public static Context getNativeMethods(String uri) throws MXQueryException{
+ String className = uri.substring(5);
+ Context ctx = new Context();
+ throw new MXQueryException(ErrorCodes.A0002_EC_NOT_SUPPORTED, "Import of native methods not supported", QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+
+ public static boolean isNativeUri(String uri) {
+ return uri.startsWith("java:");
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-19 21:50:41
|
Revision: 4360
http://mxquery.svn.sourceforge.net/mxquery/?rev=4360&view=rev
Author: maxspeicher
Date: 2011-05-19 21:50:35 +0000 (Thu, 19 May 2011)
Log Message:
-----------
- added fn:doc() to sample queries
- added query causing "void" problem to Start.java
Modified Paths:
--------------
trunk/MXQuery_Android_App/res/values/strings.xml
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
Modified: trunk/MXQuery_Android_App/res/values/strings.xml
===================================================================
--- trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-19 21:49:31 UTC (rev 4359)
+++ trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-19 21:50:35 UTC (rev 4360)
@@ -22,6 +22,7 @@
<item>@string/fibonacci</item>
<item>@string/native_java</item>
<item>@string/manipulate_ui</item>
+ <item>@string/fn_doc</item>
<item>@string/android_doc</item>
</string-array>
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-19 21:49:31 UTC (rev 4359)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-19 21:50:35 UTC (rev 4360)
@@ -397,7 +397,7 @@
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
+ //inflater.inflate(R.menu.menu, menu);
return true;
}
@@ -405,9 +405,9 @@
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
- case R.id.generate_contacts_XML:
- new GenerateContactsXMLAsyncTask().execute();
- return true;
+// case R.id.generate_contacts_XML:
+// new GenerateContactsXMLAsyncTask().execute();
+// return true;
default:
return super.onOptionsItemSelected(item);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-19 21:49:37
|
Revision: 4359
http://mxquery.svn.sourceforge.net/mxquery/?rev=4359&view=rev
Author: maxspeicher
Date: 2011-05-19 21:49:31 +0000 (Thu, 19 May 2011)
Log Message:
-----------
added Android-specific copy of functions.fn.Doc
Added Paths:
-----------
trunk/MXQuery/android/src/ch/ethz/mxquery/functions/
trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/
trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java
Added: trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java (rev 0)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java 2011-05-19 21:49:31 UTC (rev 4359)
@@ -0,0 +1,255 @@
+/* Copyright 2006 - 2009 ETH Zurich
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.ethz.mxquery.functions.fn;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Vector;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.datamodel.xdm.TextToken;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.DynamicException;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.functions.RequestTypeMulti;
+import ch.ethz.mxquery.iterators.TokenIterator;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.EmptySequenceIterator;
+import ch.ethz.mxquery.model.TokenSequenceIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.util.IOLib;
+import ch.ethz.mxquery.util.LineReader;
+import ch.ethz.mxquery.util.URIUtils;
+import ch.ethz.mxquery.xdmio.XDMInputFactory;
+import ch.ethz.mxquery.xdmio.XMLSource;
+
+/**
+ *
+ * @author Matthias Braun
+ *
+ */
+public class Doc extends CurrentBasedIterator implements RequestTypeMulti{
+ private final int OPERATION_DOC = 0;
+ private final int OPERATION_TIDY =1;
+ private final int OPERATION_UNPARSED=2;
+ private final int OPERATION_UNPARSED_LINES=3;
+private boolean inValidateExpression = false;
+ private int operation = OPERATION_DOC;
+ private String docURI = null;
+
+ private Reader rd = null; // keep around to close
+
+ public Doc() {
+ super(null, null);
+ }
+
+ public boolean isInValidateExpression() {
+ return inValidateExpression;
+ }
+
+ public void setInValidateExpression(boolean inValidateExpression) {
+ this.inValidateExpression = inValidateExpression;
+ }
+
+ public TokenInterface next() throws MXQueryException {
+ if (called == 0) {
+ init();
+ called++;
+ }
+
+ TokenInterface tok;
+
+ try {
+ tok = current.next();
+ } catch (MXQueryException e) {
+ throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE,"Error generating XML from file "+e.getMessage(),loc);
+ }
+ if (tok == Token.END_SEQUENCE_TOKEN) {
+ try {
+ if (rd != null)
+ rd.close();
+ rd = null;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return tok;
+ }
+
+
+ protected void init() throws MXQueryException {
+
+ String add = getStringValueOrEmpty(subIters[0]);
+
+
+ if (add == null) {
+ current = new EmptySequenceIterator(context, loc);
+ return;
+ }
+
+ String encoding = null;
+
+ if (subIters.length > 1) {
+ encoding = getStringValue(subIters[1]);
+ }
+
+ String uri = null;
+ try {
+ uri = URIUtils.resolveURI(context.getBaseURI(),add,loc);
+ } catch (DynamicException de) {
+ if (de.getErrorCode().equals(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE)) {
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC, "Invalid URI given to fn:doc(): "+add, loc);
+ }
+ else
+ throw de;
+ }
+ //if (operation!=OPERATION_DOC)
+ rd = IOLib.getInput(uri, false, encoding, loc);
+ XDMIterator cur = null;
+ try {
+ switch(operation) {
+ case OPERATION_DOC:
+ cur = XDMInputFactory.createXMLInput(context, rd, true, Context.NO_VALIDATION, loc);
+// if (isInValidateExpression())
+// cur = XDMInputFactory.createXMLInput(context, rd, true, Context.SCHEMA_VALIDATION_STRICT, loc);
+// else
+// cur = XDMInputFactory.createXMLInput(context, uri, true, context.getInputValidationMode(), loc);
+ ((XMLSource)cur).setURI(uri);
+ break;
+ case OPERATION_TIDY:
+ cur = XDMInputFactory.createTidyInput(context, rd, loc);
+ ((XMLSource)cur).setURI(uri);
+ break;
+ case OPERATION_UNPARSED:
+ StringBuffer sb = new StringBuffer();
+ LineReader lr = new LineReader(rd);
+ String line = lr.readLine();
+ boolean first = true;
+ while(line!=null) {
+ if (first)
+ first=false;
+ else
+ sb.append('\n');
+ sb.append(line);
+ line = lr.readLine();
+ }
+ cur = new TokenIterator(context,sb.toString(),loc);
+ break;
+ case OPERATION_UNPARSED_LINES:
+ Vector lines = new Vector();
+ lr = new LineReader(rd);
+ line = lr.readLine();
+ while(line!=null) {
+ lines.addElement(new TextToken(null, line));
+ line = lr.readLine();
+ }
+ cur = new TokenSequenceIterator(lines);
+ break;
+
+ }
+ docURI = uri;
+ current = cur;
+ } catch (MXQueryException me) {
+ try {
+ rd.close();
+ } catch (IOException ie) {
+ //
+ }
+ throw me;
+ } catch (IOException e) {
+ try {
+ rd.close();
+ } catch (IOException ie) {
+ //
+ }
+ throw new MXQueryException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, e.toString(), loc);
+ }
+ }
+
+ public TypeInfo getStaticType() {
+ return new TypeInfo(Type.START_DOCUMENT, Type.OCCURRENCE_IND_ZERO_OR_ONE);
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException {
+ Doc copy = new Doc();
+ copy.setContext(context, true);
+ copy.setInValidateExpression(inValidateExpression);
+ copy.operation = operation;
+ copy.setConstModePreserve(this.constModePreserve);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+ public String getDocURI() {
+ return docURI;
+ }
+
+ protected void freeResources(boolean restartable) throws MXQueryException {
+ super.freeResources(restartable);
+ try {
+ if (rd != null)
+ rd.close();
+ rd = null;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ public boolean isExprParameter(int valueToCheck, boolean recursive) {
+ if (valueToCheck == EXPR_PARAM_XDMGEN)
+ return true;
+ else
+ return super.isExprParameter(valueToCheck, recursive);
+ }
+
+ public void setOperation(String type) throws MXQueryException {
+ if (type.equals("tidy"))
+ operation = OPERATION_TIDY;
+ else if (type.equals("unparsed-text"))
+ operation = OPERATION_UNPARSED;
+ else if (type.equals("unparsed-text-lines"))
+ operation = OPERATION_UNPARSED_LINES;
+ else throw new MXQueryException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Incorrect operation for Doc", loc);
+
+ }
+
+ public void setReturnType(int type) throws MXQueryException {
+ }
+
+ public String getSystemID() {
+ if (current != null)
+ return ((XMLSource)current).getSystemID();
+ else
+ return null;
+ }
+ public String getPublicID() {
+ if (current != null)
+ return ((XMLSource)current).getPublicID();
+ else
+ return null;
+ }
+ public String getRootElemDTD(){
+ if (current != null)
+ return ((XMLSource)current).getRootElemDTD();
+ else
+ return null;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <et...@us...> - 2011-05-19 20:58:30
|
Revision: 4358
http://mxquery.svn.sourceforge.net/mxquery/?rev=4358&view=rev
Author: etterth
Date: 2011-05-19 20:58:22 +0000 (Thu, 19 May 2011)
Log Message:
-----------
- Removed dependency on third party tidy library.
- New tidy function uses iframes with document.write to use the browser's integrated parser (drawback: js code in the document will be executed)
Modified Paths:
--------------
trunk/MXQuery/xqib_NOTICE
trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml
trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
Added Paths:
-----------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HtmlParser.java
Removed Paths:
-------------
trunk/MXQuery/xqib_src/nu/
Modified: trunk/MXQuery/xqib_NOTICE
===================================================================
--- trunk/MXQuery/xqib_NOTICE 2011-05-19 18:41:47 UTC (rev 4357)
+++ trunk/MXQuery/xqib_NOTICE 2011-05-19 20:58:22 UTC (rev 4358)
@@ -13,103 +13,4 @@
- Apache Software Foundation (Java helper classes, Xerces)
- Robert Hanson (Regular Expressions from GWT widgets) for XQIB-JS
- GWT calendar project (time and calendar support) for XQIB-JS
- - Validator.nu HTML Parser for XQIB-JS
-License for Validator.nu HTML Parser:
-
-This is for the HTML parser as a whole except the rewindable input stream,
-the named character classes and the Live DOM Viewer.
-For the copyright notices for individual files, please see individual files.
-
-/*
- * Copyright (c) 2005, 2006, 2007 Henri Sivonen
- * Copyright (c) 2007-2011 Mozilla Foundation
- * Portions of comments Copyright 2004-2007 Apple Computer, Inc., Mozilla
- * Foundation, and Opera Software ASA.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-The following license is for the WHATWG spec from which the named character
-data was extracted.
-
-/*
- * Copyright 2004-2010 Apple Computer, Inc., Mozilla Foundation, and Opera
- * Software ASA.
- *
- * You are granted a license to use, reproduce and create derivative works of
- * this document.
- */
-
-The following license is for the rewindable input stream.
-
-/*
- * Copyright (c) 2001-2003 Thai Open Source Software Center Ltd
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of the Thai Open Source Software Center Ltd nor
- * the names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-The following license applies to the Live DOM Viewer:
-
-Copyright (c) 2000, 2006, 2008 Ian Hickson and various contributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml 2011-05-19 18:41:47 UTC (rev 4357)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml 2011-05-19 20:58:22 UTC (rev 4358)
@@ -15,7 +15,6 @@
<inherits name="ch.ethz.mxquery"/>
<inherits name="java"/>
<inherits name="com.google.gwt.xml.XML" />
-<inherits name="nu.validator.htmlparser.HtmlParser" />
<!-- <inherits name="nu.validator.htmlparser.HtmlParser" /> -->
<!-- <set-property name="user.agent" value="ie6" /> -->
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HtmlParser.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HtmlParser.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HtmlParser.java 2011-05-19 20:58:22 UTC (rev 4358)
@@ -0,0 +1,20 @@
+package ch.ethz.mxquery.extensionsModules.expathhttp;
+
+import ch.ethz.mxquery.util.browser.dom.Document;
+
+public class HtmlParser {
+ public static Document tidyAndParse(String html){
+ return nativeTidyAndParse(html);
+ }
+
+ static protected native Document nativeTidyAndParse(String html)/*-{
+ var a = $doc.createElement('iframe');
+ a.style.visibility = 'hidden';
+ $doc.documentElement.appendChild(a);
+ a.contentWindow.document.write(html);
+ var doc = a.contentWindow.document;
+ a.parentNode.removeChild(a);
+ return doc;
+ }-*/;
+
+}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-19 18:41:47 UTC (rev 4357)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-19 20:58:22 UTC (rev 4358)
@@ -22,8 +22,6 @@
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.IFrameElement;
-import nu.validator.htmlparser.gwt.HtmlParser;
-
import ch.ethz.mxqjs.client.Environment;
import ch.ethz.mxqjs.client.QnameAndArity;
import ch.ethz.mxquery.bindings.WindowFactory;
@@ -770,19 +768,14 @@
// Document doc = DOMImpl.impl.getIFrameDocument(iframe);
// doc.write(conn.responseAsString());
- Document doc = Document.createDocument();
+// Document doc = Document.createDocument();
// Element el = doc.getAsGwtDocument().getDocumentElement();
// el.removeFromParent();
// el = doc.getAsGwtDocument().getDocumentElement();
- nu.validator.htmlparser.gwt.HtmlParser tidyparser = new HtmlParser(doc);
- try {
- tidyparser.parse(conn.responseAsString(), null);
- } catch (SAXException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+// HtmlParser tidyparser = new HtmlParser(doc);
+ Document doc = HtmlParser.tidyAndParse(conn.responseAsString());
+
-
resIts[resIts.length - 1] = new NodeStoreIterator(
doc);
// Element el = doc.getAsGwtDocument().getDocumentElement();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tim...@us...> - 2011-05-19 18:41:54
|
Revision: 4357
http://mxquery.svn.sourceforge.net/mxquery/?rev=4357&view=rev
Author: timchurch
Date: 2011-05-19 18:41:47 +0000 (Thu, 19 May 2011)
Log Message:
-----------
Adding missing menu configuration and icons
Modified Paths:
--------------
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java
Added Paths:
-----------
trunk/MXQuery_Android_App/res/drawable-hdpi/ic_menu_contacts.png
trunk/MXQuery_Android_App/res/drawable-ldpi/ic_menu_contacts.png
trunk/MXQuery_Android_App/res/drawable-mdpi/ic_menu_contacts.png
trunk/MXQuery_Android_App/res/menu/
trunk/MXQuery_Android_App/res/menu/menu.xml
Added: trunk/MXQuery_Android_App/res/drawable-hdpi/ic_menu_contacts.png
===================================================================
(Binary files differ)
Property changes on: trunk/MXQuery_Android_App/res/drawable-hdpi/ic_menu_contacts.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/MXQuery_Android_App/res/drawable-ldpi/ic_menu_contacts.png
===================================================================
(Binary files differ)
Property changes on: trunk/MXQuery_Android_App/res/drawable-ldpi/ic_menu_contacts.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/MXQuery_Android_App/res/drawable-mdpi/ic_menu_contacts.png
===================================================================
(Binary files differ)
Property changes on: trunk/MXQuery_Android_App/res/drawable-mdpi/ic_menu_contacts.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/MXQuery_Android_App/res/menu/menu.xml
===================================================================
--- trunk/MXQuery_Android_App/res/menu/menu.xml (rev 0)
+++ trunk/MXQuery_Android_App/res/menu/menu.xml 2011-05-19 18:41:47 UTC (rev 4357)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/generate_contacts_XML"
+ android:icon="@drawable/ic_menu_contacts"
+ android:title="@string/menu_generate_contacts_xml" />
+</menu>
\ No newline at end of file
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java 2011-05-19 18:05:16 UTC (rev 4356)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java 2011-05-19 18:41:47 UTC (rev 4357)
@@ -14,68 +14,68 @@
import ch.ethz.repackaged.xquery.XQSequence;
public class MXQueryService extends Service {
- private XQDataSource xqjd = new MXQueryXQDataSource();
- public static String lastResult = null;
-
- // Binder given to clients
- private final IBinder mBinder = new MXQueryServiceBinder();
+ private XQDataSource xqjd = new MXQueryXQDataSource();
+ public static String lastResult = null;
- /**
- * Class used for the client Binder. Because we know this service always
- * runs in the same process as its clients, we don't need to deal with IPC.
- */
- public class MXQueryServiceBinder extends Binder {
- MXQueryService getService() {
- // Return this instance of MXQueryService so clients can call public methods
- return MXQueryService.this;
+ // Binder given to clients
+ private final IBinder mBinder = new MXQueryServiceBinder();
+
+ /**
+ * Class used for the client Binder. Because we know this service always
+ * runs in the same process as its clients, we don't need to deal with IPC.
+ */
+ public class MXQueryServiceBinder extends Binder {
+ MXQueryService getService() {
+ // Return this instance of MXQueryService so clients can call public methods
+ return MXQueryService.this;
+ }
}
- }
- @Override
- public IBinder onBind(Intent intent) {
- return mBinder;
- }
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mBinder;
+ }
- /** public method for clients */
- public void runQuery(String query, XQueryListener listener) {
- QueryThread queryThread = new QueryThread(query, listener);
- queryThread.start();
- }
-
- /**
- * Runnable thread to process query asyncronously and call callback method
- */
- private class QueryThread extends Thread {
- private String query;
- private XQueryListener listener;
- public QueryThread(String query, XQueryListener listener) {
- this.query = query;
- this.listener = listener;
+ /** public method for clients */
+ public void runQuery(String query, XQueryListener listener) {
+ QueryThread queryThread = new QueryThread(query, listener);
+ queryThread.start();
}
-
- public void run() {
- String result = doQuery(this.query);
- lastResult = result;
- System.out.println("QueryThread - saving result: " + result);
- listener.queryResult(result);
+
+ /**
+ * Runnable thread to process query asyncronously and call callback method
+ */
+ private class QueryThread extends Thread {
+ private String query;
+ private XQueryListener listener;
+ public QueryThread(String query, XQueryListener listener) {
+ this.query = query;
+ this.listener = listener;
+ }
+
+ public void run() {
+ String result = doQuery(this.query);
+ lastResult = result;
+ System.out.println("QueryThread - saving result: " + result);
+ listener.queryResult(result);
+ }
}
- }
-
- protected String doQuery(String query) {
- StringWriter result = new StringWriter();
- try {
- XQConnection xqjc = xqjd.getConnection();
- XQExpression xqje = xqjc.createExpression();
- XQSequence xqjs = xqje.executeQuery(query);
+ protected String doQuery(String query) {
+ StringWriter result = new StringWriter();
- xqjs.writeSequence(result, null);
- xqjc.close();
- } catch (XQException xqe) {
- xqe.printStackTrace();
+ try {
+ XQConnection xqjc = xqjd.getConnection();
+ XQExpression xqje = xqjc.createExpression();
+ XQSequence xqjs = xqje.executeQuery(query);
+
+ xqjs.writeSequence(result, null);
+ xqjc.close();
+ } catch (XQException xqe) {
+ xqe.printStackTrace();
+ }
+
+ return result.toString();
}
- return result.toString();
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-19 18:05:22
|
Revision: 4356
http://mxquery.svn.sourceforge.net/mxquery/?rev=4356&view=rev
Author: maxspeicher
Date: 2011-05-19 18:05:16 +0000 (Thu, 19 May 2011)
Log Message:
-----------
added query causing "return void" problems (ll. 221-234)
Modified Paths:
--------------
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-18 14:12:49 UTC (rev 4355)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-19 18:05:16 UTC (rev 4356)
@@ -217,6 +217,21 @@
//TESTING contacts XML generation
//generateContactsXML();
//printContactsXML();
+
+ /*
+ * This throws a NullPointerException at NativeFuncCall:175
+ * Because of return type void of Button.setText(...) ??
+ */
+// mResultView.setText(
+// runQuery(
+// "declare namespace r = \"java:ch.ethz.mxquery.android.R$id\";" +
+// "declare namespace helper = \"java:ch.ethz.mxquery.android.MXQuery\";" +
+// "declare namespace b = \"java:android.widget.Button\";" +
+// "let $id := r:button()" +
+// "let $button := helper:getButton($id)" +
+// "return b:setText($button, \"Hello XQuery!\")"
+// )
+// );
/*
* The following is a code to test reading a query from a static file.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-18 14:12:55
|
Revision: 4355
http://mxquery.svn.sourceforge.net/mxquery/?rev=4355&view=rev
Author: pm_fischer
Date: 2011-05-18 14:12:49 +0000 (Wed, 18 May 2011)
Log Message:
-----------
clean up test source files
Modified Paths:
--------------
trunk/MXQuery_Testing/XQTests/Queries/inserttest.xml
trunk/MXQuery_Testing/XQTests/Sources/doc.xml
Modified: trunk/MXQuery_Testing/XQTests/Queries/inserttest.xml
===================================================================
--- trunk/MXQuery_Testing/XQTests/Queries/inserttest.xml 2011-05-18 14:12:04 UTC (rev 4354)
+++ trunk/MXQuery_Testing/XQTests/Queries/inserttest.xml 2011-05-18 14:12:49 UTC (rev 4355)
@@ -1,2 +1 @@
-<?xml version='1.0' encoding='UTF-8' ?><doc>
-<NEW>2009-04-22T12:24:14.024+01:00</NEW><bla/><bla/><bla/><NEW>2011-04-28T12:45:40.129+01:00</NEW><NEW>2011-04-28T12:45:40.539+01:00</NEW><bla/><NEW>2011-05-13T08:34:41.919+01:00</NEW><NEW>2011-05-13T08:34:42.747+01:00</NEW><bla/></doc>
\ No newline at end of file
+<?xml version='1.0' encoding='UTF-8' ?><doc></doc>
Modified: trunk/MXQuery_Testing/XQTests/Sources/doc.xml
===================================================================
--- trunk/MXQuery_Testing/XQTests/Sources/doc.xml 2011-05-18 14:12:04 UTC (rev 4354)
+++ trunk/MXQuery_Testing/XQTests/Sources/doc.xml 2011-05-18 14:12:49 UTC (rev 4355)
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8' ?><catalog>
- <book id="bk101"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
@@ -8,7 +8,7 @@
<description>An in-depth look at creating applications
with XML.</description>
</book>
- <book id="bk102"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
@@ -18,7 +18,7 @@
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
- <book id="bk103"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
@@ -28,7 +28,7 @@
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
- <book id="bk104"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
@@ -39,7 +39,7 @@
for the inhabitants of London. Sequel to Maeve
Ascendant.</description>
</book>
- <book id="bk105"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk105">
<author>Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
@@ -49,7 +49,7 @@
battle one another for control of England. Sequel to
Oberon's Legacy.</description>
</book>
- <book id="bk106"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk106">
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
@@ -58,7 +58,7 @@
<description>When Carla meets Paul at an ornithology
conference, tempers fly as feathers get ruffled.</description>
</book>
- <book id="bk107"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk107">
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
@@ -67,7 +67,7 @@
<description>A deep sea diver finds true love twenty
thousand leagues beneath the sea.</description>
</book>
- <book id="bk108"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk108">
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
@@ -76,7 +76,7 @@
<description>An anthology of horror stories about roaches,
centipedes, scorpions and other insects.</description>
</book>
- <book id="bk109"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk109">
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
@@ -86,7 +86,7 @@
Uncertainty Device, James Salway discovers the problems
of being quantum.</description>
</book>
- <book id="bk110"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
@@ -95,7 +95,7 @@
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.</description>
</book>
- <book id="bk111"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk111">
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
@@ -105,7 +105,7 @@
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.</description>
</book>
- <book id="bk112"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk112">
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
@@ -116,4 +116,4 @@
integrated into a comprehensive development
environment.</description>
</book>
-</catalog>
\ No newline at end of file
+</catalog>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-18 14:12:15
|
Revision: 4354
http://mxquery.svn.sourceforge.net/mxquery/?rev=4354&view=rev
Author: pm_fischer
Date: 2011-05-18 14:12:04 +0000 (Wed, 18 May 2011)
Log Message:
-----------
fix regressions on HTTP IO
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-18 10:11:44 UTC (rev 4353)
+++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-18 14:12:04 UTC (rev 4354)
@@ -241,7 +241,9 @@
if (username!=null && (password==null||authmethod==null))
throw new DynamicException(EHC005_DYNAMIC_INVALID_REQUEST_ELEM, "If username is given, password and method also need to be provided", loc);
if (subIters.length > 1) {
- url = getStringValueOrEmpty(subIters[1]);
+ String urlCand = getStringValueOrEmpty(subIters[1]);
+ if (urlCand != null)
+ url = urlCand;
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java 2011-05-18 10:11:44 UTC (rev 4353)
+++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java 2011-05-18 14:12:04 UTC (rev 4354)
@@ -147,7 +147,6 @@
XDMIterator[] resIts;
private void init() throws MXQueryException {
- TokenInterface urlToken = subIters[0].next();
String url = getStringValue(subIters[0]);
if (request_type != REQUEST_TYPE_GET && url.indexOf('?') >= 0) {
throw new DynamicException(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-18 10:11:51
|
Revision: 4353
http://mxquery.svn.sourceforge.net/mxquery/?rev=4353&view=rev
Author: pm_fischer
Date: 2011-05-18 10:11:44 +0000 (Wed, 18 May 2011)
Log Message:
-----------
For SAX parsing, disable namespace-prefixes-mode
1) Not available on Android
2) Cleaner namespace scope handling by using SAX callbacks
Android IOLib now works
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java
trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-17 10:42:00 UTC (rev 4352)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-18 10:11:44 UTC (rev 4353)
@@ -38,6 +38,7 @@
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.util.Utils;
public class IOLib {
@@ -166,6 +167,12 @@
if (encoding == null)
encoding = "utf-8";
InputStream ins = null;
+ //android-specific treatment of local/file URIs:
+ //Strip all but the the last part
+ if (toOpen.startsWith("file:/")||toOpen.indexOf(":") < 0) {
+ String [] parts = Utils.split(toOpen, "/", true);
+ toOpen = parts[parts.length-1];
+ }
URI uri;
try {
uri = new URI(toOpen);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java 2011-05-17 10:42:00 UTC (rev 4352)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java 2011-05-18 10:11:44 UTC (rev 4353)
@@ -1,521 +1,547 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package ch.ethz.mxquery.xdmio.xmlAdapters;
-
-import java.io.IOException;
-import java.util.Properties;
-import java.util.Vector;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.ext.DeclHandler;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.DefaultHandler;
-
-import ch.ethz.mxquery.contextConfig.Context;
-import ch.ethz.mxquery.datamodel.QName;
-import ch.ethz.mxquery.datamodel.XQName;
-import ch.ethz.mxquery.datamodel.types.Type;
-import ch.ethz.mxquery.datamodel.xdm.CommentToken;
-import ch.ethz.mxquery.datamodel.xdm.ElementToken;
-import ch.ethz.mxquery.datamodel.xdm.NamedToken;
-import ch.ethz.mxquery.datamodel.xdm.ProcessingInstrToken;
-import ch.ethz.mxquery.datamodel.xdm.TextToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.DynamicException;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
-import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.QueryLocation;
-import ch.ethz.mxquery.model.XDMIterator;
-import ch.ethz.mxquery.util.Utils;
-
-public class NonSchemaValidatingSaxImportAdapter extends XDMImportAdapter {
-
-
- SaxAdapter adapter;
- ParseWorker worker;
- MXQueryException parseException = null;
- protected InputSource tobeParsed;
-
- Vector tokens;
- TokenInterface [] currBulk;
- int bulkPos = 0;
- private static final int TOKENBLOCKSIZE = 100;
- private static final int PARSED_BLOCKS_WAITING = 10;
- int validationMode;
- boolean tidyInput;
- private boolean done = false;
-
-
- class SaxAdapter extends DefaultHandler implements LexicalHandler, DeclHandler{
-
- private boolean startCData;
-
- private XMLReader reader;
-
- private boolean inDTD = false;
-
- private StringBuffer pendingTextContent = new StringBuffer();
- TokenInterface [] currToPush = new TokenInterface[TOKENBLOCKSIZE];
- int blockPos = 0;
-
- public SaxAdapter(XMLReader source) {
- reader = source;
- }
-
- public void parse() throws SAXException, IOException,MXQueryException {
- try {
- if (reader == null) {
- String saxParser = System.getProperty("javax.xml.parsers.SAXParserFactory");
- if (tidyInput) {
- System.setProperty("javax.xml.parsers.SAXParserFactory", "org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl");
- } else
- System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
-
- SAXParserFactory spf = SAXParserFactory.newInstance();
- if (saxParser != null)
- System.setProperty("javax.xml.parsers.SAXParserFactory", saxParser);
- else {
- // use indirect way, since clearProperties is not available in 1.4
- Properties sysProps = System.getProperties();
- sysProps.remove("javax.xml.parsers.SAXParserFactory");
- }
-
- //if (!tidyInput) {
- spf.setNamespaceAware(true);
- spf.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
- //} else {
- // spf.setFeature("http://xml.org/sax/features/namespaces",false);
- //}
- if (validationMode == Context.DTD_VALIDATION) {
- spf.setFeature("http://xml.org/sax/features/validation", true);
- spf.setFeature("http://apache.org/xml/features/validation/dynamic", true);
- } else if (validationMode == Context.IGNORE_DTD){
- spf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar",false);
- spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
- }
-
- SAXParser parser = spf.newSAXParser();
- reader = parser.getXMLReader();
- }
- reader.setErrorHandler(this);
- reader.setProperty("http://xml.org/sax/properties/lexical-handler", this);
- if (validationMode == Context.DTD_VALIDATION) {
- reader.setProperty("http://xml.org/sax/properties/declaration-handler", this);
- }
- // reader.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", context.initDictionary().getSchemaLocations());
- reader.setContentHandler(this);
- if (tobeParsed != null)
- reader.parse(tobeParsed);
- else
- reader.parse((String)null);
- } catch (SAXException e) {
- throw new DynamicException(ErrorCodes.A0007_EC_IO,"Error creating validating input: "+e.toString(),loc);
- } catch (ParserConfigurationException e) {
- throw new MXQueryException(ErrorCodes.A0002_EC_NOT_SUPPORTED,"Error creating validating input - parser configuration error",loc);
- }
- }
-
- private void addToken(TokenInterface tok) throws SAXException{
- currToPush[blockPos++] = tok;
- if (blockPos == currToPush.length || tok == Token.END_SEQUENCE_TOKEN) {
- synchronized(tokens) {
- while (tokens.size() > PARSED_BLOCKS_WAITING)
- try {
- tokens.wait();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- throw new SAXException("Stop worker thread");
- }
- tokens.add(currToPush);
- tokens.notify();
- }
- currToPush = new TokenInterface[TOKENBLOCKSIZE];
- blockPos = 0;
- }
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- emitPendingTextContent();
- try {
- addToken(new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION,null), data, target,curNsScope));
- } catch (MXQueryException e) {
- e.printStackTrace();
- }
- }
-
- public void startDocument() throws SAXException {
- emitPendingTextContent();
- addToken(new Token(Type.START_DOCUMENT, createNextTokenId(Type.START_DOCUMENT,null),curNsScope));
- if (getURI() != null)
- curNsScope.setBaseURI(getURI());
- //level++;
- }
-
- public void endDocument() throws SAXException {
- emitPendingTextContent();
- addToken(new Token(Type.END_DOCUMENT, null,curNsScope));
- addToken(Token.END_SEQUENCE_TOKEN);
- level--;
- }
-
- /** Start element. */
- public void startElement(String uri, String localName, String qname, Attributes attributes) throws SAXException {
- emitPendingTextContent();
- level++;
- Vector myToks = new Vector();
- boolean foundId = false;
- boolean foundIdREFS = false;
-
- String xmlId = null;
- String [] xmlIdREFS = null;
-
- String prefix = null;
- String localPart;
- boolean createdNSScope = false;
- int splitPos = qname.indexOf(':');
- if (splitPos > 0) {
- prefix = qname.substring(0,splitPos);
- localPart = qname.substring(splitPos+1);
- } else
- localPart = qname;
- XQName qName = new QName(uri, prefix, localPart);
- NamedToken token = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG,qName.toString()), qName, curNsScope);
- myToks.add(token);
-
- for (int i = 0; i < attributes.getLength(); i++) {
- int type;
- boolean setID = false;
- type = Type.UNTYPED_ATOMIC; //TODO: DTD types annotation, e.g. ID?
-
- try {
- QName attQname = new QName(attributes.getQName(i));
- String attVal = attributes.getValue(i);
-
- if (!foundId && (type == Type.ID || isXMLId(attQname,qName))) {
- foundId = true;
- xmlId = attVal;
- }
- if (!foundIdREFS && (type == Type.IDREF || isIDREF(attQname,qName))) {
- foundIdREFS = true;
- xmlIdREFS = new String[]{attVal};
- }
-
- if (!foundIdREFS && (type == Type.IDREFS || isIDREFS(attQname,qName))) {
- foundIdREFS = true;
- xmlIdREFS = Utils.split(attVal," ", false);
- }
-
-
- boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, attQname, attVal);
- if (newOpened && !createdNSScope)
- myToks.setElementAt(new ElementToken(Type.START_TAG, token.getNodeId(), qName, curNsScope), 0);
-
- if (attQname.getNamespacePrefix() == null || attQname.getNamespacePrefix().equals("")) {
- if (attQname.getLocalPart().equals("xmlns"))
- continue;
- } else if (attQname.getNamespacePrefix().equals("xmlns"))
- continue;
-
- attQname.setNamespaceURI(attributes.getURI(i));
- NamedToken attToken = createAttributeToken(type, attributes.getValue(i), attQname, curNsScope);
- if (foundId && !setID){
- attToken.setID(xmlId);
- setID = true;
- }
- if (foundIdREFS){
- attToken.setIDREFS(xmlIdREFS);
- foundIdREFS = false;
- }
- myToks.add(attToken);
- } catch (MXQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if (level < 2 && uri != null && localName.equals(qname)&& !createdNSScope) {
- try {
- checkOpenNsScopeAddNs(createdNSScope, new QName(Context.NS_XMLNS), uri);
- myToks.setElementAt(new ElementToken(Type.START_TAG, token.getNodeId(), qName, curNsScope), 0);
- } catch (MXQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-
- if (foundId) {
- NamedToken nmToken = (NamedToken)myToks.elementAt(0);
- nmToken.setID(xmlId);
- }
- for (int i=0;i<myToks.size();i++) {
- addToken((TokenInterface)myToks.elementAt(i));
- }
- } // startElement(String,String,String,Attributes)
-
-
- /** End element. */
- public void endElement(String uri, String localName, String qname) throws SAXException {
- emitPendingTextContent();
- String prefix = null;
- String localPart;
- //String[] qNameParts = qname.split(":");
- int splitPos = qname.indexOf(':');
- if (splitPos > 0) {
- prefix = qname.substring(0,splitPos);
- localPart = qname.substring(splitPos+1);
- } else
- localPart = qname;
-
- XQName qName = new QName(uri, prefix, localPart);
- NamedToken token = new ElementToken(Type.END_TAG, null, qName, curNsScope);
- addToken(token);
- checkCloseNsScope();
- level--;
- } // endElement(String,String,String)
-
- public void ignorableWhitespace(char[] ch, int start, int length)
- throws SAXException {
- characters(ch, start, length);
- }
-
- private void emitPendingTextContent() throws SAXException{
- if (pendingTextContent.length() > 0) {
- int type = Type.TEXT_NODE_UNTYPED_ATOMIC;
- try {
- addToken(new TextToken(type,createNextTokenId(type,null), pendingTextContent.toString(), curNsScope));
- } catch (MXQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- pendingTextContent = new StringBuffer();
- }
-
- }
- public void characters(char[] ch, int start, int length) throws SAXException {
-
-// for (int i = start; i < start + length; i++) {
-// text.append(ch[i]);
-// }
- int type = Type.TEXT_NODE_UNTYPED_ATOMIC;
- if (startCData) {
- emitPendingTextContent();
- try {
- addToken(new TextToken(type,createNextTokenId(type,null), new String(ch,start,length), curNsScope));
- }catch (MXQueryException e) {
- throw new SAXException(e.toString());
- }
-
- } else {
- pendingTextContent.append(ch,start,length);
- }
- }
-
- public void error(SAXParseException e) throws SAXException {
- throw e;
- }
-
- public void fatalError(SAXParseException e) throws SAXException {
- throw e;
- }
-
- public void warning(SAXParseException e) throws SAXException {
- System.out.println("Warning: " + e.getMessage());
- }
-
- public void comment(char[] ch, int start, int end) throws SAXException {
- emitPendingTextContent();
- if (!inDTD) {
- // only take comments from the main file, not from the DTD
- String text = new String(ch, start, end);
- try {
- addToken(new CommentToken(createNextTokenId(Type.COMMENT,null), text,curNsScope));
- } catch (DynamicException e) {
- throw new SAXException(e);
- }
- }
- }
-
- public void endCDATA() throws SAXException {
- startCData = false;
- }
-
- public void endDTD() throws SAXException {
- inDTD = false;
- }
-
- public void endEntity(String arg0) throws SAXException {
- //System.out.println("Entity ended");
- }
-
- public void startCDATA() throws SAXException {
- startCData = true;
- }
-
- public void startDTD(String name, String publicID, String systemID) throws SAXException {
- systemid = systemID;
- publicid = publicID;
- dtdRootElem = name;
- inDTD = true;
- }
-
- public void startEntity(String arg0) throws SAXException {
- //System.out.println("Entitiy started "+arg0);
- }
-
- public void attributeDecl(String name, String name2, String type,String mode, String value) throws SAXException {
- if (type.equals("ID"))idsVector.add(name+"#"+name2);
- if (type.equals("IDREF")) idRefVector.add(name+"#"+name2);
- if (type.equals("IDREFS")) idRefsVector.add(name+"#"+name2);
- }
-
- public void elementDecl(String name, String model) throws SAXException {
- //System.out.println("element decl"+model);
- }
-
- public void externalEntityDecl(String name, String publicId,
- String systemId) throws SAXException {
-// System.out.println("external decl");
-
- }
-
- public void internalEntityDecl(String name, String value)
- throws SAXException {
- // System.out.println("internal decl");
-
- }
- }
-
-
- class ParseWorker extends Thread {
- Vector tokens;
- SaxAdapter adapter;
-
- public ParseWorker(Vector tokens, SaxAdapter adapter) {
- super();
- this.tokens = tokens;
- this.adapter = adapter;
- }
-
- public void run() {
- try {
- adapter.parse();
- }
- catch (SAXException e) {
- String message = e.getMessage();
- parseException = new DynamicException(ErrorCodes.E0027_DYNAMIC_VALIDATE_UNEXPECTED_VALIDITY, message, loc);
- synchronized(tokens) {
- tokens.notify();
- }
-
- } catch (IOException e) {
- parseException = new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing: "+e.toString(),loc);
- synchronized(tokens) {
- tokens.notify();
- }
- } catch (MXQueryException e) {
- parseException = e;
- synchronized(tokens) {
- tokens.notify();
- }
- }
- }
- }
-
- public NonSchemaValidatingSaxImportAdapter(Context ctx, QueryLocation loc,InputSource xml, int validationMode, boolean tidyInput) {
- super(ctx,loc);
- adapter= new SaxAdapter(null);
- this.tokens = new Vector();
- tobeParsed = xml;
- this.tidyInput = tidyInput;
- this.validationMode= validationMode;
- }
-
- public NonSchemaValidatingSaxImportAdapter(Context ctx, QueryLocation loc,XMLReader source) {
- super(ctx,loc);
- adapter= new SaxAdapter(source);
- this.tokens = new Vector();
- }
-
- protected void init() throws MXQueryException {
- worker = new ParseWorker(tokens, adapter);
- worker.start();
- }
-
- protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException {
- XDMImportAdapter res = new NonSchemaValidatingSaxImportAdapter(this.context, loc,tobeParsed, validationMode, false);
- res.uri = uri;
- return res;
- }
- public TokenInterface next() throws MXQueryException {
- if (called == 0) {
- init();
- called++;
- getBulkFromQueue();
- }
- if (done)
- return Token.END_SEQUENCE_TOKEN;
- if (bulkPos == currBulk.length)
- getBulkFromQueue();
- TokenInterface tok = currBulk[bulkPos++];
- if (tok == Token.END_SEQUENCE_TOKEN)
- done = true;
- return tok;
- }
-
- private void getBulkFromQueue() throws MXQueryException {
- synchronized(tokens) {
- while (tokens.isEmpty() && parseException == null) {
- try {
- tokens.wait();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if (parseException != null)
- throw parseException;
- currBulk = (TokenInterface[])tokens.remove(0);
- bulkPos = 0;
- tokens.notify();
- }
- }
-
-
- protected void resetImpl() throws MXQueryException {
- super.resetImpl();
- done = false;
- worker.interrupt();
- }
-
- protected void freeResources(boolean restartable)
- throws MXQueryException {
- // TODO Auto-generated method stub
- super.freeResources(restartable);
- if (worker != null)
- worker.interrupt();
- }
-
-
-}
+/* Copyright 2006 - 2009 ETH Zurich
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.ethz.mxquery.xdmio.xmlAdapters;
+
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Vector;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.DeclHandler;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.Namespace;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.XQName;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.xdm.CommentToken;
+import ch.ethz.mxquery.datamodel.xdm.ElementToken;
+import ch.ethz.mxquery.datamodel.xdm.NamedToken;
+import ch.ethz.mxquery.datamodel.xdm.ProcessingInstrToken;
+import ch.ethz.mxquery.datamodel.xdm.TextToken;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.datamodel.xdm.XDMScope;
+import ch.ethz.mxquery.exceptions.DynamicException;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.util.Utils;
+
+public class NonSchemaValidatingSaxImportAdapter extends XDMImportAdapter {
+
+
+ SaxAdapter adapter;
+ ParseWorker worker;
+ MXQueryException parseException = null;
+ protected InputSource tobeParsed;
+
+ Vector tokens;
+ TokenInterface [] currBulk;
+ int bulkPos = 0;
+ private static final int TOKENBLOCKSIZE = 100;
+ private static final int PARSED_BLOCKS_WAITING = 10;
+ int validationMode;
+ boolean tidyInput;
+ private boolean done = false;
+
+
+ class SaxAdapter extends DefaultHandler implements LexicalHandler, DeclHandler{
+
+ private boolean startCData;
+
+ private XMLReader reader;
+
+ private boolean inDTD = false;
+
+ private StringBuffer pendingTextContent = new StringBuffer();
+ TokenInterface [] currToPush = new TokenInterface[TOKENBLOCKSIZE];
+ int blockPos = 0;
+
+ public SaxAdapter(XMLReader source) {
+ reader = source;
+ }
+
+ public void parse() throws SAXException, IOException,MXQueryException {
+ try {
+ if (reader == null) {
+ String saxParser = System.getProperty("javax.xml.parsers.SAXParserFactory");
+ if (tidyInput) {
+ System.setProperty("javax.xml.parsers.SAXParserFactory", "org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl");
+ } else
+ System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
+
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ if (saxParser != null)
+ System.setProperty("javax.xml.parsers.SAXParserFactory", saxParser);
+ else {
+ // use indirect way, since clearProperties is not available in 1.4
+ Properties sysProps = System.getProperties();
+ sysProps.remove("javax.xml.parsers.SAXParserFactory");
+ }
+
+ //if (!tidyInput) {
+ spf.setNamespaceAware(true);
+ //spf.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+ //} else {
+ // spf.setFeature("http://xml.org/sax/features/namespaces",false);
+ //}
+ if (validationMode == Context.DTD_VALIDATION) {
+ spf.setFeature("http://xml.org/sax/features/validation", true);
+ spf.setFeature("http://apache.org/xml/features/validation/dynamic", true);
+ } else if (validationMode == Context.IGNORE_DTD){
+ spf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar",false);
+ spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
+ }
+
+ SAXParser parser = spf.newSAXParser();
+ reader = parser.getXMLReader();
+ }
+ reader.setErrorHandler(this);
+ reader.setProperty("http://xml.org/sax/properties/lexical-handler", this);
+ if (validationMode == Context.DTD_VALIDATION) {
+ reader.setProperty("http://xml.org/sax/properties/declaration-handler", this);
+ }
+ // reader.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", context.initDictionary().getSchemaLocations());
+ reader.setContentHandler(this);
+ if (tobeParsed != null)
+ reader.parse(tobeParsed);
+ else
+ reader.parse((String)null);
+ } catch (SAXException e) {
+ throw new DynamicException(ErrorCodes.A0007_EC_IO,"Error creating validating input: "+e.toString(),loc);
+ } catch (ParserConfigurationException e) {
+ throw new MXQueryException(ErrorCodes.A0002_EC_NOT_SUPPORTED,"Error creating validating input - parser configuration error",loc);
+ }
+ }
+
+ private void addToken(TokenInterface tok) throws SAXException{
+ currToPush[blockPos++] = tok;
+ if (blockPos == currToPush.length || tok == Token.END_SEQUENCE_TOKEN) {
+ synchronized(tokens) {
+ while (tokens.size() > PARSED_BLOCKS_WAITING)
+ try {
+ tokens.wait();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ throw new SAXException("Stop worker thread");
+ }
+ tokens.add(currToPush);
+ tokens.notify();
+ }
+ currToPush = new TokenInterface[TOKENBLOCKSIZE];
+ blockPos = 0;
+ }
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException {
+ emitPendingTextContent();
+ try {
+ addToken(new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION,null), data, target,curNsScope));
+ } catch (MXQueryException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void startDocument() throws SAXException {
+ emitPendingTextContent();
+ addToken(new Token(Type.START_DOCUMENT, createNextTokenId(Type.START_DOCUMENT,null),curNsScope));
+ if (getURI() != null)
+ curNsScope.setBaseURI(getURI());
+ //level++;
+ }
+
+ public void endDocument() throws SAXException {
+ emitPendingTextContent();
+ addToken(new Token(Type.END_DOCUMENT, null,curNsScope));
+ addToken(Token.END_SEQUENCE_TOKEN);
+ level--;
+ }
+
+ /** Start element. */
+ public void startElement(String uri, String localName, String qname, Attributes attributes) throws SAXException {
+ emitPendingTextContent();
+ level++;
+ Vector myToks = new Vector();
+ boolean foundId = false;
+ boolean foundIdREFS = false;
+
+ String xmlId = null;
+ String [] xmlIdREFS = null;
+
+ String prefix = null;
+ String localPart;
+ boolean createdNSScope = false;
+ int splitPos = qname.indexOf(':');
+ if (splitPos > 0) {
+ prefix = qname.substring(0,splitPos);
+ localPart = qname.substring(splitPos+1);
+ } else
+ localPart = qname;
+ XQName qName = new QName(uri, prefix, localPart);
+ NamedToken token = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG,qName.toString()), qName, curNsScope);
+ myToks.add(token);
+
+ for (int i = 0; i < attributes.getLength(); i++) {
+ int type;
+ boolean setID = false;
+ type = Type.UNTYPED_ATOMIC; //TODO: DTD types annotation, e.g. ID?
+
+ try {
+ QName attQname = new QName(attributes.getQName(i));
+ String attVal = attributes.getValue(i);
+
+ if (!foundId && (type == Type.ID || isXMLId(attQname,qName))) {
+ foundId = true;
+ xmlId = attVal;
+ }
+ if (!foundIdREFS && (type == Type.IDREF || isIDREF(attQname,qName))) {
+ foundIdREFS = true;
+ xmlIdREFS = new String[]{attVal};
+ }
+
+ if (!foundIdREFS && (type == Type.IDREFS || isIDREFS(attQname,qName))) {
+ foundIdREFS = true;
+ xmlIdREFS = Utils.split(attVal," ", false);
+ }
+
+
+ boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, attQname, attVal);
+ //boolean newOpened = false;
+ if (newOpened && !createdNSScope)
+ myToks.setElementAt(new ElementToken(Type.START_TAG, token.getNodeId(), qName, curNsScope), 0);
+
+ if (attQname.getNamespacePrefix() == null || attQname.getNamespacePrefix().equals("")) {
+ if (attQname.getLocalPart().equals("xmlns"))
+ continue;
+ } else if (attQname.getNamespacePrefix().equals("xmlns"))
+ continue;
+
+ attQname.setNamespaceURI(attributes.getURI(i));
+ NamedToken attToken = createAttributeToken(type, attributes.getValue(i), attQname, curNsScope);
+ if (foundId && !setID){
+ attToken.setID(xmlId);
+ setID = true;
+ }
+ if (foundIdREFS){
+ attToken.setIDREFS(xmlIdREFS);
+ foundIdREFS = false;
+ }
+ myToks.add(attToken);
+ } catch (MXQueryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+// if (level < 2 && uri != null && localName.equals(qname)&& !createdNSScope) {
+// try {
+// //checkOpenNsScopeAddNs(createdNSScope, new QName(Context.NS_XMLNS), uri);
+// //myToks.setElementAt(new ElementToken(Type.START_TAG, token.getNodeId(), qName, curNsScope), 0);
+// } catch (MXQueryException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+
+
+ if (foundId) {
+ NamedToken nmToken = (NamedToken)myToks.elementAt(0);
+ nmToken.setID(xmlId);
+ }
+ for (int i=0;i<myToks.size();i++) {
+ addToken((TokenInterface)myToks.elementAt(i));
+ }
+ } // startElement(String,String,String,Attributes)
+
+
+ /** End element. */
+ public void endElement(String uri, String localName, String qname) throws SAXException {
+ emitPendingTextContent();
+ String prefix = null;
+ String localPart;
+ //String[] qNameParts = qname.split(":");
+ int splitPos = qname.indexOf(':');
+ if (splitPos > 0) {
+ prefix = qname.substring(0,splitPos);
+ localPart = qname.substring(splitPos+1);
+ } else
+ localPart = qname;
+
+ XQName qName = new QName(uri, prefix, localPart);
+ NamedToken token = new ElementToken(Type.END_TAG, null, qName, curNsScope);
+ addToken(token);
+ checkCloseNsScope();
+ level--;
+ } // endElement(String,String,String)
+
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException {
+ characters(ch, start, length);
+ }
+
+ private void emitPendingTextContent() throws SAXException{
+ if (pendingTextContent.length() > 0) {
+ int type = Type.TEXT_NODE_UNTYPED_ATOMIC;
+ try {
+ addToken(new TextToken(type,createNextTokenId(type,null), pendingTextContent.toString(), curNsScope));
+ } catch (MXQueryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ pendingTextContent = new StringBuffer();
+ }
+
+ }
+ public void characters(char[] ch, int start, int length) throws SAXException {
+
+// for (int i = start; i < start + length; i++) {
+// text.append(ch[i]);
+// }
+ int type = Type.TEXT_NODE_UNTYPED_ATOMIC;
+ if (startCData) {
+ emitPendingTextContent();
+ try {
+ addToken(new TextToken(type,createNextTokenId(type,null), new String(ch,start,length), curNsScope));
+ }catch (MXQueryException e) {
+ throw new SAXException(e.toString());
+ }
+
+ } else {
+ pendingTextContent.append(ch,start,length);
+ }
+ }
+
+ public void error(SAXParseException e) throws SAXException {
+ throw e;
+ }
+
+ public void fatalError(SAXParseException e) throws SAXException {
+ throw e;
+ }
+
+ public void warning(SAXParseException e) throws SAXException {
+ System.out.println("Warning: " + e.getMessage());
+ }
+
+ public void comment(char[] ch, int start, int end) throws SAXException {
+ emitPendingTextContent();
+ if (!inDTD) {
+ // only take comments from the main file, not from the DTD
+ String text = new String(ch, start, end);
+ try {
+ addToken(new CommentToken(createNextTokenId(Type.COMMENT,null), text,curNsScope));
+ } catch (DynamicException e) {
+ throw new SAXException(e);
+ }
+ }
+ }
+
+ public void endCDATA() throws SAXException {
+ startCData = false;
+ }
+
+ public void endDTD() throws SAXException {
+ inDTD = false;
+ }
+
+ public void endEntity(String arg0) throws SAXException {
+ //System.out.println("Entity ended");
+ }
+
+ public void startCDATA() throws SAXException {
+ startCData = true;
+ }
+
+ public void startDTD(String name, String publicID, String systemID) throws SAXException {
+ systemid = systemID;
+ publicid = publicID;
+ dtdRootElem = name;
+ inDTD = true;
+ }
+
+ public void startEntity(String arg0) throws SAXException {
+ //System.out.println("Entitiy started "+arg0);
+ }
+
+ public void attributeDecl(String name, String name2, String type,String mode, String value) throws SAXException {
+ if (type.equals("ID"))idsVector.add(name+"#"+name2);
+ if (type.equals("IDREF")) idRefVector.add(name+"#"+name2);
+ if (type.equals("IDREFS")) idRefsVector.add(name+"#"+name2);
+ }
+
+ public void elementDecl(String name, String model) throws SAXException {
+ //System.out.println("element decl"+model);
+ }
+
+ public void externalEntityDecl(String name, String publicId,
+ String systemId) throws SAXException {
+// System.out.println("external decl");
+
+ }
+
+ public void internalEntityDecl(String name, String value)
+ throws SAXException {
+ // System.out.println("internal decl");
+
+ }
+
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException {
+ if (scopeDepth.peek() != level+1) {
+ curNsScope = new XDMScope(curNsScope);
+ scopeDepth.push(level+1);
+ }
+ Namespace nm = new Namespace(prefix, uri);
+ try {
+ curNsScope.addNamespace(nm);
+ } catch (MXQueryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ // TODO Auto-generated method stub
+ if (scopeDepth.peek() == level+1) {
+ curNsScope = curNsScope.getParent();
+ scopeDepth.pop();
+ }
+ }
+ }
+
+
+ class ParseWorker extends Thread {
+ Vector tokens;
+ SaxAdapter adapter;
+
+ public ParseWorker(Vector tokens, SaxAdapter adapter) {
+ super();
+ this.tokens = tokens;
+ this.adapter = adapter;
+ }
+
+ public void run() {
+ try {
+ adapter.parse();
+ }
+ catch (SAXException e) {
+ String message = e.getMessage();
+ parseException = new DynamicException(ErrorCodes.E0027_DYNAMIC_VALIDATE_UNEXPECTED_VALIDITY, message, loc);
+ synchronized(tokens) {
+ tokens.notify();
+ }
+
+ } catch (IOException e) {
+ parseException = new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing: "+e.toString(),loc);
+ synchronized(tokens) {
+ tokens.notify();
+ }
+ } catch (MXQueryException e) {
+ parseException = e;
+ synchronized(tokens) {
+ tokens.notify();
+ }
+ }
+ }
+ }
+
+ public NonSchemaValidatingSaxImportAdapter(Context ctx, QueryLocation loc,InputSource xml, int validationMode, boolean tidyInput) {
+ super(ctx,loc);
+ adapter= new SaxAdapter(null);
+ this.tokens = new Vector();
+ tobeParsed = xml;
+ this.tidyInput = tidyInput;
+ this.validationMode= validationMode;
+ }
+
+ public NonSchemaValidatingSaxImportAdapter(Context ctx, QueryLocation loc,XMLReader source) {
+ super(ctx,loc);
+ adapter= new SaxAdapter(source);
+ this.tokens = new Vector();
+ }
+
+ protected void init() throws MXQueryException {
+ worker = new ParseWorker(tokens, adapter);
+ worker.start();
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException {
+ XDMImportAdapter res = new NonSchemaValidatingSaxImportAdapter(this.context, loc,tobeParsed, validationMode, false);
+ res.uri = uri;
+ return res;
+ }
+ public TokenInterface next() throws MXQueryException {
+ if (called == 0) {
+ init();
+ called++;
+ getBulkFromQueue();
+ }
+ if (done)
+ return Token.END_SEQUENCE_TOKEN;
+ if (bulkPos == currBulk.length)
+ getBulkFromQueue();
+ TokenInterface tok = currBulk[bulkPos++];
+ if (tok == Token.END_SEQUENCE_TOKEN)
+ done = true;
+ return tok;
+ }
+
+ private void getBulkFromQueue() throws MXQueryException {
+ synchronized(tokens) {
+ while (tokens.isEmpty() && parseException == null) {
+ try {
+ tokens.wait();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ if (parseException != null)
+ throw parseException;
+ currBulk = (TokenInterface[])tokens.remove(0);
+ bulkPos = 0;
+ tokens.notify();
+ }
+ }
+
+
+ protected void resetImpl() throws MXQueryException {
+ super.resetImpl();
+ done = false;
+ worker.interrupt();
+ }
+
+ protected void freeResources(boolean restartable)
+ throws MXQueryException {
+ // TODO Auto-generated method stub
+ super.freeResources(restartable);
+ if (worker != null)
+ worker.interrupt();
+ }
+
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2011-05-17 10:42:00 UTC (rev 4352)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2011-05-18 10:11:44 UTC (rev 4353)
@@ -235,7 +235,7 @@
/** Check if a new XDM scope needs to be opened and opens it if needed*/
private boolean checkOpenXDMScope(boolean createdNSScope) {
- if (!createdNSScope) {
+ if (scopeDepth.peek() != level) {
scopeDepth.push(level);
curNsScope = new XDMScope(curNsScope);
createdNSScope = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tim...@us...> - 2011-05-17 10:42:07
|
Revision: 4352
http://mxquery.svn.sourceforge.net/mxquery/?rev=4352&view=rev
Author: timchurch
Date: 2011-05-17 10:42:00 +0000 (Tue, 17 May 2011)
Log Message:
-----------
- Menu item for generating Contacts XML
- Moved Contacts XML logic into AsyncTask
- Set application to be "debuggable" (to allow debugging real devices via USB)
Modified Paths:
--------------
trunk/MXQuery_Android_App/AndroidManifest.xml
trunk/MXQuery_Android_App/res/values/strings.xml
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
Modified: trunk/MXQuery_Android_App/AndroidManifest.xml
===================================================================
--- trunk/MXQuery_Android_App/AndroidManifest.xml 2011-05-17 10:24:14 UTC (rev 4351)
+++ trunk/MXQuery_Android_App/AndroidManifest.xml 2011-05-17 10:42:00 UTC (rev 4352)
@@ -5,7 +5,7 @@
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"></uses-sdk>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
- <application android:icon="@drawable/xquery_icon" android:label="@string/app_name" android:permission="android.permission.READ_CONTACTS">
+ <application android:icon="@drawable/xquery_icon" android:label="@string/app_name" android:permission="android.permission.READ_CONTACTS" android:debuggable="true">
<activity android:name="Start">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Modified: trunk/MXQuery_Android_App/res/values/strings.xml
===================================================================
--- trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-17 10:24:14 UTC (rev 4351)
+++ trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-17 10:42:00 UTC (rev 4352)
@@ -2,6 +2,10 @@
<resources>
<string name="app_name">MXQuery</string>
+ <!-- Menu Strings -->
+ <string name="menu_generate_contacts_xml">Generate Contacts XML</string>
+ <!-- End Menu Strings -->
+
<!-- UI Strings -->
<string name="queries_prompt">Choose a sample query...</string>
<string name="queries_prompt2">...or enter your query here:</string>
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-17 10:24:14 UTC (rev 4351)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-17 10:42:00 UTC (rev 4352)
@@ -16,16 +16,22 @@
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.ComponentName;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.provider.ContactsContract;
+import android.util.Log;
import android.util.Xml;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
@@ -53,19 +59,44 @@
// private XQueryAsyncTask mTask;
protected MXQueryService mService;
protected boolean mIsBound = false;
+ protected ProgressDialog mDialog;
protected XQDataSource xqjd = new MXQueryXQDataSource();
public static final String STATE_CHANGE_SETTINGS = "STATE_CHANGE_SETTINGS";
public static final int QUERY_RUNNING_DIALOG = 1;
+ public static final int GENERATING_CONTACTS_XML_DIALOG = 2;
public static final String UNDEFINED_LABEL = "Undefined";
+ private static final String LOG_TAG = "MXQuery.Start";
protected Dialog onCreateDialog(int id) {
- ProgressDialog dialog = new ProgressDialog(mActivity);
- dialog.setMessage("Query running...");
- dialog.setCancelable(true);
- return dialog;
+ switch(id) {
+ case QUERY_RUNNING_DIALOG:
+ mDialog = new ProgressDialog(mActivity);
+ mDialog.setMessage("Query running...");
+ mDialog.setCancelable(true);
+ return mDialog;
+ case GENERATING_CONTACTS_XML_DIALOG:
+ mDialog = new ProgressDialog(mActivity);
+ mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ mDialog.setMessage("Generating Contacts XML...");
+ mDialog.setCancelable(true);
+ return mDialog;
+ default:
+ return null;
+ }
}
+
+ protected void onPrepareDialog(int id, Dialog dialog) {
+ switch(id) {
+ case QUERY_RUNNING_DIALOG:
+ return;
+ case GENERATING_CONTACTS_XML_DIALOG:
+ int numContacts = getContactsCount();
+ mDialog.setMax(numContacts);
+ mDialog.setProgress(0);
+ }
+ }
/*
* protected class XQueryAsyncTask extends AsyncTask<String, Integer,
@@ -184,8 +215,8 @@
});
//TESTING contacts XML generation
- generateContactsXML();
- printContactsXML();
+ //generateContactsXML();
+ //printContactsXML();
/*
* The following is a code to test reading a query from a static file.
@@ -347,193 +378,358 @@
}
});
}
-
- /**
- * Generates XML file for all contact info
- * Should be moved to a better location after testing
- */
- protected void generateContactsXML() {
- System.out.println("generating contacts XML...");
- Cursor contactsCursor = getContacts();
-
- FileOutputStream fileOutputStream = null;
- XmlSerializer serializer = null;
- try {
- fileOutputStream = openFileOutput("contacts.xml", MODE_PRIVATE);
- serializer = Xml.newSerializer();
- serializer.setOutput(fileOutputStream, "UTF-8");
- serializer.startDocument(null, Boolean.valueOf(true));
- serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
- serializer.startTag(null, "CONTACTS");
-
- //iterate through contacts
- while(contactsCursor.moveToNext()) {
- String id = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts._ID));
- String customRingtone = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.CUSTOM_RINGTONE));
- String name = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
- Integer hasPhoneNumber = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
- Long lastTimeContacted = contactsCursor.getLong(contactsCursor.getColumnIndex(ContactsContract.Contacts.LAST_TIME_CONTACTED));
- String lookupKey = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
- Long photoId = contactsCursor.getLong(contactsCursor.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
- Integer sendToVoicemail = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.SEND_TO_VOICEMAIL));
- Integer starred = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.STARRED));
- Integer timesContaced = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.TIMES_CONTACTED));
-
- serializer.startTag(null, "CONTACT");
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.generate_contacts_XML:
+ new GenerateContactsXMLAsyncTask().execute();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+
+
+ protected class GenerateContactsXMLAsyncTask extends AsyncTask<Void, Integer, String> {
+ Integer numContacts = 100;
+ final String[] phoneProjection = new String[] {
+ ContactsContract.CommonDataKinds.Phone.NUMBER,
+ ContactsContract.CommonDataKinds.Phone.TYPE
+ };
+
+ final String[] emailProjection = new String[] {
+ ContactsContract.CommonDataKinds.Email.DATA,
+ ContactsContract.CommonDataKinds.Email.TYPE
+ };
+
+ @Override
+ protected void onPreExecute() {
+ mActivity.showDialog(GENERATING_CONTACTS_XML_DIALOG);
+ /*
+ numContacts = getContactsCount();
+
+ mDialog = new ProgressDialog(mActivity);
+ mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ mDialog.setMessage("Generating Contacts XML...");
+ mDialog.setCancelable(true);
+ mDialog.setMax(numContacts);
+ mDialog.setProgress(0);
+ mDialog.show();
+ */
+ }
+
+ @Override
+ protected void onPostExecute(String s) {
+ mActivity.removeDialog(GENERATING_CONTACTS_XML_DIALOG);
+ /*
+ if(mDialog.isShowing())
+ mDialog.dismiss();
+ */
+ //printContactsXML();
+ mResultView.setText(s);
+ }
+
+ @Override
+ protected void onCancelled() {
+ if(mDialog.isShowing())
+ mDialog.dismiss();
+ }
+
+ @Override
+ protected void onProgressUpdate(Integer... progress) {
+ mDialog.incrementProgressBy(1);
+
+ if(progress[0] >= numContacts) {
+ mDialog.setMessage("Saving...");
+ }
+ }
+
+ @Override
+ protected String doInBackground(Void... v) {
+ //generateContactsXML();
+ //return null;
+ return generateContactsXML();
+ }
+
+ /**
+ * Generates XML file for all contact info
+ * Should be moved to a better location after testing
+ */
+ private String generateContactsXML() {
+ System.out.println("generating contacts XML...");
+ ContentResolver cr = getContentResolver();
+ Cursor contactsCursor = getContacts();
+ numContacts = contactsCursor.getCount();
+
+ //FileOutputStream fileOutputStream = null;
+ XmlSerializer serializer = null;
+ StringWriter stringWriter = new StringWriter();
+ String xmlString = null;
+ try {
+ //fileOutputStream = openFileOutput("contacts.xml", MODE_PRIVATE);
+ serializer = Xml.newSerializer();
+ //serializer.setOutput(fileOutputStream, "UTF-8");
+ serializer.setOutput(stringWriter);
+ serializer.startDocument(null, Boolean.valueOf(true));
+ serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
+ serializer.startTag(null, "ANDROID_CONTACTS");
+
+ //iterate through contacts
+ Integer total = 0;
+ while(contactsCursor.moveToNext()) {
+ if(isCancelled()) {
+ return "";
+ }
+
+ String id = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts._ID));
+ String customRingtone = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.CUSTOM_RINGTONE));
+ String name = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
+ Integer hasPhoneNumber = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
+ Long lastTimeContacted = contactsCursor.getLong(contactsCursor.getColumnIndex(ContactsContract.Contacts.LAST_TIME_CONTACTED));
+ String lookupKey = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
+ Long photoId = contactsCursor.getLong(contactsCursor.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
+ Integer sendToVoicemail = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.SEND_TO_VOICEMAIL));
+ Integer starred = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.STARRED));
+ Integer timesContaced = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.TIMES_CONTACTED));
+
+ serializer.startTag(null, "CONTACT");
serializer.startTag(null, "_ID");
- serializer.text(id);
+ serializer.text(id);
serializer.endTag(null, "_ID");
serializer.startTag(null, "LOOKUP_KEY");
- serializer.text(lookupKey);
- serializer.endTag(null, "LOOKUP_KEY");
+ serializer.text(lookupKey);
+ serializer.endTag(null, "LOOKUP_KEY");
serializer.startTag(null, "DISPLAY_NAME");
- serializer.text(name);
- serializer.endTag(null, "DISPLAY_NAME");
+ serializer.text(name);
+ serializer.endTag(null, "DISPLAY_NAME");
if(customRingtone != null) {
- serializer.startTag(null, "CUSTOM_RINGTONE");
- serializer.text(customRingtone);
- serializer.endTag(null, "CUSTOM_RINGTONE");
+ serializer.startTag(null, "CUSTOM_RINGTONE");
+ serializer.text(customRingtone);
+ serializer.endTag(null, "CUSTOM_RINGTONE");
}
if(lastTimeContacted != null) {
- serializer.startTag(null, "LAST_TIME_CONTACTED");
- serializer.text(lastTimeContacted.toString());
- serializer.endTag(null, "LAST_TIME_CONTACTED");
+ serializer.startTag(null, "LAST_TIME_CONTACTED");
+ serializer.text(lastTimeContacted.toString());
+ serializer.endTag(null, "LAST_TIME_CONTACTED");
}
- if(photoId != null) {
- serializer.startTag(null, "PHOTO_ID");
- serializer.text(photoId.toString());
- serializer.endTag(null, "PHOTO_ID");
- }
- serializer.startTag(null, "SEND_TO_VOICEMAIL");
- serializer.text(sendToVoicemail.toString());
- serializer.endTag(null, "SEND_TO_VOICEMAIL");
- serializer.startTag(null, "STARRED");
- serializer.text(starred.toString());
- serializer.endTag(null, "STARRED");
- serializer.startTag(null, "TIMES_CONTACTED");
- serializer.text(timesContaced.toString());
- serializer.endTag(null, "TIMES_CONTACTED");
-
- //phone #s
- if(hasPhoneNumber > 0) {
+ if(photoId != null) {
+ serializer.startTag(null, "PHOTO_ID");
+ serializer.text(photoId.toString());
+ serializer.endTag(null, "PHOTO_ID");
+ }
+ serializer.startTag(null, "SEND_TO_VOICEMAIL");
+ serializer.text(sendToVoicemail.toString());
+ serializer.endTag(null, "SEND_TO_VOICEMAIL");
+ serializer.startTag(null, "STARRED");
+ serializer.text(starred.toString());
+ serializer.endTag(null, "STARRED");
+ serializer.startTag(null, "TIMES_CONTACTED");
+ serializer.text(timesContaced.toString());
+ serializer.endTag(null, "TIMES_CONTACTED");
+
+ //phone #s
+ if(hasPhoneNumber > 0) {
serializer.startTag(null, "PHONES");
//query phone number information
- Cursor phoneCursor = managedQuery(
- ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
- ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
- new String[]{id}, null);
-
- while (phoneCursor.moveToNext()) {
- String phoneNumber = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
- String phoneType = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
- String phoneTypeLabel = (String) ContactsContract.CommonDataKinds.Phone.getTypeLabel(
- this.getResources(),
- Integer.parseInt(phoneType),
- UNDEFINED_LABEL);
-
- serializer.startTag(null, "PHONE");
- serializer.startTag(null, "PHONE_NUMBER");
- serializer.text(phoneNumber);
- serializer.endTag(null, "PHONE_NUMBER");
- serializer.startTag(null, "PHONE_TYPE");
- serializer.text(phoneTypeLabel);
- serializer.endTag(null, "PHONE_TYPE");
- serializer.endTag(null, "PHONE");
- }
- phoneCursor.close();
- serializer.endTag(null, "PHONES");
+ Cursor phoneCursor = cr.query(
+ ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
+ phoneProjection,
+ ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
+ new String[]{id}, null);
+
+ while (phoneCursor.moveToNext()) {
+ String phoneNumber = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
+ String phoneType = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
+ String phoneTypeLabel = (String) ContactsContract.CommonDataKinds.Phone.getTypeLabel(
+ mActivity.getResources(),
+ Integer.parseInt(phoneType),
+ UNDEFINED_LABEL);
+
+ serializer.startTag(null, "PHONE");
+ serializer.startTag(null, "PHONE_NUMBER");
+ serializer.text(phoneNumber);
+ serializer.endTag(null, "PHONE_NUMBER");
+ serializer.startTag(null, "PHONE_TYPE");
+ serializer.text(phoneTypeLabel);
+ serializer.endTag(null, "PHONE_TYPE");
+ serializer.endTag(null, "PHONE");
+ }
+ phoneCursor.close();
+ serializer.endTag(null, "PHONES");
}
-
- //emails
- serializer.startTag(null, "EMAILS");
- Cursor emailCursor = managedQuery(
- ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
- ContactsContract.CommonDataKinds.Email.CONTACT_ID +" = ?",
- new String[]{id}, null);
-
- while (emailCursor.moveToNext()) {
- String emailAddress = emailCursor.getString(emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
- String emailType = emailCursor.getString(emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
- String emailTypeLabel = (String) ContactsContract.CommonDataKinds.Email.getTypeLabel(
- this.getResources(),
- Integer.parseInt(emailType),
- UNDEFINED_LABEL);
-
- serializer.startTag(null, "EMAIL");
- serializer.startTag(null, "EMAIL_ADDRESS");
- serializer.text(emailAddress);
- serializer.endTag(null, "EMAIL_ADDRESS");
- serializer.startTag(null, "EMAIL_TYPE");
- serializer.text(emailTypeLabel);
- serializer.endTag(null, "EMAIL_TYPE");
- serializer.endTag(null, "EMAIL");
- }
- serializer.endTag(null, "EMAILS");
-
- //TODO - addresses, organizations, notes, websites, nickname, etc
- serializer.endTag(null, "CONTACT");
+
+ //emails
+ Cursor emailCursor = cr.query(
+ ContactsContract.CommonDataKinds.Email.CONTENT_URI,
+ emailProjection,
+ ContactsContract.CommonDataKinds.Email.CONTACT_ID +" = ?",
+ new String[]{id}, null);
+
+ if(emailCursor.getCount() > 0) {
+ serializer.startTag(null, "EMAILS");
+ while (emailCursor.moveToNext()) {
+ String emailAddress = emailCursor.getString(emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
+ String emailType = emailCursor.getString(emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
+ String emailTypeLabel = (String) ContactsContract.CommonDataKinds.Email.getTypeLabel(
+ mActivity.getResources(),
+ Integer.parseInt(emailType),
+ UNDEFINED_LABEL);
+
+ serializer.startTag(null, "EMAIL");
+ serializer.startTag(null, "EMAIL_ADDRESS");
+ serializer.text(emailAddress);
+ serializer.endTag(null, "EMAIL_ADDRESS");
+ serializer.startTag(null, "EMAIL_TYPE");
+ serializer.text(emailTypeLabel);
+ serializer.endTag(null, "EMAIL_TYPE");
+ serializer.endTag(null, "EMAIL");
+ }
+ emailCursor.close();
+ serializer.endTag(null, "EMAILS");
+ }
+
+ //TODO - addresses, organizations, notes, websites, nickname, etc
+ serializer.endTag(null, "CONTACT");
+
+ // finished one contact, update progress bar
+ total++;
+ publishProgress(total);
+
+ // for testing
+ /*if(total.equals(300)) {
+ break;
+ }*/
+ }
+
+ serializer.endTag(null, "ANDROID_CONTACTS");
+ Log.d(LOG_TAG, "XMLSerializer.endDocument()");
+ serializer.endDocument();
+ Log.d(LOG_TAG, "writing xml to string...");
+ xmlString = stringWriter.toString();
+ Log.d(LOG_TAG, "xml written to string.");
+ writeContactsXMLFile(xmlString);
+
+ } catch (FileNotFoundException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ } finally {
+ contactsCursor.close();
+ try {
+ //fileOutputStream.close();
+ stringWriter.close();
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ }
}
- serializer.endTag(null, "CONTACTS");
- serializer.endDocument();
- serializer.flush();
- fileOutputStream.close();
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- contactsCursor.close();
- }
-
- /**
- * Obtains the contact list for the currently selected account.
- *
- * @return A cursor for for accessing the contact list.
- */
- private Cursor getContacts()
- {
- Uri uri = ContactsContract.Contacts.CONTENT_URI;
+ return xmlString;
+ }
+
+ /**
+ * Obtains the contact list for the currently selected account.
+ *
+ * @return A cursor for for accessing the contact list.
+ */
+ private Cursor getContacts() {
+ Uri uri = ContactsContract.Contacts.CONTENT_URI;
+ String[] projection = new String[] {
+ ContactsContract.Contacts._ID,
+ ContactsContract.Contacts.DISPLAY_NAME,
+ ContactsContract.Contacts.HAS_PHONE_NUMBER,
+ ContactsContract.Contacts.LAST_TIME_CONTACTED,
+ ContactsContract.Contacts.LOOKUP_KEY,
+ ContactsContract.Contacts.PHOTO_ID,
+ ContactsContract.Contacts.SEND_TO_VOICEMAIL,
+ ContactsContract.Contacts.STARRED,
+ ContactsContract.Contacts.TIMES_CONTACTED,
+ ContactsContract.Contacts.CUSTOM_RINGTONE
+ };
+ String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'";
+
+ return managedQuery(uri, projection, selection, null, null);
+ }
+
+
+
+ /** Test function to read in Contacts XML file and print to screen
+ *
+ */
+ private void printContactsXML() {
+ System.out.println("printing contacts XML...");
+ try {
+ FileInputStream fileInputStream = openFileInput("contacts.xml");
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
+ BufferedReader bReader = new BufferedReader(inputStreamReader);
+
+ String line = new String();
+ String xml = new String();
+ while((line = bReader.readLine()) != null) {
+ xml = xml + "\n" + line;
+ }
+ mResultView.setText(xml);
+
+ } catch (FileNotFoundException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ }
+ }
+
+ // Write XML to file
+ public void writeContactsXMLFile(String xml){
+ Log.d(LOG_TAG, "starting writeContactsXMLFile");
+ FileOutputStream fileOutputStream = null;
+ OutputStreamWriter outputStreamWriter = null;
+
+ try {
+ fileOutputStream = openFileOutput("contacts.xml", MODE_PRIVATE);
+ outputStreamWriter = new OutputStreamWriter(fileOutputStream);
+ Log.d(LOG_TAG, "writing xml...");
+ outputStreamWriter.write(xml);
+ Log.d(LOG_TAG, "flushing...");
+ outputStreamWriter.flush();
+ Log.d(LOG_TAG, "flush complete...");
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if(outputStreamWriter != null) {
+ outputStreamWriter.close();
+ }
+ if(fileOutputStream != null) {
+ fileOutputStream.close();
+ }
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ private int getContactsCount() {
+ //for testing
+ //return 300;
+
+ Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts._ID,
- ContactsContract.Contacts.DISPLAY_NAME,
- ContactsContract.Contacts.HAS_PHONE_NUMBER,
- ContactsContract.Contacts.LAST_TIME_CONTACTED,
- ContactsContract.Contacts.LOOKUP_KEY,
- ContactsContract.Contacts.PHOTO_ID,
- ContactsContract.Contacts.SEND_TO_VOICEMAIL,
- ContactsContract.Contacts.STARRED,
- ContactsContract.Contacts.TIMES_CONTACTED,
- ContactsContract.Contacts.CUSTOM_RINGTONE
};
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'";
- return managedQuery(uri, projection, selection, null, null);
+ Cursor c = managedQuery(uri, projection, selection, null, null);
+ int count = c.getCount();
+ c.close();
+ return count;
}
-
- // Test function to read in Contacts XML file and print to screen
- private void printContactsXML() {
- System.out.println("printing contacts XML...");
- try {
- FileInputStream fileInputStream = openFileInput("contacts.xml");
- InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
- BufferedReader bReader = new BufferedReader(inputStreamReader);
-
- String line = new String();
- String xml = new String();
- while((line = bReader.readLine()) != null) {
- xml = xml + "\n" + line;
- }
- mResultView.setText(xml);
-
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-}
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-17 10:24:22
|
Revision: 4351
http://mxquery.svn.sourceforge.net/mxquery/?rev=4351&view=rev
Author: pm_fischer
Date: 2011-05-17 10:24:14 +0000 (Tue, 17 May 2011)
Log Message:
-----------
Refactor Function Gallery to have same code on all platforms
Introduced FGPopulator to handle FG platform-specific loading
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/cmdline/MXQuery.java
trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionGallery.java
Added Paths:
-----------
trunk/MXQuery/src/ch/ethz/mxquery/functions/FGPopulator.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
Removed Paths:
-------------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/cmdline/MXQuery.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/cmdline/MXQuery.java 2011-05-17 10:21:05 UTC (rev 4350)
+++ trunk/MXQuery/src/ch/ethz/mxquery/cmdline/MXQuery.java 2011-05-17 10:24:14 UTC (rev 4351)
@@ -54,7 +54,6 @@
import ch.ethz.mxquery.contextConfig.CompilerOptions;
import ch.ethz.mxquery.contextConfig.Context;
import ch.ethz.mxquery.datamodel.QName;
-import ch.ethz.mxquery.datamodel.XQName;
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.exceptions.QueryLocation;
@@ -71,7 +70,6 @@
import ch.ethz.mxquery.xdmio.XDMInputFactory;
import ch.ethz.mxquery.xdmio.XDMSerializer;
import ch.ethz.mxquery.xdmio.XDMSerializerSettings;
-import ch.ethz.mxquery.xdmio.XMLSource;
public class MXQuery {
@@ -360,8 +358,7 @@
protected static void setUpExtension(String funcFile)
throws FileNotFoundException {
try {
- File file = new File(funcFile);
- Hashtable builtInExtensions = FunctionGallery.getModules(new InputStreamReader(new FileInputStream(file)));
+ Hashtable builtInExtensions = FunctionGallery.getModulesFile(funcFile);
Enumeration mods = builtInExtensions.keys();
while (mods.hasMoreElements()) {
String ns = (String) mods.nextElement();
Modified: trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java 2011-05-17 10:21:05 UTC (rev 4350)
+++ trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java 2011-05-17 10:24:14 UTC (rev 4351)
@@ -1554,7 +1554,7 @@
globalContext.setParserType(NONVALIDATED_INPUT_MODE_SAX);
globalContext.setScoringImplementation(new MXQSimpleScoring());
for (int i=0;i<extensions.length;i++) {
- Hashtable builtInExtensions = FunctionGallery.getModules(extensions[i]);
+ Hashtable builtInExtensions = FunctionGallery.getModulesRes(extensions[i]);
Enumeration mods = builtInExtensions.keys();
while (mods.hasMoreElements()) {
String ns = (String) mods.nextElement();
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/FGPopulator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/FGPopulator.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/FGPopulator.java 2011-05-17 10:24:14 UTC (rev 4351)
@@ -0,0 +1,151 @@
+package ch.ethz.mxquery.functions;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.kxml2.io.KXmlParser;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.contextConfig.XQStaticContext;
+import ch.ethz.mxquery.datamodel.Namespace;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.util.IOLib;
+
+class FGPopulator {
+
+ private static Reader getRessource(FunctionGallery fg, String name, String type) throws IOException, MXQueryException {
+ if (type.equals("fg"))
+ return new InputStreamReader(fg.getClass().getResourceAsStream(name));
+ if (type.equals("ctx"))
+ return new InputStreamReader(Context.getGlobalContext().getClass().getResourceAsStream(name));
+ if (type.equals("file")) {
+ return IOLib.getInput(name, false, null, QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+ return null;
+ }
+ public static void populateFunctionGallery(XQStaticContext ctx,
+ FunctionGallery fg, String id, String type) throws MXQueryException {
+ Reader is = null;
+ try {
+ is = getRessource(fg, id,type);
+
+ populateFunctionGallery(ctx, fg, is);
+ is.close();
+ } catch (IOException e) {
+ throw new MXQueryException(ErrorCodes.A0007_EC_IO, e, "Function Gallery could not be loaded, IO Error",null);
+ } finally {
+ if (is!=null)
+ try {
+ is.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void populateFunctionGallery(XQStaticContext ctx,
+ FunctionGallery fg, Reader is) throws MXQueryException {
+ KXmlParser xpp = new KXmlParser();
+ try {
+ xpp.setInput(is);
+
+ xpp.nextTag();
+ xpp.require(XmlPullParser.START_TAG, null, "functionGallery");
+ String baseLoc = xpp.getAttributeValue("","basePackage");
+ if (baseLoc==null)
+ throw new MXQueryException(ErrorCodes.A0007_EC_IO,"Invalid Function Gallery, basePackage missing",QueryLocation.OUTSIDE_QUERY_LOC);
+ xpp.nextTag();
+ while (!xpp.getName().equals("functionGallery") && xpp.getEventType() != XmlPullParser.END_TAG) {
+
+ xpp.require(XmlPullParser.START_TAG, null, "functionGroup");
+ //Function prefix, name, and class
+ String[] funcDesc = new String[3];
+ funcDesc[0] = xpp.getAttributeValue("", "namespace");
+ String prefix = xpp.getAttributeValue("", "prefix");
+ String loc = xpp.getAttributeValue("", "loc");
+ if (loc==null)
+ loc=prefix;
+ String[] parameters = new String[10];
+ int currArity = 0;
+
+ Namespace ns = ctx.getNamespace(prefix);
+ if (ns == null)
+ ctx.addNamespace(prefix, funcDesc[0]);
+ else if (!ns.getURI().equals(funcDesc[0]))
+ throw new MXQueryException(ErrorCodes.E0033_STATIC_MODULE_MULTIPLE_BINDINGS_FOR_SAME_PREFIX, "Inconsisten namespace for function/module import: "+prefix, QueryLocation.OUTSIDE_QUERY_LOC);
+ xpp.nextTag();
+ while (!xpp.getName().equals("functionGroup") && xpp.getEventType() != XmlPullParser.END_TAG) {
+ xpp.require(XmlPullParser.START_TAG, null, "functionDescription");
+ xpp.nextTag();
+ String operation = null;
+ TypeInfo type = null;
+ while (!xpp.getName().equals("functionDescription") && xpp.getEventType() != XmlPullParser.END_TAG) {
+ String elementName = xpp.getName();
+ if (elementName.equals("functionName")) {
+ funcDesc[1] = xpp.nextText();
+ } else if (elementName.equals("parameters")) {
+ xpp.nextTag();
+ int i = 0;
+ while (!xpp.getName().equals("parameters") && xpp.getEventType() != XmlPullParser.END_TAG){
+ xpp.require(XmlPullParser.START_TAG, null, "paramType");
+ elementName = xpp.getName();
+ if (elementName.equals("paramType")){
+ parameters[i++] = xpp.nextText();
+ }
+ xpp.nextTag();
+ }
+ currArity = i;
+ } else if (elementName.equals("className")) {
+ operation = xpp.getAttributeValue("", "op");
+ String rawType = xpp.getAttributeValue("", "type");
+ funcDesc[2] = xpp.nextText();
+ if (rawType != null) {
+ type = new TypeInfo(FunctionGallery.getType(rawType,ctx),FunctionGallery.getOccur(rawType));
+ }
+ } else {
+ // element ignored
+ System.out.println("element ignored!");
+ }
+
+ xpp.nextTag();
+ }
+
+ for (int i = 0; i < funcDesc.length; i++) {
+ if (funcDesc[i] == null) {
+ throw new IllegalArgumentException("The function description is not complete:" + funcDesc[0]
+ + ":" + funcDesc[1] + ":" + funcDesc[2]);
+ }
+ }
+
+ QName qn = new QName(funcDesc[0],prefix, funcDesc[1]);
+
+ TypeInfo [] paramTypes = new TypeInfo[currArity];
+ //TODO: What about the prefix and URI?
+ for (int i=0;i<paramTypes.length;i++)
+ paramTypes[i] = new TypeInfo(FunctionGallery.getType(parameters[i],ctx),FunctionGallery.getOccur(parameters[i]));
+
+ FunctionSignature signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+ Function function = new Function(baseLoc+loc+"."+funcDesc[2],signature, null, operation, type );
+ fg.add(function);
+
+ xpp.nextTag();
+ }
+ xpp.nextTag();
+ }
+ } catch (XmlPullParserException e) {
+ throw new MXQueryException(ErrorCodes.A0007_EC_IO, e, "Function Gallery could not be loaded, Parse Error",null);
+ } catch (IOException e) {
+ throw new MXQueryException(ErrorCodes.A0007_EC_IO, e, "Function Gallery could not be loaded, Parse Error",null);
+ }
+
+}
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionGallery.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-17 10:21:05 UTC (rev 4350)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-17 10:24:14 UTC (rev 4351)
@@ -16,22 +16,15 @@
package ch.ethz.mxquery.functions;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
import java.util.Enumeration;
import ch.ethz.mxquery.util.Hashtable;
import java.util.Vector;
-import org.kxml2.io.KXmlParser;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
+//import org.xmlpull.v1.XmlPullParserException;
-import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.contextConfig.Context;
import ch.ethz.mxquery.contextConfig.XQStaticContext;
-import ch.ethz.mxquery.datamodel.Namespace;
import ch.ethz.mxquery.datamodel.QName;
import ch.ethz.mxquery.datamodel.XQName;
import ch.ethz.mxquery.datamodel.types.Type;
@@ -155,35 +148,28 @@
public static FunctionGallery createFunctionGallery(XQStaticContext ctx, String resName) throws MXQueryException {
FunctionGallery fg = new FunctionGallery(ctx);
- try {
- Reader is = new InputStreamReader(fg.getClass().getResourceAsStream(resName));
- populateFunctionGallery(ctx, fg, is);
- is.close();
+ FGPopulator.populateFunctionGallery(ctx, fg, resName,"fg");
return fg;
- } catch (IOException e) {
- throw new MXQueryException(ErrorCodes.A0007_EC_IO, e, "Function Gallery could not be loaded, IO Error",null);
- } catch (XmlPullParserException e) {
- throw new MXQueryException(ErrorCodes.A0007_EC_IO, e, "Function Gallery could not be loaded, Parse Error",null);
- }
}
- public static Hashtable getModules(String id) throws MXQueryException {
- InputStreamReader is = new InputStreamReader(Context.getGlobalContext().getClass().getResourceAsStream(id));
- return getModules(is);
+ public static Hashtable getModulesRes(String id) throws MXQueryException {
+ Context temp = new Context();
+ FunctionGallery fg = new FunctionGallery(temp);
+ FGPopulator.populateFunctionGallery(temp, fg, id,"ctx");
+ return setUpModules(fg);
}
- public static Hashtable getModules(InputStreamReader is)
+ public static Hashtable getModulesFile(String fn)
throws MXQueryException {
Context temp = new Context();
FunctionGallery fg = new FunctionGallery(temp);
- try {
- populateFunctionGallery(temp, fg, is);
- } catch (XmlPullParserException e) {
- throw new MXQueryException(ErrorCodes.A0007_EC_IO, e, "Function Gallery could not be loaded, Parse Error",null);
- } catch (IOException e) {
- throw new MXQueryException(ErrorCodes.A0007_EC_IO, e, "Function Gallery could not be loaded, Parse Error",null);
- }
+ FGPopulator.populateFunctionGallery(temp, fg, fn,"file");
+ return setUpModules(fg);
+ }
+
+ static Hashtable setUpModules(FunctionGallery fg)
+ throws MXQueryException {
Hashtable mods = new Hashtable();
Enumeration elements = fg.functions.elements();
while(elements.hasMoreElements()) {
@@ -203,97 +189,7 @@
return mods;
}
- public static void populateFunctionGallery(XQStaticContext ctx,
- FunctionGallery fg, Reader is) throws XmlPullParserException,
- IOException, MXQueryException {
- KXmlParser xpp = new KXmlParser();
- xpp.setInput(is);
-
- xpp.nextTag();
- xpp.require(XmlPullParser.START_TAG, null, "functionGallery");
- String baseLoc = xpp.getAttributeValue("","basePackage");
- if (baseLoc==null)
- throw new MXQueryException(ErrorCodes.A0007_EC_IO,"Invalid Function Gallery, basePackage missing",QueryLocation.OUTSIDE_QUERY_LOC);
- xpp.nextTag();
- while (!xpp.getName().equals("functionGallery") && xpp.getEventType() != XmlPullParser.END_TAG) {
-
- xpp.require(XmlPullParser.START_TAG, null, "functionGroup");
- //Function prefix, name, and class
- String[] funcDesc = new String[3];
- funcDesc[0] = xpp.getAttributeValue("", "namespace");
- String prefix = xpp.getAttributeValue("", "prefix");
- String loc = xpp.getAttributeValue("", "loc");
- if (loc==null)
- loc=prefix;
- String[] parameters = new String[10];
- int currArity = 0;
-
- Namespace ns = ctx.getNamespace(prefix);
- if (ns == null)
- ctx.addNamespace(prefix, funcDesc[0]);
- else if (!ns.getURI().equals(funcDesc[0]))
- throw new MXQueryException(ErrorCodes.E0033_STATIC_MODULE_MULTIPLE_BINDINGS_FOR_SAME_PREFIX, "Inconsisten namespace for function/module import: "+prefix, QueryLocation.OUTSIDE_QUERY_LOC);
- xpp.nextTag();
- while (!xpp.getName().equals("functionGroup") && xpp.getEventType() != XmlPullParser.END_TAG) {
- xpp.require(XmlPullParser.START_TAG, null, "functionDescription");
- xpp.nextTag();
- String operation = null;
- TypeInfo type = null;
- while (!xpp.getName().equals("functionDescription") && xpp.getEventType() != XmlPullParser.END_TAG) {
- String elementName = xpp.getName();
- if (elementName.equals("functionName")) {
- funcDesc[1] = xpp.nextText();
- } else if (elementName.equals("parameters")) {
- xpp.nextTag();
- int i = 0;
- while (!xpp.getName().equals("parameters") && xpp.getEventType() != XmlPullParser.END_TAG){
- xpp.require(XmlPullParser.START_TAG, null, "paramType");
- elementName = xpp.getName();
- if (elementName.equals("paramType")){
- parameters[i++] = xpp.nextText();
- }
- xpp.nextTag();
- }
- currArity = i;
- } else if (elementName.equals("className")) {
- operation = xpp.getAttributeValue("", "op");
- String rawType = xpp.getAttributeValue("", "type");
- funcDesc[2] = xpp.nextText();
- if (rawType != null) {
- type = new TypeInfo(getType(rawType,ctx),getOccur(rawType));
- }
- } else {
- // element ignored
- System.out.println("element ignored!");
- }
-
- xpp.nextTag();
- }
-
- for (int i = 0; i < funcDesc.length; i++) {
- if (funcDesc[i] == null) {
- throw new IllegalArgumentException("The function description is not complete:" + funcDesc[0]
- + ":" + funcDesc[1] + ":" + funcDesc[2]);
- }
- }
-
- QName qn = new QName(funcDesc[0],prefix, funcDesc[1]);
-
- TypeInfo [] paramTypes = new TypeInfo[currArity];
- //TODO: What about the prefix and URI?
- for (int i=0;i<paramTypes.length;i++)
- paramTypes[i] = new TypeInfo(getType(parameters[i],ctx),getOccur(parameters[i]));
-
- FunctionSignature signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
- Function function = new Function(baseLoc+loc+"."+funcDesc[2],signature, null, operation, type );
- fg.add(function);
-
- xpp.nextTag();
- }
- xpp.nextTag();
- }
- }
- private static int getType(String rawType, XQStaticContext ctx) throws MXQueryException{
+ static int getType(String rawType, XQStaticContext ctx) throws MXQueryException{
//Removing the occurrence indicators
if (rawType.indexOf('*') > -1){
rawType = rawType.substring(0,rawType.indexOf("*")).trim();
@@ -329,7 +225,7 @@
}
- private static int getOccur(String rawType){
+ static int getOccur(String rawType){
if (rawType.indexOf("*") > -1){
return Type.getOccurID('*');
}else if (rawType.indexOf("+")>-1){
Copied: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java (from rev 4350, trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java)
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-05-17 10:24:14 UTC (rev 4351)
@@ -0,0 +1,6097 @@
+package ch.ethz.mxquery.functions;
+
+import java.io.IOException;
+import java.io.Reader;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.contextConfig.XQStaticContext;
+import ch.ethz.mxquery.datamodel.Namespace;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.model.XDMIterator;
+
+class FGPopulator {
+ public static void populateFunctionGallery(XQStaticContext ctx,
+ FunctionGallery fg, String id, String resType) throws MXQueryException {
+
+ if (resType.equals("ctx")) {
+ populateExPath(ctx, fg);
+ return;
+ }
+
+
+
+ Context context = (Context)ctx;
+ QName qn;
+ TypeInfo [] paramTypes;
+ FunctionSignature signature;
+ Function function;
+ TypeInfo type;
+ String classname;
+
+ ctx.addNamespace(XQStaticContext.NS_BROWSER,
+ XQStaticContext.URI_BROWSER);
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "js-eval");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.JsEval iter = new ch.ethz.mxquery.functions.b.JsEval();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "timer");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:integer",ctx),FunctionGallery.getOccur("xs:integer"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "QName",ctx),FunctionGallery.getOccur("QName"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.Timer iter = new ch.ethz.mxquery.functions.b.Timer();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getCookieNames");
+ paramTypes = new TypeInfo[0];
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.GetCookieNames iter = new ch.ethz.mxquery.functions.b.GetCookieNames();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getCookie");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.GetCookie iter = new ch.ethz.mxquery.functions.b.GetCookie();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeCookie");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.RemoveCookie iter = new ch.ethz.mxquery.functions.b.RemoveCookie();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "setCookie");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "setCookie");
+ paramTypes = new TypeInfo[3];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "xs:dateTime",ctx),FunctionGallery.getOccur("xs:dateTime"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "pageURI");
+ paramTypes = new TypeInfo[0];
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.LocUri iter = new ch.ethz.mxquery.functions.b.LocUri();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getLocation");
+ paramTypes = new TypeInfo[0];
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.GetLocation iter = new ch.ethz.mxquery.functions.b.GetLocation();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "log");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.Log iter = new ch.ethz.mxquery.functions.b.Log();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "alert");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.Alert iter = new ch.ethz.mxquery.functions.b.Alert();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeClass");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.RemoveClassName iter = new ch.ethz.mxquery.functions.b.RemoveClassName();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getClasses");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.GetClasses iter = new ch.ethz.mxquery.functions.b.GetClasses();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "addClass");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.AddClassName iter = new ch.ethz.mxquery.functions.b.AddClassName();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "addEventListener");
+ paramTypes = new TypeInfo[4];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "QName",ctx),FunctionGallery.getOccur("QName"),null);
+
+ paramTypes[3] = new TypeInfo(FunctionGallery.getType(
+ "xs:integer",ctx),FunctionGallery.getOccur("xs:integer"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "addEventListener");
+ paramTypes = new TypeInfo[3];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "QName",ctx),FunctionGallery.getOccur("QName"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeEventListener");
+ paramTypes = new TypeInfo[4];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "QName",ctx),FunctionGallery.getOccur("QName"),null);
+
+ paramTypes[3] = new TypeInfo(FunctionGallery.getType(
+ "xs:integer",ctx),FunctionGallery.getOccur("xs:integer"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeEventListener");
+ paramTypes = new TypeInfo[3];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()",ctx),FunctionGallery.getOccur("node()"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "QName",ctx),FunctionGallery.getOccur("QName"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "dom");
+ paramTypes = new TypeInfo[0];
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.Dom iter = new ch.ethz.mxquery.functions.b.Dom();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "windowInfo");
+ paramTypes = new TypeInfo[0];
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.WindowInfo iter = new ch.ethz.mxquery.functions.b.WindowInfo();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getStyle");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()",ctx),FunctionGallery.getOccur("node()"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.GetStyle iter = new ch.ethz.mxquery.functions.b.GetStyle();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "setStyle");
+ paramTypes = new TypeInfo[3];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()",ctx),FunctionGallery.getOccur("node()"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.SetStyle iter = new ch.ethz.mxquery.functions.b.SetStyle();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "QName");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.FNQName iter = new ch.ethz.mxquery.functions.fn.FNQName();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "abs");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "numeric?",ctx),FunctionGallery.getOccur("numeric?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.Abs iter = new ch.ethz.mxquery.functions.fn.Abs();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "adjust-date-to-timezone");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:date?",ctx),FunctionGallery.getOccur("xs:date?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
+ iter.setContext(context, false);
+
+ type = new TypeInfo(FunctionGallery.getType("xs:date",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+
+ iter.setReturnType(type.getType());
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "adjust-date-to-timezone");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:date?",ctx),FunctionGallery.getOccur("xs:date?"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:dayTimeDuration?",ctx),FunctionGallery.getOccur("xs:dayTimeDuration?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
+ iter.setContext(context, false);
+
+ type = new TypeInfo(FunctionGallery.getType("xs:date",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+
+ iter.setReturnType(type.getType());
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "adjust-dateTime-to-timezone");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:dateTime?",ctx),FunctionGallery.getOccur("xs:dateTime?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
+ iter.setContext(context, false);
+
+ type = new TypeInfo(FunctionGallery.getType("xs:dateTime",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+
+ iter.setReturnType(type.getType());
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "adjust-dateTime-to-timezone");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:dateTime?",ctx),FunctionGallery.getOccur("xs:dateTime?"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:dayTimeDuration?",ctx),FunctionGallery.getOccur("xs:dayTimeDuration?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
+ iter.setContext(context, false);
+
+ type = new TypeInfo(FunctionGallery.getType("xs:dateTime",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+
+ iter.setReturnType(type.getType());
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "adjust-time-to-timezone");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:time?",ctx),FunctionGallery.getOccur("xs:time?"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:dayTimeDuration?",ctx),FunctionGallery.getOccur("xs:dayTimeDuration?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
+ iter.setContext(context, false);
+
+ type = new TypeInfo(FunctionGallery.getType("xs:time",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+
+ iter.setReturnType(type.getType());
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "adjust-time-to-timezone");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:time?",ctx),FunctionGallery.getOccur("xs:time?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
+ iter.setContext(context, false);
+
+ type = new TypeInfo(FunctionGallery.getType("xs:time",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+
+ iter.setReturnType(type.getType());
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "avg");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:anyAtomicType*",ctx),FunctionGallery.getOccur("xs:anyAtomicType*"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.Avg iter = new ch.ethz.mxquery.functions.fn.Avg();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "base-uri");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()",ctx),FunctionGallery.getOccur("node()"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.BaseUri iter = new ch.ethz.mxquery.functions.fn.BaseUri();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "base-uri");
+ paramTypes = new TypeInfo[0];
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.BaseUri iter = new ch.ethz.mxquery.functions.fn.BaseUri();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "boolean");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "item()*",ctx),FunctionGallery.getOccur("item()*"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.BooleanIterator iter = new ch.ethz.mxquery.functions.fn.BooleanIterator();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "ceiling");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "numeric?",ctx),FunctionGallery.getOccur("numeric?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.Ceiling iter = new ch.ethz.mxquery.functions.fn.Ceiling();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "codepoint-equal");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.CodePointEqual iter = new ch.ethz.mxquery.functions.fn.CodePointEqual();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "codepoints-to-string");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:integer*",ctx),FunctionGallery.getOccur("xs:integer*"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.CodepointsToString iter = new ch.ethz.mxquery.functions.fn.CodepointsToString();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "collection");
+ paramTypes = new TypeInfo[0];
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.Collection iter = new ch.ethz.mxquery.functions.fn.Collection();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "collection");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.Collection iter = new ch.ethz.mxquery.functions.fn.Collection();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "compare");
+ paramTypes = new TypeInfo[3];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.Compare iter = new ch.ethz.mxquery.functions.fn.Compare();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "compare");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.fn.Compare iter = new ch.ethz.mxquery.functions.fn.Compare();
+ ...
[truncated message content] |
|
From: <pm_...@us...> - 2011-05-17 10:21:14
|
Revision: 4350
http://mxquery.svn.sourceforge.net/mxquery/?rev=4350&view=rev
Author: pm_fischer
Date: 2011-05-17 10:21:05 +0000 (Tue, 17 May 2011)
Log Message:
-----------
refactoring/simplification of string parameter handling
Modified Paths:
--------------
trunk/MXQuery/altsrc/ch/ethz/mxquery/functions/math/TransMath.java
trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Replace.java
trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/StringToCodepoints.java
trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/String_Length.java
trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/SubString.java
trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Tokenize.java
trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Translate.java
trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/crypto/SignString.java
trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocAvailable.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EncodeForURI.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EscapeHTMLURI.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNQName.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/IRItoURI.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/LowerCase.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Matches.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Namespace_uri_for_prefix.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/NormalizeSpace.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/NormalizeUnicode.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Parse.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Replace.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/ResolveQName.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StringJoin.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StringToCodepoints.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/String_Length.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Tokenize.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Trace.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/UpperCase.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/ComputedPIConstrIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/model/Iterator.java
trunk/MXQuery/src/ch/ethz/mxquery/util/Utils.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/IRItoURI.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Matches.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Replace.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Tokenize.java
Modified: trunk/MXQuery/altsrc/ch/ethz/mxquery/functions/math/TransMath.java
===================================================================
--- trunk/MXQuery/altsrc/ch/ethz/mxquery/functions/math/TransMath.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/altsrc/ch/ethz/mxquery/functions/math/TransMath.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -146,7 +146,7 @@
break;
case TRANSMATH_ATAN2:
MXQueryDouble y = null;
- XDMIterator input2 = subIters[0];
+ XDMIterator input2 = subIters[1];
TokenInterface inputToken2 = input2.next();
int type2 = Type.getEventTypeSubstituted(inputToken2.getEventType(), Context.getDictionary());
@@ -155,16 +155,16 @@
currentToken = Token.END_SEQUENCE_TOKEN;
return;
case Type.INTEGER:
- y = new MXQueryDouble(inputToken.getLong());
+ y = new MXQueryDouble(inputToken2.getLong());
break;
case Type.UNTYPED_ATOMIC:
case Type.UNTYPED:
- y = new MXQueryDouble(inputToken.getText());
+ y = new MXQueryDouble(inputToken2.getText());
break;
case Type.DOUBLE:
case Type.FLOAT:
case Type.DECIMAL:
- y = inputToken.getDouble();
+ y = inputToken2.getDouble();
break;
default:
throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+Type.getTypeQName(type, Context.getDictionary()), loc);
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Replace.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Replace.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Replace.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -31,25 +31,13 @@
public class Replace extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator input = DataValuesIterator.getDataIterator(subIters[0],context);
- TokenInterface tok = input.next();
-
- int type = tok.getEventType();
-
- if (type == Type.END_SEQUENCE) {
- currentToken = new TextToken(null,"");
+ String res = getStringValueOrEmpty(subIters[0]);
+ if (res == null){
+ currentToken = new TextToken(null, "");
return;
- }
- if (type != Type.STRING)
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+type,loc);
- String res = tok.getText();
- TokenInterface tok1 = subIters[1].next();
-
- String pattern = tok1.getText();
-
- TokenInterface tok2 = subIters[2].next();
-
- String replacement = tok2.getText();
+ }
+ String pattern = getStringValue(subIters[1]);
+ String replacement = getStringValue(subIters[2]);
//currentToken.setText(res.replaceAll(pattern, replacement));
//FIXME: Dummy implementation
currentToken = new TextToken(null,res);
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/StringToCodepoints.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/StringToCodepoints.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/StringToCodepoints.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -36,23 +36,11 @@
String toTranslate = null;
protected void init() throws MXQueryException {
- XDMIterator input = DataValuesIterator.getDataIterator(subIters[0],context);
- TokenInterface inputToken =input.next();
- int type = Type.getEventTypeSubstituted( inputToken.getEventType(),null );
-
- switch (type) {
- case(Type.END_SEQUENCE):
- currentToken = new TextToken(null, "");
- break;
- case(Type.STRING):
- case(Type.UNTYPED_ATOMIC):
- case Type.UNTYPED:
- String res = inputToken.getText();
- toTranslate = res;
- break;
- default:
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+Type.getTypeQName(type,null),loc);
- }
+ toTranslate = getStringValueOrEmpty(subIters[0]);
+ if (toTranslate==null||toTranslate.equals("")) {
+ currentToken = new TextToken(null, "");
+ return;
+ }
}
public TokenInterface next() throws MXQueryException {
if (called == 0)
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/String_Length.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/String_Length.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/String_Length.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -20,6 +20,7 @@
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.functions.fn.FNString;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.datamodel.types.Type;
@@ -36,40 +37,22 @@
public class String_Length extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator input;
- if (subIters != null && subIters.length == 1) {
- input = DataValuesIterator.getDataIterator(subIters[0], context);
- } else {
- VariableHolder contextVarHolder = context.getContextItem();
- if (contextVarHolder != null) {
- input = contextVarHolder.getIter();
- if (input == null) {
- throw new DynamicException(ErrorCodes.E0002_DYNAMIC_NO_VALUE_ASSIGNED, "Context Item Iterator not set", loc);
- } else {
- input = DataValuesIterator.getDataIterator(input, context);
- }
- } else {
- throw new RuntimeException("Context Item not set");
- }
- }
+ XDMIterator input;
+ if (subIters.length > 0 )
+ input = subIters[0];
+ else {
+ input = new FNString();
+ input.setContext(context, false);
+ }
+ String content = getStringValueOrEmpty(input);
+
+ if (content == null){
+ currentToken = new LongToken(Type.INTEGER, null,0);
+ } else {
+ int charCount = content.length();
+ currentToken = new LongToken(Type.INTEGER, null, charCount );
+ }
- TokenInterface inputToken = input.next();
- int type = inputToken.getEventType();
- if (type == Type.START_DOCUMENT) {
- inputToken = input.next();
- type = inputToken.getEventType();
- }
-
- if ( Type.isAttribute(type) )
- type = Type.getAttributeValueType(type);
-
- if ( Type.isAtomicType(type, null) ){
- String content = inputToken.getValueAsString();
- int charCount = content.length();
- currentToken = new LongToken(Type.INTEGER, null, charCount );
- } else if (type == Type.END_SEQUENCE){
- currentToken = new LongToken(Type.INTEGER, null,0);
- }
}
public TypeInfo getStaticType() {
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/SubString.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/SubString.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/SubString.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -29,16 +29,12 @@
public class SubString extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator input = DataValuesIterator.getDataIterator(subIters[0], context);
- TokenInterface inputToken = input.next();
- int type = inputToken.getEventType();
+ String res = getStringValueOrEmpty(subIters[0]);
- if (type == Type.END_SEQUENCE) {
+ if (res == null) {
currentToken = new TextToken(null, "");
return;
}
-
- String res = inputToken.getText();
TokenInterface inputToken1 = subIters[1].next();
int type1 = Type.getEventTypeSubstituted(inputToken1.getEventType(), Context.getDictionary());
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Tokenize.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Tokenize.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Tokenize.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -41,34 +41,19 @@
}
private void init() throws MXQueryException {
- XDMIterator input = DataValuesIterator.getDataIterator(subIters[0],context);
- TokenInterface tok1 = input.next();
- int type = tok1.getEventType();
- String res = tok1.getText();
- XDMIterator input2 = DataValuesIterator.getDataIterator(subIters[1],context);
- TokenInterface tok2 = input2.next();
- int type2 = tok2.getEventType();
- String delimiter = tok2.getText();
- if (type2 != Type.STRING || delimiter.length() == 0)
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+Type.getTypeQName(type,null),loc);
- switch (type) {
- case(Type.END_SEQUENCE):
+ String res = getStringValueOrEmpty(subIters[0]);
+ String delimiter = getStringValue(subIters[1]);
+ if (delimiter.length() == 0)
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Separator must not be empty", loc);
+
+ if (res==null || res.length() == 0)
current = new TokenIterator(context, "", loc);
- break;
-
- case(Type.STRING):
- if (res.length() == 0)
- current = new TokenIterator(context, "",loc);
- else {
- String [] splitted = Utils.split(res,delimiter,true);
- TokenIterator [] toks = new TokenIterator[splitted.length];
- for (int i =0;i<toks.length;i++)
- toks[i] = new TokenIterator(context, splitted[i],loc);
- current = new SequenceIterator(null, toks,loc);
- }
- break;
- default:
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+type,loc);
+ else {
+ String [] splitted = Utils.split(res,delimiter,true);
+ TokenIterator [] toks = new TokenIterator[splitted.length];
+ for (int i =0;i<toks.length;i++)
+ toks[i] = new TokenIterator(context, splitted[i],loc);
+ current = new SequenceIterator(null, toks,loc);
}
}
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Translate.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Translate.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/fn/Translate.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -34,25 +34,16 @@
private Vector remove = new Vector();
protected void init() throws MXQueryException {
- TokenInterface arg = subIters[0].next();
- TokenInterface mapString = subIters[1].next();
- TokenInterface transString = subIters[2].next();
+ String sArg = getStringValueOrEmpty(subIters[0]);
- if (arg.getEventType() == Type.END_SEQUENCE) {
+ if (sArg == null || sArg.equals("")) {
currentToken = new TextToken(null, "");
return;
}
+
+ String sMap = getStringValue(subIters[1]);
+ String sTrans = getStringValue(subIters[2]);
- if (arg.getEventType() != Type.STRING ||
- mapString.getEventType() != Type.STRING ||
- transString.getEventType() != Type.STRING) {
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type for fn:translate!", loc);
- }
-
- String sArg = arg.getText();
- String sMap = mapString.getText();
- String sTrans = transString.getText();
-
int transPos = 0;
for (int i=0; i<sMap.length(); i++) {
int sMapChar = sMap.charAt(i);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/crypto/SignString.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/crypto/SignString.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/crypto/SignString.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -14,8 +14,6 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.BinaryToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
@@ -26,19 +24,12 @@
public class SignString extends TokenBasedIterator {
protected void init() throws MXQueryException {
- TokenInterface method = subIters[0].next();
- if (method == Token.END_SEQUENCE_TOKEN || !(method.getEventType() == Type.UNTYPED_ATOMIC || Type.isTypeOrSubTypeOf(method.getEventType(), Type.STRING, Context.getDictionary())))
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Single Element of Type String Expected",loc);
- String macMethod = method.getText();
- TokenInterface key = subIters[1].next();
- if (key == Token.END_SEQUENCE_TOKEN || !(key.getEventType() == Type.UNTYPED_ATOMIC || Type.isTypeOrSubTypeOf(key.getEventType(), Type.STRING, Context.getDictionary())))
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Single Element of Type String Expected",loc);
- String keyChars = key.getText();
- TokenInterface content = subIters[2].next();
- if (content == Token.END_SEQUENCE_TOKEN || !(content.getEventType() == Type.UNTYPED_ATOMIC || Type.isTypeOrSubTypeOf(content.getEventType(), Type.STRING, Context.getDictionary())))
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Single Element of Type String Expected",loc);
- String contentChars = content.getText();
+ String macMethod = getStringValue(subIters[0]);
+ String keyChars = getStringValue(subIters[1]);
+
+ String contentChars = getStringValue(subIters[2]);
+
Mac mac;
try {
mac = Mac.getInstance(macMethod);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -241,27 +241,7 @@
if (username!=null && (password==null||authmethod==null))
throw new DynamicException(EHC005_DYNAMIC_INVALID_REQUEST_ELEM, "If username is given, password and method also need to be provided", loc);
if (subIters.length > 1) {
- String urlParam = null;
- TokenInterface urlToken = subIters[1].next();
-
- switch (urlToken.getEventType()) {
- case Type.UNTYPED_ATOMIC:
- urlParam = urlToken.getText();
- break;
- case Type.END_SEQUENCE:
- break;
- default:
- if (Type.isTypeOrSubTypeOf(urlToken.getEventType(), Type.STRING,
- Context.getDictionary()))
- urlParam = urlToken.getText();
- else
- throw new DynamicException(
- ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
- "Expected String type for URL", loc);
- break;
- }
- if (urlParam != null)
- url = urlParam;
+ url = getStringValueOrEmpty(subIters[1]);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -148,25 +148,7 @@
private void init() throws MXQueryException {
TokenInterface urlToken = subIters[0].next();
- String url;
- switch (urlToken.getEventType()) {
- case Type.END_SEQUENCE:
- throw new DynamicException(
- ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
- "Emtpy sequence not allowed for URL", loc);
- case Type.UNTYPED_ATOMIC:
- url = urlToken.getText();
- break;
- default:
- if (Type.isTypeOrSubTypeOf(urlToken.getEventType(), Type.STRING,
- Context.getDictionary()))
- url = urlToken.getText();
- else
- throw new DynamicException(
- ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
- "Expected String type for URL", loc);
- break;
- }
+ String url = getStringValue(subIters[0]);
if (request_type != REQUEST_TYPE_GET && url.indexOf('?') >= 0) {
throw new DynamicException(
ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocAvailable.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocAvailable.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocAvailable.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -29,89 +29,76 @@
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.types.TypeLexicalConstraints;
import ch.ethz.mxquery.datamodel.xdm.BooleanToken;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
public class DocAvailable extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator parameter = subIters[0];
- if (parameter == null) {
- // this should never happen!!!
- throw new IllegalArgumentException("No parameter for fn:doc-available() function given!");
+ String add = getStringValueOrEmpty(subIters[0]);
+
+ if (add == null) {
+ currentToken = BooleanToken.FALSE_TOKEN;
+ return;
}
- TokenInterface tok = parameter.next();
- int type = Type.getEventTypeSubstituted(tok.getEventType(), Context.getDictionary());
+ URI uri;
- if (type == Type.END_SEQUENCE) {
+ if (!TypeLexicalConstraints.isValidURI(add))
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
+ try {
+ if (TypeLexicalConstraints.isAbsoluteURI(add)) {
+ uri = new URI(add);
+ } else {
+ String base = context.getBaseURI();
+ String add1 = add;
+ if (add1.startsWith("/"))
+ add1 = add1.substring(1);
+ uri = new URI(base + add1);
+ }
+ } catch (URISyntaxException se) {
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
+ }
+ if(add.startsWith("http://")){
+
+ URL url;
+ try {
+ url = uri.toURL();
+ } catch (MalformedURLException e) {
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
+ }
+ try {
+ InputStream in = url.openStream();
+ in.close();
+ } catch (IOException e) {
currentToken = BooleanToken.FALSE_TOKEN;
return;
+ }
+ currentToken = BooleanToken.TRUE_TOKEN;
+ // }
+ // catch(Exception e){
+ // throw new DynamicException(ErrorCodes.A0006_EC_URI_NOT_FOUND, "Remote Data cannot be accessed: " + e);
+ // }
}
- if (Type.typePromoteableTo(type, Type.STRING,Context.getDictionary()) || type == Type.UNTYPED_ATOMIC) {
- String add=tok.getText();
- URI uri;
-
- if (!TypeLexicalConstraints.isValidURI(add))
- throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
+ else {
+ File xml;
+ try {
+ xml = new File(uri);
+ }catch(IllegalArgumentException ia) {
try {
- if (TypeLexicalConstraints.isAbsoluteURI(add)) {
- uri = new URI(add);
- } else {
- String base = context.getBaseURI();
- String add1 = add;
- if (add1.startsWith("/"))
- add1 = add1.substring(1);
- uri = new URI(base + add1);
- }
- } catch (URISyntaxException se) {
- throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
- }
- if(add.startsWith("http://")){
-
- URL url;
- try {
- url = uri.toURL();
- } catch (MalformedURLException e) {
- throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
- }
- try {
- InputStream in = url.openStream();
- in.close();
- } catch (IOException e) {
- currentToken = BooleanToken.FALSE_TOKEN;
- return;
- }
- currentToken = BooleanToken.TRUE_TOKEN;
-// }
-// catch(Exception e){
-// throw new DynamicException(ErrorCodes.A0006_EC_URI_NOT_FOUND, "Remote Data cannot be accessed: " + e);
-// }
+ xml = new File(add);
+ } catch (IllegalArgumentException ia2) {
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
}
- else {
- File xml;
- try {
- xml = new File(uri);
- }catch(IllegalArgumentException ia) {
- try {
- xml = new File(add);
- } catch (IllegalArgumentException ia2) {
- throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
- }
- }
- if (xml.exists()) {
- currentToken = BooleanToken.TRUE_TOKEN;
- } else {
- currentToken = BooleanToken.FALSE_TOKEN;
- }
- }
- }
- else
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Invalid argument given to fn:doc-available", loc);
+ }
+ if (xml.exists()) {
+ currentToken = BooleanToken.TRUE_TOKEN;
+ } else {
+ currentToken = BooleanToken.FALSE_TOKEN;
+ }
+ }
}
public TypeInfo getStaticType() {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EncodeForURI.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EncodeForURI.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EncodeForURI.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -21,10 +21,7 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.TextToken;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.BitSet;
@@ -44,19 +41,13 @@
}
protected void init() throws MXQueryException {
- XDMIterator input = subIters[0];
- TokenInterface uri = input.next();
+ String uri = getStringValueOrEmpty(subIters[0]);
- if (uri.getEventType() == Type.END_SEQUENCE) {
+ if (uri == null || uri.equals("")) {
currentToken = new TextToken(null, "");
return;
- }
-
- if (!(Type.isTypeOrSubTypeOf(uri.getEventType(), Type.STRING,Context.getDictionary()) || uri.getEventType()==Type.UNTYPED_ATOMIC)) {
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type for fn:encode-for-uri!", loc);
- }
-
- currentToken = new TextToken(null, encode(uri.getText()));
+ }
+ currentToken = new TextToken(null, encode(uri));
}
public TypeInfo getStaticType() {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EscapeHTMLURI.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EscapeHTMLURI.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EscapeHTMLURI.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -21,10 +21,7 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.TextToken;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.Utils;
@@ -34,19 +31,13 @@
private int eRange = 126;
protected void init() throws MXQueryException {
- XDMIterator input = subIters[0];
- TokenInterface uri = input.next();
+ String uri = getStringValueOrEmpty(subIters[0]);
- if (uri.getEventType() == Type.END_SEQUENCE) {
+ if (uri == null || uri.equals("")) {
currentToken = new TextToken(null, "");
return;
- }
-
- if (!(Type.isTypeOrSubTypeOf(uri.getEventType(), Type.STRING,Context.getDictionary()) || uri.getEventType()==Type.UNTYPED_ATOMIC)) {
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type for fn:encode-for-uri!", loc);
- }
-
- currentToken = new TextToken(null, encode(uri.getText()));
+ }
+ currentToken = new TextToken(null, encode(uri));
}
private String encode(String input) {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNQName.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNQName.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNQName.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -22,73 +22,31 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.QNameToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
public class FNQName extends TokenBasedIterator {
protected void init() throws MXQueryException {
- if (subIters[0] == null) {
- throw new IllegalArgumentException();
- }
- XDMIterator paramQNameIt;
- TokenInterface nsToken = subIters[0].next();
- paramQNameIt = subIters[1];
- String nsString = null;
- if (!(nsToken.getText() == null || nsToken.getText().equals("")))
- nsString = nsToken.getText();
- if (!(Type.getEventTypeSubstituted(nsToken.getEventType(), Context
- .getDictionary()) == Type.STRING
- || nsToken.getEventType() == Type.UNTYPED_ATOMIC
- || nsToken.getEventType() == Type.UNTYPED || nsToken
- .getEventType() == Type.END_SEQUENCE))
- throw new DynamicException(
- ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
- "Wrong data type for fn:QName", loc);
- TokenInterface paramToken = paramQNameIt.next();
- int type = Type.getEventTypeSubstituted(paramToken.getEventType(),
- Context.getDictionary());
+ String nsString = getStringValueOrEmpty(subIters[0]);
- switch (type) {
- case Type.END_SEQUENCE:
- throw new DynamicException(
- ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
- "QName expected", loc);
- case Type.STRING:
- case Type.UNTYPED_ATOMIC:
- case Type.UNTYPED:
- String qNameText = paramToken.getText();
+ String qNameText = getStringValue(subIters[1]);
+
if (qNameText.equals(""))
throw new DynamicException(
ErrorCodes.F0005_INVALID_LEXICAL_VALUE,
"Empty QName not possible", loc);
QName qToGen = new QName(qNameText);
if (qToGen.getNamespacePrefix() != null
- && (nsToken.getEventType() == Type.END_SEQUENCE || nsToken
- .getText().equals("")))
+ && (nsString == null || nsString.equals("")))
throw new DynamicException(
ErrorCodes.F0005_INVALID_LEXICAL_VALUE,
"Prefix not allow with empty namespace", loc);
qToGen.setNamespaceURI(nsString);
currentToken = new QNameToken(null, qToGen);
- break;
- default:
- throw new DynamicException(
- ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
- "Wrong data type for fn:QName", loc);
- }
-
- if (paramQNameIt.next() != Token.END_SEQUENCE_TOKEN)
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
- "Could not cast sequence to atomic type "
- + Type.getTypeQName(Type.QNAME, Context
- .getDictionary()), loc);
}
public TypeInfo getStaticType() {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/IRItoURI.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/IRItoURI.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/IRItoURI.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -22,11 +22,7 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.TextToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.Utils;
@@ -50,22 +46,14 @@
}
protected void init() throws MXQueryException {
- XDMIterator input = subIters[0];
- TokenInterface iri = input.next();
+ String iri = getStringValueOrEmpty(subIters[0]);
- if (iri.getEventType() == Type.END_SEQUENCE) {
+ if (iri == null || iri.equals("")) {
currentToken = new TextToken(null, "");
return;
}
-
- if (input.next() != Token.END_SEQUENCE_TOKEN)
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Expected single value, encountered multiple",loc);
-
- if (!(iri.getEventType()==Type.UNTYPED_ATOMIC || Type.typePromoteableTo(iri.getEventType(), Type.STRING, Context.getDictionary()))) {
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type for fn:encode-for-uri!", loc);
- }
-
- currentToken = new TextToken(null, encode(iri.getText()));
+
+ currentToken = new TextToken(null, encode(iri));
}
private String encode(String input) {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/LowerCase.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/LowerCase.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/LowerCase.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -20,33 +20,19 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.TextToken;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
public class LowerCase extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator input = subIters[0];
- TokenInterface inputToken =input.next();
- int type = Type.getEventTypeSubstituted( inputToken.getEventType(), Context.getDictionary() );
-
- switch (type) {
- case(Type.END_SEQUENCE):
- currentToken = new TextToken(null, "");
- break;
- case(Type.STRING):
- case(Type.UNTYPED_ATOMIC):
- case Type.UNTYPED:
- String res = inputToken.getText();
+ String res = getStringValueOrEmpty(subIters[0]);
+ if (res==null)
+ currentToken = new TextToken(null, "");
+ else
currentToken = new TextToken(null, res.toLowerCase());
- break;
- default:
- throw new TypeException(ErrorCodes.F0028_INVALID_ARGUMENT_TYPE, "Invalid argument type"+Type.getTypeQName(type, Context.getDictionary()), loc);
- }
+
}
public TypeInfo getStaticType() {
return new TypeInfo(Type.STRING,Type.OCCURRENCE_IND_EXACTLY_ONE);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Matches.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Matches.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Matches.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -24,42 +24,26 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.BooleanToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.exceptions.QueryLocation;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
public class Matches extends TokenBasedIterator {
protected void init() throws MXQueryException {
- if (subIters == null || subIters.length == 1 || subIters.length > 3) {
- throw new IllegalArgumentException();
- }
+ String text = getStringValueOrEmpty(subIters[0]);
+ if (text == null)
+ text = "";
- TokenInterface input = subIters[0].next();
- int ev = Type.getEventTypeSubstituted(input.getEventType(),Context.getDictionary());
- if (!(ev == Type.STRING || input == Token.END_SEQUENCE_TOKEN))
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Expected String, got "+Type.getTypeQName(ev, Context.getDictionary()),loc);
-
- String text;
- if (input == Token.END_SEQUENCE_TOKEN)
- text = "";
- else
- text = input.getText();
-
-
- TokenInterface pattern = subIters[1].next();
-
int f = computeFlags(subIters, 3, loc);
- String pat = pattern.getText();
+ String pat = getStringValue(subIters[1]);
- if (pat == null || pat.equals("")) {
+ if (pat.equals("")) {
throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Pattern must be a String value!", loc);
}
@@ -71,8 +55,10 @@
Pattern p = null;
try {
- String translated = Translator.translate(pat);
- p = Pattern.compile(translated, f);
+ String toMatch = pat;
+ if ((f & Pattern.LITERAL) == 0)
+ toMatch = Translator.translate(pat);
+ p = Pattern.compile(toMatch, f);
} catch (Exception e) {
throw new DynamicException(ErrorCodes.F0032_INVALID_REGULAR_EXPRESSION, "Invalid regular expression!", loc);
}
@@ -114,6 +100,7 @@
static int computeFlags(XDMIterator [] subIters, int pos, QueryLocation loc) throws MXQueryException {
int f = 0;
if (subIters.length == pos) {
+
TokenInterface flags = subIters[pos-1].next();
String theFlags = flags.getText();
@@ -122,7 +109,7 @@
}
if (!theFlags.equals("")) { // if flags are empty, skip
- if (!theFlags.matches("[smix]+")) {
+ if (!theFlags.matches("[smixq]+")) {
throw new DynamicException(ErrorCodes.F0031_INVALID_REGULAR_EXPRESSION_FLAGS, "Invalid regular expression flags!", loc);
}
@@ -137,7 +124,11 @@
}
if (theFlags.indexOf("x") >= 0) {
f += Pattern.COMMENTS;
+ }
+ if (theFlags.indexOf("q") >= 0) {
+ f += Pattern.LITERAL;
}
+
}
}
return f;
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Namespace_uri_for_prefix.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Namespace_uri_for_prefix.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Namespace_uri_for_prefix.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -32,19 +32,9 @@
public class Namespace_uri_for_prefix extends TokenBasedIterator {
protected void init() throws MXQueryException {
- if (subIters == null || subIters.length != 2) {
- throw new IllegalArgumentException();
- }
-
- XDMIterator prefixIter = subIters[0];
-
- TokenInterface t1 = prefixIter.next();
- String prefixToTest;
- if (t1.getEventType() == Type.END_SEQUENCE)
+ String prefixToTest = getStringValueOrEmpty(subIters[0]);
+ if (prefixToTest == null)
prefixToTest = "";
- else
- prefixToTest = t1.getText();
-
TokenInterface t2 = subIters[1].next();
if (t2.getEventType() == Type.START_TAG) {
XDMScope scope = t2.getDynamicScope();
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/NormalizeSpace.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/NormalizeSpace.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/NormalizeSpace.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -20,10 +20,7 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.TextToken;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.Utils;
@@ -31,28 +28,11 @@
public class NormalizeSpace extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator input = DataValuesIterator.getDataIterator(getNodeIteratorOrContext(subIters, 1,context, loc), context);
-
- TokenInterface tok = input.next();
-
- int type = Type.getEventTypeSubstituted( tok.getEventType(), Context.getDictionary() );
- String res = tok.getText();
-
- switch (type) {
- case(Type.END_SEQUENCE):
- currentToken = new TextToken(null, "");
- break;
- case Type.STRING:
- case Type.UNTYPED_ATOMIC:
- case Type.UNTYPED: {
- currentToken = new TextToken(null, Utils.normalizeString(res));
- }
- break;
- default:
- throw new TypeException(ErrorCodes.F0028_INVALID_ARGUMENT_TYPE, "Invalid argument type"+Type.getTypeQName(type, Context.getDictionary()), loc);
- }
- if (input.next().getEventType() != Type.END_SEQUENCE)
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "No sequences allow as input to normalize-space()", loc);
+ String res = getStringValueOrEmpty(DataValuesIterator.getDataIterator(getNodeIteratorOrContext(subIters, 1,context, loc), context));
+ if (res == null)
+ currentToken = new TextToken(null, "");
+ else
+ currentToken = new TextToken(null, Utils.normalizeString(res));
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/NormalizeUnicode.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/NormalizeUnicode.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/NormalizeUnicode.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -20,11 +20,8 @@
import ch.ethz.mxquery.contextConfig.Context;
import ch.ethz.mxquery.datamodel.types.Type;
-import ch.ethz.mxquery.datamodel.types.TypeDictionary;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.TextToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
@@ -34,56 +31,32 @@
public class NormalizeUnicode extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator input = subIters[0];
- TokenInterface tok = input.next();
- TypeDictionary tdic = Context.getDictionary();
- int type = tok.getEventType();
- if (!(Type.isTypeOrSubTypeOf(type, Type.STRING,tdic)||tok == Token.END_SEQUENCE_TOKEN)) {
- throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "String expected for normalize-unicode, got "+Type.getTypeQName(type, tdic),loc);
- }
+
+ String toNormalize = getStringValueOrEmpty(subIters[0]);
- if (input.next() != Token.END_SEQUENCE_TOKEN) {
- throw new DynamicException(ErrorCodes.E0001_STATIC_NO_VALUE_ASSIGNED, "More than a single value given to normalize-unicode",loc);
- }
-
- String toNormalize;
-
- if (tok == Token.END_SEQUENCE_TOKEN)
+ if (toNormalize == null)
toNormalize = "";
- else
- toNormalize = tok.getText();
try {
Normalizer.Form normalForm = Normalizer.Form.NFC;
-
if (subIters.length == 2) {
- XDMIterator inputNF = subIters[1];
- TokenInterface tokNF = inputNF.next();
- int type1 = tokNF.getEventType();
- if (!(Type.isTypeOrSubTypeOf(type1, Type.STRING,tdic))) {
- throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "String expected for normalize-unicode, got "+Type.getTypeQName(type, tdic),loc);
- }
-
- if (inputNF.next() != Token.END_SEQUENCE_TOKEN) {
- throw new DynamicException(ErrorCodes.E0001_STATIC_NO_VALUE_ASSIGNED, "More than a single value given to normalize-unicode",loc);
- }
-
- if (tokNF.getText().equals("")) {
+ String nf = getStringValue(subIters[1]).trim();
+ if (nf.equals("")) {
currentToken = new TextToken(null,toNormalize);
return;
}
- if (tokNF.getText().trim().equalsIgnoreCase("NFC"))
+ if (nf.equalsIgnoreCase("NFC"))
normalForm = Normalizer.Form.NFC;
- else if (tokNF.getText().trim().equalsIgnoreCase("NFD"))
+ else if (nf.equalsIgnoreCase("NFD"))
normalForm = Normalizer.Form.NFD;
- else if (tokNF.getText().trim().equalsIgnoreCase("NFKC"))
+ else if (nf.equalsIgnoreCase("NFKC"))
normalForm = Normalizer.Form.NFKC;
- else if (tokNF.getText().trim().equalsIgnoreCase("NFKD"))
+ else if (nf.equalsIgnoreCase("NFKD"))
normalForm = Normalizer.Form.NFKD;
else
- throw new DynamicException(ErrorCodes.F0011_UNSUPPORTED_NORMALIZATION_FORM, "Normalizaton form "+tokNF.getText()+" not supported",loc);
+ throw new DynamicException(ErrorCodes.F0011_UNSUPPORTED_NORMALIZATION_FORM, "Normalizaton form "+nf+" not supported",loc);
}
String normalized = Normalizer.normalize(toNormalize, normalForm);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Parse.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Parse.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Parse.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -23,7 +23,6 @@
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.functions.RequestTypeMulti;
import ch.ethz.mxquery.model.CurrentBasedIterator;
import ch.ethz.mxquery.model.EmptySequenceIterator;
@@ -54,23 +53,16 @@
public void init() throws MXQueryException {
- XDMIterator parameter = subIters[0];
- TokenInterface tok = parameter.next();
- int type = Type.getEventTypeSubstituted(tok.getEventType(), Context.getDictionary());
- if (type == Type.END_SEQUENCE) {
- current = new EmptySequenceIterator(context,loc);
- return;
- }
- if (type == Type.STRING || type == Type.UNTYPED_ATOMIC || type == Type.UNTYPED) {
- String add=tok.getText();
- if (!useTidy)
- current = XDMInputFactory.createXMLInput(context, new StringReader(add),false,context.getInputValidationMode(),loc);
- else
- current = XDMInputFactory.createTidyInput(context, new StringReader(add), loc);
- } else {
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Type "+Type.getTypeQName(type, Context.getDictionary())+" not correct at parse-string-to-XML", loc);
- }
+ String add = getStringValueOrEmpty(subIters[0]);
+ if (add == null || add.equals("")) {
+ current = new EmptySequenceIterator(context,loc);
return;
+ }
+ if (!useTidy)
+ current = XDMInputFactory.createXMLInput(context, new StringReader(add),false,context.getInputValidationMode(),loc);
+ else
+ current = XDMInputFactory.createTidyInput(context, new StringReader(add), loc);
+ return;
}
public TypeInfo getStaticType() {
return new TypeInfo(Type.START_TAG,Type.OCCURRENCE_IND_ZERO_OR_ONE);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Replace.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Replace.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Replace.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -24,43 +24,24 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.TextToken;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.ObjectObjectPair;
public class Replace extends TokenBasedIterator {
- protected void init() throws MXQueryException {
- XDMIterator input = subIters[0];
- TokenInterface inputToken1 = input.next();
- int type = Type.getEventTypeSubstituted( inputToken1.getEventType(), Context.getDictionary() );
-
- if (type == Type.END_SEQUENCE) {
+ protected void init() throws MXQueryException {
+ String res = getStringValueOrEmpty(subIters[0]);
+ if (res == null){
currentToken = new TextToken(null, "");
return;
- }
+ }
+ String pattern = getStringValue(subIters[1]);
+ String replacement = getStringValue(subIters[2]);
- if (!(type == Type.STRING||type == Type.UNTYPED_ATOMIC||type == Type.UNTYPED))
- throw new TypeException(ErrorCodes.F0028_INVALID_ARGUMENT_TYPE, "Invalid argument type"+type, loc);
-
- String res = inputToken1.getText();
-
- TokenInterface inputToken2 = subIters[1].next();
- if (inputToken2.getEventType() == Type.END_SEQUENCE)
- throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid pattern", loc);
-
- String pattern = inputToken2.getText();
-
- TokenInterface inputToken3 = subIters[2].next();
- if (inputToken3.getEventType() == Type.END_SEQUENCE)
- throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid replacement (empty squence)!", loc);
- String replacement = inputToken3.getText();
-
int f = Matches.computeFlags(subIters, 4, loc);
Pattern p = null;
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/ResolveQName.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/ResolveQName.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/ResolveQName.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -35,51 +35,30 @@
public class ResolveQName extends TokenBasedIterator {
protected void init() throws MXQueryException {
- if (subIters[0] == null) {
- throw new IllegalArgumentException();
- }
+ String val = getStringValueOrEmpty(subIters[0]);
+ if (val == null)
+ currentToken = Token.END_SEQUENCE_TOKEN;
+ else if (val.equals(""))
+ throw new TypeException(ErrorCodes.F0023_INVALID_VALUE_FOR_CAST_CONSTRUCTOR, "Invalid lexical value: " + val, loc);
+ else {
+ TokenInterface contextNode = subIters[1].next();
- XDMIterator iter = subIters[0];
- TokenInterface inputToken = iter.next();
-
- int type = Type.getEventTypeSubstituted( inputToken.getEventType(), Context.getDictionary() );
-
- switch (type) {
- case Type.END_SEQUENCE:
- currentToken = Token.END_SEQUENCE_TOKEN;
- break;
- case Type.STRING:
- case Type.UNTYPED_ATOMIC:
- String val = inputToken.getText().trim();
- if (val.equals(""))
- throw new TypeException(ErrorCodes.F0023_INVALID_VALUE_FOR_CAST_CONSTRUCTOR, "Invalid lexical value: " + val, loc);
-
- TokenInterface contextNode = subIters[1].next();
-
- QName res = new QName(val);
-
- currentToken = new QNameToken(null, res);
-
- if (contextNode.getEventType() == Type.START_TAG) {
- XDMScope ns = contextNode.getDynamicScope();
- String nm = ns.getNsURI(res.getNamespacePrefix());
- if (nm != null) {
- res.setNamespaceURI(nm);
- } else if (res.getNamespacePrefix() != null) {
- throw new DynamicException(ErrorCodes.F0021_NO_NAMESPACE_FOUND,"No namespace found for the given prefix and context node",loc);
- }
-
- } else
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Need element node for fn-resolve-qname()",loc);
+ QName res = new QName(val);
-
- break;
- default:
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Could not cast type " + Type.getTypeQName(type, Context.getDictionary()) + " to type " + Type.getTypeQName(Type.QNAME, Context.getDictionary()), loc);
- }
-
- if ( iter.next() != Token.END_SEQUENCE_TOKEN )
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Could not cast sequence to atomic type " + Type.getTypeQName(Type.QNAME, Context.getDictionary()), loc);
+ currentToken = new QNameToken(null, res);
+
+ if (contextNode.getEventType() == Type.START_TAG) {
+ XDMScope ns = contextNode.getDynamicScope();
+ String nm = ns.getNsURI(res.getNamespacePrefix());
+ if (nm != null) {
+ res.setNamespaceURI(nm);
+ } else if (res.getNamespacePrefix() != null) {
+ throw new DynamicException(ErrorCodes.F0021_NO_NAMESPACE_FOUND,"No namespace found for the given prefix and context node",loc);
+ }
+
+ } else
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Need element node for fn-resolve-qname()",loc);
+ }
}
public TypeInfo getStaticType() {
return new TypeInfo(Type.QNAME,Type.OCCURRENCE_IND_ZERO_OR_ONE);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StringJoin.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StringJoin.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StringJoin.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -36,14 +36,7 @@
if (subIters.length > 1) {
- TokenInterface inputToken2 = subIters[1].next();
- int type2 = inputToken2.getEventType();
-
-
- if (type2 != Type.END_SEQUENCE)
- sep = inputToken2.getText();
- else
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Empty Sequence not allowed as separator in string-join", loc);
+ sep = getStringValue(subIters[1]);
}
StringBuffer res = new StringBuffer();
@@ -51,6 +44,12 @@
TokenInterface tok = it.next();
+ int aType = tok.getEventType();
+
+ if ( !(Type.typePromoteableTo(aType, Type.STRING,Context.getDictionary()) ||aType == Type.UNTYPED_ATOMIC || aType == Type.END_SEQUENCE)) {
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Item of type "+"xs:string"+" expected", loc);
+ }
+
String curString = tok.getValueAsString();
if (curString == null) {
curString = "";
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StringToCodepoints.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StringToCodepoints.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StringToCodepoints.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -24,9 +24,7 @@
import ch.ethz.mxquery.datamodel.xdm.TextToken;
import ch.ethz.mxquery.datamodel.xdm.Token;
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
@@ -34,23 +32,11 @@
String toTranslate = null;
protected void init() throws MXQueryException {
- XDMIterator input = subIters[0];
- TokenInterface inputToken =input.next();
- int type = Type.getEventTypeSubstituted( inputToken.getEventType(), Context.getDictionary() );
-
- switch (type) {
- case(Type.END_SEQUENCE):
- currentToken = new TextToken(null, "");
- break;
- case(Type.STRING):
- case(Type.UNTYPED_ATOMIC):
- case Type.UNTYPED:
- String res = inputToken.getText();
- toTranslate = res;
- break;
- default:
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+Type.getTypeQName(type, Context.getDictionary()), loc);
- }
+ toTranslate = getStringValueOrEmpty(subIters[0]);
+ if (toTranslate==null||toTranslate.equals("")) {
+ currentToken = new TextToken(null, "");
+ return;
+ }
}
public TokenInterface next() throws MXQueryException {
if (called == 0)
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/String_Length.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/String_Length.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/String_Length.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -21,10 +21,6 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.LongToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.DynamicException;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
@@ -43,23 +39,17 @@
input = new FNString();
input.setContext(context, false);
}
-
- TokenInterface inputToken = input.next();
- int type = inputToken.getEventType();
+ String content = getStringValueOrEmpty(input);
- if (type == Type.END_SEQUENCE){
+ if (content == null){
currentToken = new LongToken(Type.INTEGER, null,0);
- } else if ( (Type.isTypeOrSubTypeOf(type, Type.STRING, Context.getDictionary()) || type == Type.UNTYPED_ATOMIC )&&
- input.next() == Token.END_SEQUENCE_TOKEN){
- String content = inputToken.getValueAsString();
+ } else {
int charCount = content.length();
//TODO: performance improvement: annotate string token if they contain only non BMP-codepoints
//=> counting CP is unnecessary then
int characterCount = content.codePointCount(0, charCount);
currentToken = new LongToken(Type.INTEGER, null, characterCount );
- } else {
- throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Single Value of type xs:string expected",loc);
- }
+ }
}
public TypeInfo getStaticType() {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Tokenize.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Tokenize.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Tokenize.java 2011-05-17 10:21:05 UTC (rev 4350)
@@ -45,16 +45,10 @@
}
private void init() throws MXQueryException {
- XDMIterator input = subIters[0];
- TokenInterface tok1 = input.next();
- int type = tok1.getEventType();
- String res = tok1.getText();
- XDMIterator input2 = subIters[1];
- TokenInterface tok2 = input2.next();
- int type2 = Type.getEventTypeSubstituted( tok2.getEventType(), Context.getDictionary());
- String delimiter = tok2.getText();
- if (type2 != Type.STRING || delimiter.length() == 0)
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+Type.getTypeQName(type, Context.getDictionary()), loc);
+ String res = getStringValueOrEmpty(subIters[0]);
+ String delimiter = getStringValue(subIters[1]);
+ if (delimiter.length() == 0)
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Separator must not be empty", loc);
int f = Matches.computeFlags(subIters, 3, loc);
@@ -73,26 +67,15 @@
if (m.find())
throw new DynamicException(ErrorCodes.F0033_REGULAR_EXPRESSION_MATCHES_EMPTY,"Pattern matches empty string",loc);
- switch (type) {
- case(Type.END_SEQUENCE):
- current = new EmptySequenceIterator(context,loc);
- break;
-
- case Type.STRING:
- case Type.UNTYPED_ATOMIC:
- if (res.length() == 0)
- current = new EmptySequenceIterator(context,loc);
- else {
- //String [] splitted = Utils.split(res,delimiter);
- String [] splitted = p.split(res,-1);
- TokenIterator [] toks = new TokenIterator[splitted.length];
- for (int i =0;i<toks.length;i++)
- toks[i] = new TokenIterator(context, splitted[i],loc);
- current = new SequenceIterator(context, toks,loc);
- }
- break;
- default:
- throw new TypeException(ErrorCodes.F0028_INVALID_ARGUMENT_TYPE, "Invalid argument type"+Type.getTypeQName(type, Context.getDictionary()), loc);
+ if (res == null || res.length() == 0)
+ current = new EmptySequenceIterator(context,loc);
+ else {
+ //String [] splitted = Utils.split(res,delimiter);
+ String [] splitted = p.split(res,-1);
+ TokenIterator [] toks = new TokenIterator[splitted.length];
+ for (int i =0;i<toks.length;i++)
+ toks[i] = new TokenIterator(context, splitted[i],loc);
+ current = new SequenceIterator(context, toks,loc);
}
}
public TypeInfo getStaticType() {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Trace.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Trace.java 2011-05-16 19:04:44 UTC (rev 4349)
+++ trunk/MXQuery/src/ch/ethz/mxquery/f...
[truncated message content] |
|
From: <max...@us...> - 2011-05-16 19:04:50
|
Revision: 4349
http://mxquery.svn.sourceforge.net/mxquery/?rev=4349&view=rev
Author: maxspeicher
Date: 2011-05-16 19:04:44 +0000 (Mon, 16 May 2011)
Log Message:
-----------
minor fix
Modified Paths:
--------------
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-16 18:50:34 UTC (rev 4348)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-16 19:04:44 UTC (rev 4349)
@@ -149,6 +149,8 @@
mInputView.setText(getString(R.string.native_java_xquery));
} else if (item.equals(getString(R.string.manipulate_ui))) {
mInputView.setText(getString(R.string.manipulate_ui_xquery));
+ } else if (item.equals(getString(R.string.fn_doc))) {
+ mInputView.setText(getString(R.string.fn_doc_xquery));
} else if (item.equals(getString(R.string.android_doc))) {
mInputView.setText(getString(R.string.android_doc_xquery));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-16 18:50:40
|
Revision: 4348
http://mxquery.svn.sourceforge.net/mxquery/?rev=4348&view=rev
Author: maxspeicher
Date: 2011-05-16 18:50:34 +0000 (Mon, 16 May 2011)
Log Message:
-----------
changed IOLib to use Android-specific IO -> leads to SAXNotSupportedException when using fn:doc()
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-16 18:49:27 UTC (rev 4347)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-16 18:50:34 UTC (rev 4348)
@@ -19,12 +19,12 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
-import ch.ethz.mxquery.util.PrintStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URI;
@@ -32,6 +32,8 @@
import java.net.URL;
import java.net.URLConnection;
+import android.content.Context;
+import ch.ethz.mxquery.android.MXQuery;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
@@ -201,45 +203,42 @@
throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "I/O Error - Remote Data cannot be accessed: " + e, loc);
}
} else {
- File xml = new File(uri);
- if (xml.exists()) {
- try {
- ins = new FileInputStream(xml);
- // snoop encoding
- //encoding = "utf-8";
- String tempEncoding = IOLib.snoopEncoding8bit(ins, xquery);
+ Context ctx = MXQuery.getContext();
+ try {
+ ins = ctx.openFileInput(toOpen);
+ // snoop encoding
+ //encoding = "utf-8";
+ String tempEncoding = IOLib.snoopEncoding8bit(ins, xquery);
+ if (tempEncoding != null) {
+ encoding = tempEncoding;
+ } else {
+ ins.close();
+ ins = ctx.openFileInput(toOpen);
+ tempEncoding = IOLib.snoopEncoding16bit(ins, xquery);
if (tempEncoding != null) {
encoding = tempEncoding;
- } else {
- ins.close();
- ins = new FileInputStream(xml);
- tempEncoding = IOLib.snoopEncoding16bit(ins, xquery);
- if (tempEncoding != null) {
- encoding = tempEncoding;
- }
}
+ }
+ ins.close();
+ ins = ctx.openFileInput(toOpen);
+ return new BufferedReader(new UnicodeReader(ins, encoding));
+ } catch (UnsupportedEncodingException ue) {
+ try {
ins.close();
- ins = new FileInputStream(xml);
- return new BufferedReader(new UnicodeReader(ins, encoding));
- } catch (UnsupportedEncodingException ue) {
- try {
- ins.close();
- } catch (IOException ie) {
- //
- }
- throw new DynamicException(ErrorCodes.A0007_EC_IO, "Unsupported encoding '" + encoding + "' in File '" + uri, loc);
- }catch (Exception e) {
- try {
- if (ins != null)
- ins.close();
- } catch (IOException ie) {
- //
- }
- throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "File '" + uri + "' could not be openend " + e.toString(), loc);
+ } catch (IOException ie) {
+ //
}
-
- } else {
- throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "File '" + uri + "' does not exist!", loc);
+ throw new DynamicException(ErrorCodes.A0007_EC_IO, "Unsupported encoding '" + encoding + "' in File '" + uri, loc);
+ } catch (FileNotFoundException fe) {
+ throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "File '" + toOpen + "' does not exist!", loc);
+ } catch (Exception e) {
+ try {
+ if (ins != null)
+ ins.close();
+ } catch (IOException ie) {
+ //
+ }
+ throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "File '" + uri + "' could not be openend " + e.toString(), loc);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-16 18:49:33
|
Revision: 4347
http://mxquery.svn.sourceforge.net/mxquery/?rev=4347&view=rev
Author: maxspeicher
Date: 2011-05-16 18:49:27 +0000 (Mon, 16 May 2011)
Log Message:
-----------
added test queries for fn:doc() and fn:parse-xml() -> both throw a SAXNotSupportedException
Modified Paths:
--------------
trunk/MXQuery_Android_App/res/values/strings.xml
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
Modified: trunk/MXQuery_Android_App/res/values/strings.xml
===================================================================
--- trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-16 16:19:00 UTC (rev 4346)
+++ trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-16 18:49:27 UTC (rev 4347)
@@ -29,6 +29,7 @@
<string name="fibonacci">Fibonacci</string>
<string name="native_java">Native Java</string>
<string name="manipulate_ui">Manipulate UI</string>
+ <string name="fn_doc">fn:doc()</string>
<string name="android_doc">android:doc()</string>
<string name="hello_world_xquery">\"Hello World\"</string>
@@ -67,9 +68,12 @@
let $x := m:getActivity()\n
return a:updateUiFromXquery($x, \"Hello XQuery!\")
</string>
+ <string name="fn_doc_xquery">
+ fn:doc(\"test.xml\")
+ </string>
<string name="android_doc_xquery">
declare namespace android = \"java:ch.ethz.mxquery.android.MXQuery\";\n
- android:doc(\"test.xml\")
+ fn:parse(android:doc(\"test.xml\"))
</string>
</resources>
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-16 16:19:00 UTC (rev 4346)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-16 18:49:27 UTC (rev 4347)
@@ -101,7 +101,6 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- /*
MXQuery.init(this);
// set up sample file for testing fn:doc()
@@ -115,7 +114,6 @@
} catch (Exception e) {
e.printStackTrace();
}
- */
setContentView(R.layout.main);
mButton = (Button) findViewById(R.id.button);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-16 16:19:06
|
Revision: 4346
http://mxquery.svn.sourceforge.net/mxquery/?rev=4346&view=rev
Author: maxspeicher
Date: 2011-05-16 16:19:00 +0000 (Mon, 16 May 2011)
Log Message:
-----------
- updated Android copy of IOLib
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-16 16:15:22 UTC (rev 4345)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-16 16:19:00 UTC (rev 4346)
@@ -19,12 +19,12 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import ch.ethz.mxquery.util.PrintStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URI;
@@ -32,8 +32,6 @@
import java.net.URL;
import java.net.URLConnection;
-import android.content.Context;
-import ch.ethz.mxquery.android.MXQuery;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
@@ -41,8 +39,6 @@
public class IOLib {
- private static Context ctx = MXQuery.getContext();
-
public static void copyFile(String source, String destination) throws MXQueryException{
FileInputStream in = null;
FileOutputStream out = null;
@@ -164,8 +160,9 @@
return encoding;
}
- public static Reader getInput (String toOpen, boolean xquery, QueryLocation loc) throws MXQueryException {
- String encoding = "utf-8";
+ public static Reader getInput (String toOpen, boolean xquery,String encoding, QueryLocation loc) throws MXQueryException {
+ if (encoding == null)
+ encoding = "utf-8";
InputStream ins = null;
URI uri;
try {
@@ -204,42 +201,45 @@
throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "I/O Error - Remote Data cannot be accessed: " + e, loc);
}
} else {
- try {
- ins = ctx.openFileInput(toOpen);
-
- // snoop encoding
- encoding = "utf-8";
- String tempEncoding = IOLib.snoopEncoding8bit(ins, xquery);
- if (tempEncoding != null) {
- encoding = tempEncoding;
- } else {
- ins.close();
- ins = ctx.openFileInput(toOpen);
- tempEncoding = IOLib.snoopEncoding16bit(ins, xquery);
- if (tempEncoding != null) {
- encoding = tempEncoding;
- }
- }
- ins.close();
- ins = ctx.openFileInput(toOpen);
- return new BufferedReader(new UnicodeReader(ins, encoding));
- } catch (FileNotFoundException e1) {
- throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "File '" + uri + "' does not exist!", loc);
- } catch (UnsupportedEncodingException e) {
- try {
- ins.close();
- } catch (IOException ie) {
- //
- }
- throw new DynamicException(ErrorCodes.A0007_EC_IO, "Unsupported encoding '" + encoding + "' in File '" + uri, loc);
- } catch (Exception e) {
- try {
- if (ins != null)
- ins.close();
- } catch (IOException ie) {
- //
- }
- throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "File '" + uri + "' could not be openend " + e.toString(), loc);
+ File xml = new File(uri);
+ if (xml.exists()) {
+ try {
+ ins = new FileInputStream(xml);
+ // snoop encoding
+ //encoding = "utf-8";
+ String tempEncoding = IOLib.snoopEncoding8bit(ins, xquery);
+ if (tempEncoding != null) {
+ encoding = tempEncoding;
+ } else {
+ ins.close();
+ ins = new FileInputStream(xml);
+ tempEncoding = IOLib.snoopEncoding16bit(ins, xquery);
+ if (tempEncoding != null) {
+ encoding = tempEncoding;
+ }
+ }
+ ins.close();
+ ins = new FileInputStream(xml);
+ return new BufferedReader(new UnicodeReader(ins, encoding));
+ } catch (UnsupportedEncodingException ue) {
+ try {
+ ins.close();
+ } catch (IOException ie) {
+ //
+ }
+ throw new DynamicException(ErrorCodes.A0007_EC_IO, "Unsupported encoding '" + encoding + "' in File '" + uri, loc);
+ }catch (Exception e) {
+ try {
+ if (ins != null)
+ ins.close();
+ } catch (IOException ie) {
+ //
+ }
+ throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "File '" + uri + "' could not be openend " + e.toString(), loc);
+ }
+
+ } else {
+ throw new DynamicException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, "File '" + uri + "' does not exist!", loc);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-16 16:15:28
|
Revision: 4345
http://mxquery.svn.sourceforge.net/mxquery/?rev=4345&view=rev
Author: maxspeicher
Date: 2011-05-16 16:15:22 +0000 (Mon, 16 May 2011)
Log Message:
-----------
- added Android SDK to classpath of target jar-android
Modified Paths:
--------------
trunk/MXQuery/build.xml
Modified: trunk/MXQuery/build.xml
===================================================================
--- trunk/MXQuery/build.xml 2011-05-16 14:29:52 UTC (rev 4344)
+++ trunk/MXQuery/build.xml 2011-05-16 16:15:22 UTC (rev 4345)
@@ -1165,6 +1165,7 @@
extdirs="">
<classpath>
<path refid="android.lib.path" />
+ <pathelement location="${sdk.dir}/platforms/android-8/android.jar" />
</classpath>
</javac>
</target>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-16 14:29:58
|
Revision: 4344
http://mxquery.svn.sourceforge.net/mxquery/?rev=4344&view=rev
Author: pm_fischer
Date: 2011-05-16 14:29:52 +0000 (Mon, 16 May 2011)
Log Message:
-----------
compilation fix on Java 1.4
Modified Paths:
--------------
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/XQ11FunctionsTest.java
Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/XQ11FunctionsTest.java
===================================================================
--- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/XQ11FunctionsTest.java 2011-05-16 14:28:49 UTC (rev 4343)
+++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/XQ11FunctionsTest.java 2011-05-16 14:29:52 UTC (rev 4344)
@@ -433,7 +433,7 @@
String query = "declare context item := doc('XQTests/Sources/doc.xml'); fn:document-uri()";
doQuery(prepareQuery(query, false,false, false, true, false));
//System.out.println(resultBuffer.toString());
- assertTrue(resultBuffer.toString().contains("doc.xml"));
+ assertTrue(resultBuffer.toString().indexOf("doc.xml")>-1);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-16 14:28:55
|
Revision: 4343
http://mxquery.svn.sourceforge.net/mxquery/?rev=4343&view=rev
Author: pm_fischer
Date: 2011-05-16 14:28:49 +0000 (Mon, 16 May 2011)
Log Message:
-----------
fold-left(), fold-right()
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml
trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
Added Paths:
-----------
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Fold.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml 2011-05-16 14:27:10 UTC (rev 4342)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml 2011-05-16 14:28:49 UTC (rev 4343)
@@ -420,14 +420,14 @@
<parameters><paramType>function(*)</paramType>
<paramType>item()*</paramType>
<paramType>item()*</paramType></parameters>
- <className op="left">fold</className>
+ <className op="left">Fold</className>
</functionDescription>
<functionDescription>
<functionName>fold-right</functionName>
<parameters><paramType>function(*)</paramType>
<paramType>item()*</paramType>
<paramType>item()*</paramType></parameters>
- <className op="right">fold</className>
+ <className op="right">Fold</className>
</functionDescription>
<functionDescription>
<functionName>function-name</functionName>
@@ -620,8 +620,7 @@
<paramType>item()*</paramType>
</parameters>
<className>MapPairs</className>
- </functionDescription>
-
+ </functionDescription>
<functionDescription>
<functionName>matches</functionName>
<parameters>
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Fold.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Fold.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Fold.java 2011-05-16 14:28:49 UTC (rev 4343)
@@ -0,0 +1,123 @@
+package ch.ethz.mxquery.functions.fn;
+
+import java.util.Vector;
+
+import ch.ethz.mxquery.bindings.WindowFactory;
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.functions.RequestTypeMulti;
+import ch.ethz.mxquery.iterators.SequenceTypeIterator;
+import ch.ethz.mxquery.iterators.UserdefFuncCallLateBinding;
+import ch.ethz.mxquery.iterators.VariableIterator;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.TokenSequenceIterator;
+import ch.ethz.mxquery.model.VariableHolder;
+import ch.ethz.mxquery.model.Window;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class Fold extends CurrentBasedIterator implements RequestTypeMulti{
+
+ private int direction;
+ private int DIRECTION_LEFT = 0;
+ private int DIRECTION_RIGHT = 1;
+
+ public TokenInterface next() throws MXQueryException {
+ if (called == 0) {
+ QName qnSeq = context.registerAnonymousVariable();
+ VariableHolder vh1 = context.getVariable(qnSeq);
+ QName qnZero = context.registerAnonymousVariable();
+ VariableHolder vh2 = context.getVariable(qnZero);
+
+ called++;
+ TypeInfo [] params = new TypeInfo[2];
+ params[0] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE);
+ params[1] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE);
+ TypeInfo tInfo = new TypeInfo(Type.FUNCTION_ITEM, Type.OCCURRENCE_IND_EXACTLY_ONE, params, new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE));
+ SequenceTypeIterator st = new SequenceTypeIterator(tInfo, true, true, context, loc, true);
+ st.setSubIters(subIters[0]);
+ st.setResettable(true);
+ called++;
+ XDMIterator reduceFunc = new UserdefFuncCallLateBinding(context);
+ if (direction == DIRECTION_LEFT)
+ reduceFunc.setSubIters(new XDMIterator[]{st,new VariableIterator(context,qnZero,true,loc),new VariableIterator(context,qnSeq,true,loc)});
+ else
+ reduceFunc.setSubIters(new XDMIterator[]{st,new VariableIterator(context,qnSeq,true,loc), new VariableIterator(context,qnZero,true,loc)});
+ reduceFunc.staticInit();
+ reduceFunc.setResettable(true);
+
+ // create Windows on each
+ Window wnd1 = WindowFactory.getNewWindow(context, subIters[2]);
+ current = WindowFactory.getNewWindow(context, subIters[1]);
+ if (direction == DIRECTION_LEFT)
+ while (wnd1.hasNextItem()) {
+ if (vh1.getIter() != null)
+ ((Window)vh1.getIter()).destroyWindow();
+ vh1.setIter(wnd1.nextItem());
+ vh2.setIter(current);
+ //current.reset();
+ collect(reduceFunc);
+ } else {
+ int numItems = 1;
+ while (wnd1.hasItem(numItems)) {
+ numItems++;
+ }
+ numItems--;
+ for (int i=numItems;i>0;i--) {
+ if (vh1.getIter() != null)
+ ((Window)vh1.getIter()).destroyWindow();
+ vh1.setIter(wnd1.getItem(i));
+ vh2.setIter(current);
+ collect(reduceFunc);
+ }
+ }
+
+ }
+ if (endOfSeq)
+ return Token.END_SEQUENCE_TOKEN;
+ TokenInterface tk = current.next();
+ return tk;
+ }
+
+
+
+ void collect(XDMIterator reduceFunc) throws MXQueryException {
+ Vector acc = new Vector();
+ TokenInterface tok = reduceFunc.next();
+ while (tok.getEventType()!=Type.END_SEQUENCE) {
+ acc.addElement(tok);
+ tok = reduceFunc.next();
+ }
+ current = WindowFactory.getNewWindow(context, new TokenSequenceIterator(acc));
+ reduceFunc.reset();
+ }
+
+
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ Fold copy = new Fold();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ copy.direction = direction;
+ return copy;
+ }
+
+ public void setOperation(String type) throws MXQueryException {
+ if (type.equals("left"))
+ direction = DIRECTION_LEFT;
+ else if (type.equals("right"))
+ direction = DIRECTION_RIGHT;
+ else
+ throw new MXQueryException(ErrorCodes.E0009_STATIC_SCHEMA_IMPORTS_NOT_SUPPORTED, "invalid value for fold: "+type, loc);
+ }
+
+ public void setReturnType(int type) throws MXQueryException {
+ }
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-05-16 14:27:10 UTC (rev 4342)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-05-16 14:28:49 UTC (rev 4343)
@@ -1920,7 +1920,7 @@
Object obj = subs.elementAt(i);
if (obj instanceof VariableIterator) {
VariableIterator vi = (VariableIterator)obj;
- if (!vi.isInContextOrNested(getCurrentContext())) {
+ if (!vi.isInContextOrNested(getCurrentContext()) && !getCurrentContext().checkVariableLocal(vi.getVarQName())) {
//establish closure by putting variable definition
closure.addElement(vi.getVarQName());
//context of function get new variable definition of closure variables
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-16 14:27:17
|
Revision: 4342
http://mxquery.svn.sourceforge.net/mxquery/?rev=4342&view=rev
Author: pm_fischer
Date: 2011-05-16 14:27:10 +0000 (Mon, 16 May 2011)
Log Message:
-----------
added map(), filter(), map-pairs()
minor cleanup and bug fixes
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/bindings/WindowSequenceIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Contains.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EndsWith.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StartsWith.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/FFLWORIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/SequenceTypeIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java
Added Paths:
-----------
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Filter.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Map.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/MapPairs.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/bindings/WindowSequenceIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/bindings/WindowSequenceIterator.java 2011-05-16 10:18:59 UTC (rev 4341)
+++ trunk/MXQuery/src/ch/ethz/mxquery/bindings/WindowSequenceIterator.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -127,6 +127,8 @@
this.endNode = endNode;
this.nodeId = startNode;
tokenIdOutdated = true;
+ if (mat.getSource()!=null)
+ context = mat.getSource().getContext();
}
public boolean hasItem(int position) throws MXQueryException {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml 2011-05-16 10:18:59 UTC (rev 4341)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml 2011-05-16 14:27:10 UTC (rev 4342)
@@ -403,6 +403,12 @@
<className>False</className>
</functionDescription>
<functionDescription>
+ <functionName>filter</functionName>
+ <parameters><paramType>function(*)</paramType>
+ <paramType>item()*</paramType></parameters>
+ <className>Filter</className>
+ </functionDescription>
+ <functionDescription>
<functionName>floor</functionName>
<parameters>
<paramType>numeric?</paramType>
@@ -410,6 +416,20 @@
<className>Floor</className>
</functionDescription>
<functionDescription>
+ <functionName>fold-left</functionName>
+ <parameters><paramType>function(*)</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType></parameters>
+ <className op="left">fold</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>fold-right</functionName>
+ <parameters><paramType>function(*)</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType></parameters>
+ <className op="right">fold</className>
+ </functionDescription>
+ <functionDescription>
<functionName>function-name</functionName>
<parameters>
<paramType>function(*)</paramType>
@@ -585,6 +605,24 @@
<className>LowerCase</className>
</functionDescription>
<functionDescription>
+ <functionName>map</functionName>
+ <parameters>
+ <paramType>function(*)</paramType>
+ <paramType>item()*</paramType>
+ </parameters>
+ <className>Map</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>map-pairs</functionName>
+ <parameters>
+ <paramType>function(*)</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ </parameters>
+ <className>MapPairs</className>
+ </functionDescription>
+
+ <functionDescription>
<functionName>matches</functionName>
<parameters>
<paramType>xs:string?</paramType>
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Contains.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Contains.java 2011-05-16 10:18:59 UTC (rev 4341)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Contains.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -20,12 +20,9 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.BooleanToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.Set;
@@ -35,22 +32,12 @@
protected void init() throws MXQueryException {
//currentToken = new BooleanToken(null);
- XDMIterator iter0 = subIters[0];
- XDMIterator iter1 = subIters[1];
+ String res = getStringValueOrEmpty(subIters[0]);
+ String res2 = getStringValueOrEmpty(subIters[1]);
- TokenInterface inputToken1 = iter0.next();
- int type = inputToken1.getEventType();
- TokenInterface inputToken2 = iter1.next();
- int type2 = inputToken2.getEventType();
-
if (subIters.length > 2) {
// Minimum collation test - raise error on all collations that are not codepoint
- XDMIterator collIter = subIters[2];
- TokenInterface collToken = collIter.next();
- if (collToken == Token.END_SEQUENCE_TOKEN ||
- !Type.isTypeOrSubTypeOf(collToken.getEventType(),Type.STRING, Context.getDictionary()))
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Wrong type for collation", loc);
- String collUri = collToken.getText();
+ String collUri = getStringValue(subIters[2]);
Set collations = context.getCollations();
if (!collations.contains(collUri))
throw new DynamicException(ErrorCodes.F0010_UNSUPPORTED_COLLATION, "Unsupported Collation", loc);
@@ -58,19 +45,12 @@
}
- String res2 = "";
- if (type2 != Type.END_SEQUENCE)
- res2 = inputToken2.getText();
-
- if (res2.equals("")) {
+ if (res2 == null ||res2.equals("")) {
currentToken = BooleanToken.TRUE_TOKEN;
return;
}
- String res = "";
- if (type != Type.END_SEQUENCE)
- res = inputToken1.getText();
if (res == null || res.equals(""))
currentToken = BooleanToken.FALSE_TOKEN;
else {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EndsWith.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EndsWith.java 2011-05-16 10:18:59 UTC (rev 4341)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EndsWith.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -20,12 +20,9 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.BooleanToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.Set;
@@ -33,48 +30,23 @@
public class EndsWith extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator iter0 = subIters[0];
- XDMIterator iter1 = subIters[1];
- TokenInterface inputToken1 = iter0.next();
- int type = inputToken1.getEventType();
- TokenInterface inputToken2 = iter1.next();
- int type2 = inputToken2.getEventType();
+ String res = getStringValueOrEmpty(subIters[0]);
+ String res2 = getStringValueOrEmpty(subIters[1]);
if (subIters.length > 2) {
// Minimum collation test - raise error on all collations that are not codepoint
- XDMIterator collIter = subIters[2];
- TokenInterface collToken = collIter.next();
- if (collToken == Token.END_SEQUENCE_TOKEN ||
- !Type.isTypeOrSubTypeOf(collToken.getEventType(),Type.STRING, Context.getDictionary()))
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Wrong type for collation", loc);
- String collUri = collToken.getText();
- Set collations = context.getCollations();
+ String collUri = getStringValue(subIters[2]);
+ Set collations = context.getCollations();
if (!collations.contains(collUri))
throw new DynamicException(ErrorCodes.F0010_UNSUPPORTED_COLLATION, "Unsupported Collation", loc);
}
- String res2 = "";
- if (type2 != Type.END_SEQUENCE)
- res2 = inputToken2.getText();
- else {
+ if (res2 == null || res2.equals("")) {
currentToken = BooleanToken.TRUE_TOKEN;
return;
- }
-
- if (res2.equals("")) {
- currentToken = BooleanToken.TRUE_TOKEN;
- return;
}
-
- String res = "";
- if (type != Type.END_SEQUENCE)
- res = inputToken1.getText();
- else {
- currentToken = BooleanToken.FALSE_TOKEN;
- return;
- }
if (res == null || res.equals(""))
currentToken = BooleanToken.FALSE_TOKEN;
else {
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Filter.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Filter.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Filter.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -0,0 +1,68 @@
+package ch.ethz.mxquery.functions.fn;
+
+import java.util.Vector;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.iterators.FFLWORIterator;
+import ch.ethz.mxquery.iterators.ForIterator;
+import ch.ethz.mxquery.iterators.SequenceTypeIterator;
+import ch.ethz.mxquery.iterators.UserdefFuncCallLateBinding;
+import ch.ethz.mxquery.iterators.VariableIterator;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.Iterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class Filter extends CurrentBasedIterator {
+
+ public TokenInterface next() throws MXQueryException {
+ if (called == 0) {
+// TokenInterface tok = subIters[0].next();
+// if (tok.getEventType()!= Type.FUNCTION_ITEM)
+// throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Function Item expected",loc);
+ // FLWOR
+ Context flworScope = new Context(context);
+ Context forScope = new Context(flworScope);
+
+ forScope.registerNewContextItem();
+ // if (!(predicate instanceof FFLWORIterator))
+ TypeInfo [] params = new TypeInfo[1];
+ params[0] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ TypeInfo tInfo = new TypeInfo(Type.FUNCTION_ITEM, Type.OCCURRENCE_IND_EXACTLY_ONE, params, new TypeInfo(Type.BOOLEAN,Type.OCCURRENCE_IND_EXACTLY_ONE));
+ SequenceTypeIterator st = new SequenceTypeIterator(tInfo, true, true, context, loc, true);
+ st.setSubIters(subIters[0]);
+ Iterator[] its = null;
+ ForIterator forIt = new ForIterator(forScope,
+ new XDMIterator[] { subIters[1] }, Context.CONTEXT_ITEM,
+ null, null, true, loc, false);
+ its = new Iterator[] { forIt };
+ VariableIterator varIt = new VariableIterator(forScope,
+ Context.CONTEXT_ITEM, false, loc);
+ VariableIterator varIt1 = new VariableIterator(forScope,
+ Context.CONTEXT_ITEM, false, loc);
+
+ UserdefFuncCallLateBinding funcInv = new UserdefFuncCallLateBinding(context);
+ funcInv.setSubIters(new XDMIterator[]{st,varIt1});
+ current = new FFLWORIterator(context, its, funcInv,
+ varIt, loc);
+ current.staticInit();
+ current.setResettable(resettable);
+ // For over subiter[1]
+ // return with function item invocation
+ called++;
+ }
+ return current.next();
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ XDMIterator copy = new Filter();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Map.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Map.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Map.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -0,0 +1,65 @@
+package ch.ethz.mxquery.functions.fn;
+
+import java.util.Vector;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.iterators.FFLWORIterator;
+import ch.ethz.mxquery.iterators.ForIterator;
+import ch.ethz.mxquery.iterators.SequenceTypeIterator;
+import ch.ethz.mxquery.iterators.UserdefFuncCallLateBinding;
+import ch.ethz.mxquery.iterators.VariableIterator;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.Iterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class Map extends CurrentBasedIterator {
+
+ public TokenInterface next() throws MXQueryException {
+ if (called == 0) {
+// TokenInterface tok = subIters[0].next();
+// if (tok.getEventType()!= Type.FUNCTION_ITEM)
+// throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Function Item expected",loc);
+ // FLWOR
+ Context flworScope = new Context(context);
+ Context forScope = new Context(flworScope);
+
+ forScope.registerNewContextItem();
+ // if (!(predicate instanceof FFLWORIterator))
+ TypeInfo [] params = new TypeInfo[1];
+ params[0] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE);
+ TypeInfo tInfo = new TypeInfo(Type.FUNCTION_ITEM, Type.OCCURRENCE_IND_EXACTLY_ONE, params, new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE));
+ SequenceTypeIterator st = new SequenceTypeIterator(tInfo, true, true, context, loc, true);
+ st.setSubIters(subIters[0]);
+
+ Iterator[] its = null;
+ ForIterator forIt = new ForIterator(forScope,
+ new XDMIterator[] { subIters[1] }, Context.CONTEXT_ITEM,
+ null, null, true, loc, false);
+ its = new Iterator[] { forIt };
+ VariableIterator varIt = new VariableIterator(forScope,
+ Context.CONTEXT_ITEM, false, loc);
+ UserdefFuncCallLateBinding funcInv = new UserdefFuncCallLateBinding(context);
+ funcInv.setSubIters(new XDMIterator[]{st,varIt});
+ current = new FFLWORIterator(context, its, null,
+ funcInv, loc);
+ current.staticInit();
+ // For over subiter[1]
+ // return with function item invocation
+ called++;
+ }
+ return current.next();
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ XDMIterator copy = new Map();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/MapPairs.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/MapPairs.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/MapPairs.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -0,0 +1,88 @@
+package ch.ethz.mxquery.functions.fn;
+
+import java.util.Vector;
+
+import ch.ethz.mxquery.bindings.WindowFactory;
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.iterators.SequenceTypeIterator;
+import ch.ethz.mxquery.iterators.UserdefFuncCallLateBinding;
+import ch.ethz.mxquery.iterators.VariableIterator;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.EmptySequenceIterator;
+import ch.ethz.mxquery.model.VariableHolder;
+import ch.ethz.mxquery.model.Window;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class MapPairs extends CurrentBasedIterator {
+ Window wnd1, wnd2;
+ VariableHolder vh1 = null, vh2 = null;
+ SequenceTypeIterator st =null;
+ public TokenInterface next() throws MXQueryException {
+ if (called == 0) {
+ QName qn1 = context.registerAnonymousVariable();
+ vh1 = context.getVariable(qn1);
+ QName qn2 = context.registerAnonymousVariable();
+ vh2 = context.getVariable(qn2);
+ called++;
+ TypeInfo [] params = new TypeInfo[2];
+ params[0] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ params[1] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
+
+ TypeInfo tInfo = new TypeInfo(Type.FUNCTION_ITEM, Type.OCCURRENCE_IND_EXACTLY_ONE, params, new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE));
+ st = new SequenceTypeIterator(tInfo, true, true, context, loc, true);
+ st.setSubIters(subIters[0]);
+ st.setResettable(true);
+ called++;
+ current = new UserdefFuncCallLateBinding(context);
+ current.setSubIters(new XDMIterator[]{st,new VariableIterator(context,qn1,true,loc),new VariableIterator(context,qn2,true,loc)});
+ current.staticInit();
+ current.setResettable(true);
+
+ // create Windows on each
+ wnd1 = WindowFactory.getNewWindow(context, subIters[1]);
+ wnd2 = WindowFactory.getNewWindow(context, subIters[2]);
+
+ bindPair(st);
+
+ }
+ if (endOfSeq)
+ return Token.END_SEQUENCE_TOKEN;
+ TokenInterface tk = current.next();
+ if (tk.getEventType() == Type.END_SEQUENCE) {
+ bindPair(st);
+ tk = current.next();
+ }
+ return tk;
+ }
+
+ void bindPair(SequenceTypeIterator st) throws MXQueryException {
+ if (wnd1.hasNextItem() && wnd2.hasNextItem()) {
+ if (vh1.getIter() != null)
+ ((Window)vh1.getIter()).destroyWindow();
+ vh1.setIter(wnd1.nextItem());
+ if (vh2.getIter() != null)
+ ((Window)vh2.getIter()).destroyWindow();
+ vh2.setIter(wnd2.nextItem());
+ current.reset();
+
+ } else {
+ current = new EmptySequenceIterator(context,loc);
+ endOfSeq = true;
+ }
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ XDMIterator copy = new MapPairs();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StartsWith.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StartsWith.java 2011-05-16 10:18:59 UTC (rev 4341)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/StartsWith.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -20,12 +20,9 @@
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.BooleanToken;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.Set;
@@ -33,22 +30,12 @@
public class StartsWith extends TokenBasedIterator {
protected void init() throws MXQueryException {
- XDMIterator iter0 = subIters[0];
- XDMIterator iter1 = subIters[1];
+ String res = getStringValueOrEmpty(subIters[0]);
+ String res2 = getStringValueOrEmpty(subIters[1]);
- TokenInterface inputToken1 = iter0.next();
- int type = inputToken1.getEventType();
- TokenInterface inputToken2 = iter1.next();
- int type2 = inputToken2.getEventType();
-
if (subIters.length > 2) {
// Minimum collation test - raise error on all collations that are not codepoint
- XDMIterator collIter = subIters[2];
- TokenInterface collToken = collIter.next();
- if (collToken == Token.END_SEQUENCE_TOKEN ||
- !Type.isTypeOrSubTypeOf(collToken.getEventType(),Type.STRING, Context.getDictionary()))
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Wrong type for collation", loc);
- String collUri = collToken.getText();
+ String collUri = getStringValue(subIters[2]);
Set collations = context.getCollations();
if (!collations.contains(collUri))
throw new DynamicException(ErrorCodes.F0010_UNSUPPORTED_COLLATION, "Unsupported Collation", loc);
@@ -56,27 +43,12 @@
}
- String res2 = "";
- if (type2 != Type.END_SEQUENCE)
- res2 = inputToken2.getText();
- else {
+ if (res2 == null || res2.equals("")) {
currentToken = BooleanToken.TRUE_TOKEN;
return;
}
- if (res2.equals("")) {
- currentToken = BooleanToken.TRUE_TOKEN;
- return;
- }
-
-
- String res = "";
- if (type != Type.END_SEQUENCE)
- res = inputToken1.getText();
- else {
- currentToken = BooleanToken.FALSE_TOKEN;
- return;
- }
+
if (res == null || res.equals(""))
currentToken = BooleanToken.FALSE_TOKEN;
else {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/FFLWORIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/FFLWORIterator.java 2011-05-16 10:18:59 UTC (rev 4341)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/FFLWORIterator.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -188,9 +188,10 @@
}
else throw te;
}
- if (tok.getEventType() == Type.BOOLEAN) {
+ if (tok.getEventType() == Type.BOOLEAN && whereExpr.next().getEventType() == Type.END_SEQUENCE) {
value = tok.getBoolean();
- }
+ } else
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"xs:boolean expected",loc);
if (whereExpr.getExpressionCategoryType(isScripting) == EXPR_CATEGORY_UPDATING)
getPendingUpdateList().merge(whereExpr.getPendingUpdateList());
@@ -431,7 +432,7 @@
public XDMIterator staticInit() throws MXQueryException {
super.staticInit();
- setResettable(false);
+ setResettable(resettable);
return this;
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/SequenceTypeIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/SequenceTypeIterator.java 2011-05-16 10:18:59 UTC (rev 4341)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/SequenceTypeIterator.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -135,6 +135,8 @@
String name = node_name;
String[] tokens = QName.parseQName(node_name);
if (coerce && tInfo.getType() == Type.FUNCTION_ITEM) {
+ if (tok.getEventType() != Type.FUNCTION_ITEM)
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Function item expected",loc);
tok = coerceFunctionItem((FunctionItemToken)tok, tInfo);
return tok;
} else {
@@ -387,6 +389,8 @@
TokenInterface coerceFunctionItem(FunctionItemToken tok, TypeInfo targetType) throws MXQueryException {
FunctionSignature origSig = tok.getFunction().getFunctionSignature();
+ if (origSig.getArity() != targetType.getParameterTypes().length)
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Wrong arity for function item",loc);
FunctionSignature fs = new FunctionSignature(tok.getQNameTokenValue(), targetType.getParameterTypes(), FunctionSignature.USER_DEFINED_FUNCTION, origSig.getExpressionCategory(), origSig.isNonDeterministic(), origSig.isPrivateFunction());
Function fun = new Function(null,fs,tok.getFunction().getFunctionImplementation(getContext()),null,targetType.getReturnType());
return tok.coerce(fun);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java 2011-05-16 10:18:59 UTC (rev 4341)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java 2011-05-16 14:27:10 UTC (rev 4342)
@@ -101,7 +101,7 @@
if (funcName == null) {
// get function item from the first parameter
TokenInterface tok = subIters[0].next();
- if (tok.getEventType() != Type.FUNCTION_ITEM && subIters[0].next().getEventType() != Type.END_SEQUENCE)
+ if (tok.getEventType() != Type.FUNCTION_ITEM || subIters[0].next().getEventType() != Type.END_SEQUENCE)
throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Single Function Item expected",loc);
ft = ((FunctionItemToken)tok);
f = ft.getFunction();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tim...@us...> - 2011-05-16 10:19:06
|
Revision: 4341
http://mxquery.svn.sourceforge.net/mxquery/?rev=4341&view=rev
Author: timchurch
Date: 2011-05-16 10:18:59 +0000 (Mon, 16 May 2011)
Log Message:
-----------
Added a rather pathetic home-made Android launcher icon
Modified Paths:
--------------
trunk/MXQuery_Android_App/AndroidManifest.xml
Added Paths:
-----------
trunk/MXQuery_Android_App/res/drawable-hdpi/xquery_icon.png
trunk/MXQuery_Android_App/res/drawable-ldpi/xquery_icon.png
trunk/MXQuery_Android_App/res/drawable-mdpi/xquery_icon.png
Modified: trunk/MXQuery_Android_App/AndroidManifest.xml
===================================================================
--- trunk/MXQuery_Android_App/AndroidManifest.xml 2011-05-14 15:31:32 UTC (rev 4340)
+++ trunk/MXQuery_Android_App/AndroidManifest.xml 2011-05-16 10:18:59 UTC (rev 4341)
@@ -5,7 +5,7 @@
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"></uses-sdk>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
- <application android:icon="@drawable/icon" android:label="@string/app_name" android:permission="android.permission.READ_CONTACTS">
+ <application android:icon="@drawable/xquery_icon" android:label="@string/app_name" android:permission="android.permission.READ_CONTACTS">
<activity android:name="Start">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Added: trunk/MXQuery_Android_App/res/drawable-hdpi/xquery_icon.png
===================================================================
(Binary files differ)
Property changes on: trunk/MXQuery_Android_App/res/drawable-hdpi/xquery_icon.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/MXQuery_Android_App/res/drawable-ldpi/xquery_icon.png
===================================================================
(Binary files differ)
Property changes on: trunk/MXQuery_Android_App/res/drawable-ldpi/xquery_icon.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/MXQuery_Android_App/res/drawable-mdpi/xquery_icon.png
===================================================================
(Binary files differ)
Property changes on: trunk/MXQuery_Android_App/res/drawable-mdpi/xquery_icon.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-14 15:31:41
|
Revision: 4340
http://mxquery.svn.sourceforge.net/mxquery/?rev=4340&view=rev
Author: pm_fischer
Date: 2011-05-14 15:31:32 +0000 (Sat, 14 May 2011)
Log Message:
-----------
Merge branch 'XQ3.0-functions'
Modified Paths:
--------------
trunk/MXQuery/build.xml
trunk/MXQuery/midp_src/ch/ethz/mxquery/util/IOLib.java
trunk/MXQuery/midp_src/ch/ethz/mxquery/xdmio/XDMInputFactory.java
trunk/MXQuery/src/ch/ethz/mxquery/cmdline/MXQuery.java
trunk/MXQuery/src/ch/ethz/mxquery/datamodel/MXQueryDouble.java
trunk/MXQuery/src/ch/ethz/mxquery/exceptions/MXQueryException.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocumentUri.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Node_Name.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubSequenceIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/math/TransMath.java
trunk/MXQuery/src/ch/ethz/mxquery/model/Iterator.java
trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
trunk/MXQuery/src/ch/ethz/mxquery/util/FileReader.java
trunk/MXQuery/src/ch/ethz/mxquery/util/IOLib.java
trunk/MXQuery_Testing/XQTests/Queries/inserttest.xml
trunk/MXQuery_Testing/XQTests/Sources/doc.xml
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/XQ11FunctionsTest.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/scripting/ScriptingUseCases.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/testsuite/TestSuite.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/testsuite/internal/DictionaryBasedStemmer.java
Added Paths:
-----------
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/AvailEnvVars.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EnvVar.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Head.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Tail.java
trunk/MXQuery_Testing/XQTests/Sources/iso.txt
Modified: trunk/MXQuery/build.xml
===================================================================
--- trunk/MXQuery/build.xml 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/build.xml 2011-05-14 15:31:32 UTC (rev 4340)
@@ -184,7 +184,7 @@
<delete file="${customtmp.dir}/ch/ethz/mxquery/sms/activeStore/ReadDataThread.java" />
<delete file="${customtmp.dir}/ch/ethz/mxquery/functions/fn/NormalizeUnicode.java" />
-
+ <delete file="${customtmp.dir}/ch/ethz/mxquery/functions/fn/AvailEnvVars.java"/>
<delete file="${customtmp.dir}/ch/ethz/mxquery/iterators/PFFLWORIterator.java" />
<delete file="${customtmp.dir}/ch/ethz/mxquery/iterators/PGFLWORIterator.java"/>
<delete file="${customtmp.dir}/ch/ethz/mxquery/iterators/PGroupBy.java"/>
@@ -444,6 +444,8 @@
<delete file="${midptmp.dir}/ch/ethz/mxquery/functions/fn/Round.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/functions/fn/Put.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/functions/fn/Matches.java"/>
+ <delete file="${midptmp.dir}/ch/ethz/mxquery/functions/fn/AvailEnvVars.java"/>
+ <delete file="${midptmp.dir}/ch/ethz/mxquery/functions/fn/EnvVar.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/functions/fn/IRItoURI.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/functions/fn/DocAvailable.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/functions/fn/NormalizeUnicode.java"/>
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/util/IOLib.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/util/IOLib.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/util/IOLib.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -137,15 +137,16 @@
return encoding;
}
- public static Reader getInput (String uri, boolean xquery, QueryLocation loc) throws MXQueryException {
- String encoding = "utf-8";
+ public static Reader getInput (String uri, boolean xquery, String encoding, QueryLocation loc) throws MXQueryException {
+ if (encoding == null)
+ encoding = "utf-8";
InputStream ins = null;
try {
ins = Connector.openInputStream(uri);
- encoding = "iso-8859-1";
+ //encoding = "iso-8859-1";
String tempEncoding = IOLib.snoopEncoding8bit(ins, xquery);
if (tempEncoding != null) {
encoding = tempEncoding;
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/xdmio/XDMInputFactory.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/xdmio/XDMInputFactory.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/xdmio/XDMInputFactory.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -49,7 +49,7 @@
public static XMLSource createXMLInput(Context ctx, String uri, boolean doc, int valMode, QueryLocation location) throws MXQueryException {
if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD)
- return new XPPImportAdapter(ctx,IOLib.getInput(uri, false, location),doc,location);
+ return new XPPImportAdapter(ctx,IOLib.getInput(uri, false, null,location),doc,location);
else {
throw new MXQueryException(ErrorCodes.A0002_EC_NOT_SUPPORTED,"XML Input validation not supported on CLDC",location);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/cmdline/MXQuery.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/cmdline/MXQuery.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/cmdline/MXQuery.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -536,7 +536,7 @@
throw new Exception(errorMsg+compString[j]);
QName varName = getVar(ctx, argValPair);
String uri = URIUtils.resolveURI(ctx.getBaseURI(),argValPair[1],QueryLocation.OUTSIDE_QUERY_LOC);
- Reader rd = IOLib.getInput(uri, false, QueryLocation.OUTSIDE_QUERY_LOC);
+ Reader rd = IOLib.getInput(uri, false, null, QueryLocation.OUTSIDE_QUERY_LOC);
VariableHolder vh = ctx.getVariable(varName);
XDMIterator xmlIt;
if (vh != null && vh.getType() != null && Type.isAtomicType(vh.getType().getType(),Context.getDictionary())) {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/MXQueryDouble.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/MXQueryDouble.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/MXQueryDouble.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -108,6 +108,8 @@
public MXQueryDouble(double d) {
val = d;
+ if ((new Float(d)).equals(new Float(-0.0)))
+ negativeZero = true;
}
/** Methods: */
Modified: trunk/MXQuery/src/ch/ethz/mxquery/exceptions/MXQueryException.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/exceptions/MXQueryException.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/exceptions/MXQueryException.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -93,7 +93,7 @@
if (loc.getFile()!=null) {
str.append("Error was not caused in main query module, but in the imported query module ").append(loc.getFile()).append("\n");
try {
- query = FileReader.getContents(IOLib.getInput(loc.getFile(), true, QueryLocation.OUTSIDE_QUERY_LOC));
+ query = FileReader.getContents(IOLib.getInput(loc.getFile(), true, null, QueryLocation.OUTSIDE_QUERY_LOC));
} catch (MXQueryException e) {
str.append("Could not retrieve module contents, bailing out");
return str.toString();
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml 2011-05-14 15:31:32 UTC (rev 4340)
@@ -62,6 +62,11 @@
<className type="xs:time">DateTimeAdjustTimezone</className>
</functionDescription>
<functionDescription>
+ <functionName>available-environment-variables</functionName>
+ <parameters/>
+ <className>AvailEnvVars</className>
+ </functionDescription>
+ <functionDescription>
<functionName>avg</functionName>
<parameters>
<paramType>xs:anyAtomicType*</paramType>
@@ -185,6 +190,11 @@
<parameters> </parameters>
<className>CurrentTime</className>
</functionDescription>
+ <functionDescription>
+ <functionName>data</functionName>
+ <parameters/>
+ <className>DataValuesIterator</className>
+ </functionDescription>
<functionDescription>
<functionName>data</functionName>
<parameters>
@@ -272,6 +282,11 @@
</parameters>
<className>DocAvailable</className>
</functionDescription>
+ <functionDescription>
+ <functionName>document-uri</functionName>
+ <parameters/>
+ <className>DocumentUri</className>
+ </functionDescription>
<functionDescription>
<functionName>document-uri</functionName>
<parameters>
@@ -326,6 +341,13 @@
<className>EndsWith</className>
</functionDescription>
<functionDescription>
+ <functionName>environment-variable</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ </parameters>
+ <className>EnvVar</className>
+ </functionDescription>
+ <functionDescription>
<functionName>error</functionName>
<parameters>
<paramType>xs:QName?</paramType>
@@ -414,6 +436,13 @@
<className>GenerateId</className>
</functionDescription>
<functionDescription>
+ <functionName>head</functionName>
+ <parameters>
+ <paramType>item()?</paramType>
+ </parameters>
+ <className>Head</className>
+ </functionDescription>
+ <functionDescription>
<functionName>hours-from-dateTime</functionName>
<parameters>
<paramType>xs:dateTime?</paramType>
@@ -692,6 +721,11 @@
</functionDescription>
<functionDescription>
<functionName>node-name</functionName>
+ <parameters/>
+ <className>Node_Name</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>node-name</functionName>
<parameters>
<paramType>node()?</paramType>
</parameters>
@@ -751,14 +785,14 @@
<className>One_or_more</className>
</functionDescription>
<functionDescription>
- <functionName>parse</functionName>
+ <functionName>parse-xml</functionName>
<parameters>
<paramType>string</paramType>
</parameters>
<className>Parse</className>
</functionDescription>
<functionDescription>
- <functionName>parse</functionName>
+ <functionName>parse-xml</functionName>
<parameters>
<paramType>string</paramType>
<paramType>string</paramType>
@@ -1081,6 +1115,13 @@
</parameters>
<className>Sum</className>
</functionDescription>
+ <functionDescription>
+ <functionName>tail</functionName>
+ <parameters>
+ <paramType>item()*</paramType>
+ </parameters>
+ <className>Tail</className>
+ </functionDescription>
<functionDescription>
<functionName>timezone-from-date</functionName>
<parameters>
@@ -1149,6 +1190,44 @@
<className>Unordered</className>
</functionDescription>
<functionDescription>
+ <functionName>unparsed-text</functionName>
+ <parameters>
+ <paramType>xs:string?</paramType>
+ </parameters>
+ <className op="unparsed-text">Doc</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>unparsed-text</functionName>
+ <parameters>
+ <paramType>xs:string?</paramType>
+ <paramType>xs:string</paramType>
+ </parameters>
+ <className op="unparsed-text">Doc</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>unparsed-text-lines</functionName>
+ <parameters>
+ <paramType>xs:string?</paramType>
+ </parameters>
+ <className op="unparsed-text-lines">Doc</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>unparsed-text-lines</functionName>
+ <parameters>
+ <paramType>xs:string?</paramType>
+ <paramType>xs:string</paramType>
+ </parameters>
+ <className op="unparsed-text-lines">Doc</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>unparsed-text-available</functionName>
+ <parameters>
+ <paramType>xs:string?</paramType>
+ </parameters>
+ <className>DocAvailable</className>
+ </functionDescription>
+
+ <functionDescription>
<functionName>upper-case</functionName>
<parameters>
<paramType>xs:string?</paramType>
@@ -1512,7 +1591,8 @@
<functionDescription>
<functionName>atan2</functionName>
<parameters>
- <paramType>xs:double?</paramType>
+ <paramType>xs:double</paramType>
+ <paramType>xs:double</paramType>
</parameters>
<className op="atan2">TransMath</className>
</functionDescription>
@@ -1635,4 +1715,4 @@
<className>SubFiles2</className>
</functionDescription>
</functionGroup>
-</functionGallery>
\ No newline at end of file
+</functionGallery>
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/AvailEnvVars.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/AvailEnvVars.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/AvailEnvVars.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -0,0 +1,38 @@
+package ch.ethz.mxquery.functions.fn;
+
+import java.util.Vector;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.xdm.TextToken;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.TokenSequenceIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class AvailEnvVars extends CurrentBasedIterator {
+
+ public TokenInterface next() throws MXQueryException {
+ if (called == 0) {
+ called++;
+ Vector vars = new Vector();
+ java.util.Iterator envVars = System.getenv().keySet().iterator();
+ // create a snapshot of the environment variables
+ while (envVars.hasNext()) {
+ TokenInterface tok = new TextToken(null,(String)envVars.next());
+ vars.add(tok);
+ }
+ current = new TokenSequenceIterator(vars);
+ }
+ return current.next();
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ AvailEnvVars copy = new AvailEnvVars();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -64,9 +64,6 @@
DataValuesIterator(Context ctx, XDMIterator iter, QueryLocation location) {
super(ctx, location);
- if (iter == null) {
- throw new IllegalArgumentException();
- }
this.subIters = new XDMIterator[] { iter };
}
@@ -74,10 +71,8 @@
super(null, location);
this.fnData = true;
- if (iter == null) {
- throw new IllegalArgumentException();
- }
- this.subIters = new XDMIterator[] { iter };
+ if (iter != null)
+ this.subIters = new XDMIterator[] { iter };
}
public DataValuesIterator() {
@@ -89,7 +84,7 @@
if (!evalComplete) {
if (!(current instanceof SequenceIterator))
- current = getValue(subIters[0]);
+ current = getValue(getNodeIteratorOrContext(subIters, 1,context, loc));
TokenInterface e = current.next();
if (e.getEventType() == Type.END_SEQUENCE) {
evalComplete = true;
@@ -740,7 +735,11 @@
protected XDMIterator copy(Context context, XDMIterator[] subIters,
Vector nestedPredCtxStack) throws MXQueryException {
- XDMIterator copy = new DataValuesIterator(subIters[0], loc);
+ XDMIterator copy ;
+ if (subIters != null && subIters.length > 0)
+ copy = new DataValuesIterator(subIters[0], loc);
+ else
+ copy = new DataValuesIterator(null,loc);
copy.setContext(context, false);
return copy;
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -22,17 +22,20 @@
import ch.ethz.mxquery.contextConfig.Context;
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.datamodel.xdm.TextToken;
import ch.ethz.mxquery.datamodel.xdm.Token;
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.DynamicException;
import ch.ethz.mxquery.exceptions.ErrorCodes;
import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.functions.RequestTypeMulti;
+import ch.ethz.mxquery.iterators.TokenIterator;
import ch.ethz.mxquery.model.CurrentBasedIterator;
import ch.ethz.mxquery.model.EmptySequenceIterator;
+import ch.ethz.mxquery.model.TokenSequenceIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.IOLib;
+import ch.ethz.mxquery.util.LineReader;
import ch.ethz.mxquery.util.URIUtils;
import ch.ethz.mxquery.xdmio.XDMInputFactory;
import ch.ethz.mxquery.xdmio.XMLSource;
@@ -43,8 +46,12 @@
*
*/
public class Doc extends CurrentBasedIterator implements RequestTypeMulti{
- private boolean inValidateExpression = false;
- private boolean tidyInput = false;
+ private final int OPERATION_DOC = 0;
+ private final int OPERATION_TIDY =1;
+ private final int OPERATION_UNPARSED=2;
+ private final int OPERATION_UNPARSED_LINES=3;
+private boolean inValidateExpression = false;
+ private int operation = OPERATION_DOC;
private String docURI = null;
private Reader rd = null; // keep around to close
@@ -60,10 +67,6 @@
public void setInValidateExpression(boolean inValidateExpression) {
this.inValidateExpression = inValidateExpression;
}
-
- public void setTidyInput (boolean tidyInput) {
- this.tidyInput = tidyInput;
- }
public TokenInterface next() throws MXQueryException {
if (called == 0) {
@@ -93,54 +96,90 @@
protected void init() throws MXQueryException {
- XDMIterator parameter = subIters[0];
- if (parameter == null) {
- // this should never happen!!!
- throw new IllegalArgumentException("No parameter for fn:doc() function given!");
- }
- TokenInterface tok = parameter.next();
- int type = Type.getEventTypeSubstituted(tok.getEventType(), Context.getDictionary());
+
+ String add = getStringValueOrEmpty(subIters[0]);
+
- if (type == Type.END_SEQUENCE) {
+ if (add == null) {
current = new EmptySequenceIterator(context, loc);
return;
}
- if (Type.typePromoteableTo(type, Type.STRING,Context.getDictionary())|| type == Type.UNTYPED_ATOMIC) {
-
- String add = tok.getText();
- String uri = null;
- try {
- uri = URIUtils.resolveURI(context.getBaseURI(),add,loc);
- } catch (DynamicException de) {
- if (de.getErrorCode().equals(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE)) {
- throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC, "Invalid URI given to fn:doc(): "+add, loc);
- }
- else
- throw de;
- }
- if (tidyInput)
- rd = IOLib.getInput(uri, false, loc);
- XMLSource cur;
- try {
+
+ String encoding = null;
+
+ if (subIters.length > 1) {
+ encoding = getStringValue(subIters[1]);
+ }
+
+ String uri = null;
+ try {
+ uri = URIUtils.resolveURI(context.getBaseURI(),add,loc);
+ } catch (DynamicException de) {
+ if (de.getErrorCode().equals(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE)) {
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC, "Invalid URI given to fn:doc(): "+add, loc);
+ }
+ else
+ throw de;
+ }
+ if (operation!=OPERATION_DOC)
+ rd = IOLib.getInput(uri, false, encoding, loc);
+ XDMIterator cur = null;
+ try {
+ switch(operation) {
+ case OPERATION_DOC:
if (isInValidateExpression())
- cur = XDMInputFactory.createXMLInput(context, rd, true, Context.SCHEMA_VALIDATION_STRICT, loc);
- else if (tidyInput)
- cur = XDMInputFactory.createTidyInput(context, rd, loc);
- else cur = XDMInputFactory.createXMLInput(context, uri, true, context.getInputValidationMode(), loc);
- cur.setURI(uri);
- docURI = uri;
- current = cur;
- } catch (MXQueryException me) {
- try {
- rd.close();
- } catch (IOException ie) {
- //
- }
- throw me;
+ cur = XDMInputFactory.createXMLInput(context, rd, true, Context.SCHEMA_VALIDATION_STRICT, loc);
+ else
+ cur = XDMInputFactory.createXMLInput(context, uri, true, context.getInputValidationMode(), loc);
+ ((XMLSource)cur).setURI(uri);
+ break;
+ case OPERATION_TIDY:
+ cur = XDMInputFactory.createTidyInput(context, rd, loc);
+ ((XMLSource)cur).setURI(uri);
+ break;
+ case OPERATION_UNPARSED:
+ StringBuffer sb = new StringBuffer();
+ LineReader lr = new LineReader(rd);
+ String line = lr.readLine();
+ boolean first = true;
+ while(line!=null) {
+ if (first)
+ first=false;
+ else
+ sb.append('\n');
+ sb.append(line);
+ line = lr.readLine();
}
+ cur = new TokenIterator(context,sb.toString(),loc);
+ break;
+ case OPERATION_UNPARSED_LINES:
+ Vector lines = new Vector();
+ lr = new LineReader(rd);
+ line = lr.readLine();
+ while(line!=null) {
+ lines.addElement(new TextToken(null, line));
+ line = lr.readLine();
+ }
+ cur = new TokenSequenceIterator(lines);
+ break;
- } else {
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Invalid argument given to fn:doc", loc);
+ }
+ docURI = uri;
+ current = cur;
+ } catch (MXQueryException me) {
+ try {
+ rd.close();
+ } catch (IOException ie) {
+ //
+ }
+ throw me;
+ } catch (IOException e) {
+ try {
+ rd.close();
+ } catch (IOException ie) {
+ //
+ }
+ throw new MXQueryException(ErrorCodes.F0014_ERROR_RETRIEVING_RESOURCE, e.toString(), loc);
}
}
@@ -152,7 +191,7 @@
Doc copy = new Doc();
copy.setContext(context, true);
copy.setInValidateExpression(inValidateExpression);
- copy.setTidyInput(this.tidyInput);
+ copy.operation = operation;
copy.setConstModePreserve(this.constModePreserve);
copy.setSubIters(subIters);
return copy;
@@ -182,7 +221,11 @@
public void setOperation(String type) throws MXQueryException {
if (type.equals("tidy"))
- tidyInput = true;
+ operation = OPERATION_TIDY;
+ else if (type.equals("unparsed-text"))
+ operation = OPERATION_UNPARSED;
+ else if (type.equals("unparsed-text-lines"))
+ operation = OPERATION_UNPARSED_LINES;
else throw new MXQueryException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Incorrect operation for Doc", loc);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocumentUri.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocumentUri.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocumentUri.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -31,7 +31,8 @@
public class DocumentUri extends TokenBasedIterator {
protected void init() throws MXQueryException {
- TokenInterface tok = subIters[0].next();
+ XDMIterator iter = getNodeIteratorOrContext(subIters, 1, context, loc);
+ TokenInterface tok = iter.next();
if (tok.getEventType() == Type.START_DOCUMENT) {
// Take advantage of our Node ID implementation -
// each node ID has a reference to the store it comes from,
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EnvVar.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EnvVar.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/EnvVar.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -0,0 +1,32 @@
+package ch.ethz.mxquery.functions.fn;
+
+import java.util.Vector;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.xdm.TextToken;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class EnvVar extends TokenBasedIterator {
+
+ protected void init() throws MXQueryException {
+ String varName = getStringValue(subIters[0]);
+ String varValue = System.getenv(varName);
+ if (varValue != null)
+ currentToken = new TextToken(null,varValue);
+ else
+ currentToken = Token.END_SEQUENCE_TOKEN;
+
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ EnvVar copy = new EnvVar();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Head.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Head.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Head.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -0,0 +1,60 @@
+package ch.ethz.mxquery.functions.fn;
+
+import java.util.Vector;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class Head extends CurrentBasedIterator {
+ int position = 0;
+ public TokenInterface next() throws MXQueryException {
+ TokenInterface retToken;
+
+ if (endOfSeq)
+ return Token.END_SEQUENCE_TOKEN;
+
+ if (called == 0) {
+ called++;
+ current = subIters[0];
+ }
+ retToken = sub0Next();
+
+ if(position <=1) {
+ if (retToken.getEventType() == Type.END_SEQUENCE){
+ }
+ return retToken;
+ }
+ else {
+ //current = null;
+ endOfSeq = true;
+ return Token.END_SEQUENCE_TOKEN;
+ }
+ }
+
+ protected void resetImpl() throws MXQueryException {
+ super.resetImpl();
+ position = 0;
+ }
+
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ XDMIterator copy = new Head();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+ private TokenInterface sub0Next() throws MXQueryException {
+ if (depth == 0) {
+ position++;
+ }
+ return super.getNext();
+ }
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Node_Name.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Node_Name.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Node_Name.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -32,12 +32,8 @@
public class Node_Name extends TokenBasedIterator {
protected void init() throws MXQueryException {
- if (subIters == null || subIters.length == 0) {
- currentToken = Token.END_SEQUENCE_TOKEN;
- return;
- }
- XDMIterator input = subIters[0];
+ XDMIterator input = getNodeIteratorOrContext(subIters, 1,context, loc);
TokenInterface inputToken = input.next();
int i = inputToken.getEventType();
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubSequenceIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubSequenceIterator.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubSequenceIterator.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -19,7 +19,6 @@
import ch.ethz.mxquery.contextConfig.Context;
import ch.ethz.mxquery.datamodel.MXQueryDouble;
import ch.ethz.mxquery.datamodel.types.Type;
-import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.Token;
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.ErrorCodes;
@@ -161,9 +160,6 @@
startPos = -1;
len = -1;
position = 0;
- }
- public TypeInfo getStaticType() {
- return new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE);
}
protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException {
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Tail.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Tail.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Tail.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -0,0 +1,65 @@
+package ch.ethz.mxquery.functions.fn;
+
+import java.util.Vector;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class Tail extends CurrentBasedIterator {
+ int position = 0;
+ public TokenInterface next() throws MXQueryException {
+ TokenInterface retToken;
+
+ if (endOfSeq)
+ return Token.END_SEQUENCE_TOKEN;
+
+ if (called == 0) {
+ called++;
+ current = subIters[0];
+ retToken = skipToStart();
+ } else {
+ retToken = sub0Next();
+ }
+ if (retToken.getEventType() == Type.END_SEQUENCE){
+ endOfSeq = true;
+ return Token.END_SEQUENCE_TOKEN;
+ }
+ return retToken;
+ }
+
+ protected void resetImpl() throws MXQueryException {
+ super.resetImpl();
+ position = 0;
+ }
+
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ XDMIterator copy = new Tail();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+ private TokenInterface sub0Next() throws MXQueryException {
+ if (depth == 0) {
+ position++;
+ }
+ return super.getNext();
+ }
+
+ private TokenInterface skipToStart() throws MXQueryException{
+ while(true) {
+ TokenInterface tok = sub0Next();
+ if(position > 1 || tok.getEventType() == Type.END_SEQUENCE)
+ return tok;
+ }
+ }
+
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/math/TransMath.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/math/TransMath.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/math/TransMath.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -146,7 +146,7 @@
break;
case TRANSMATH_ATAN2:
MXQueryDouble y = null;
- XDMIterator input2 = subIters[0];
+ XDMIterator input2 = subIters[1];
TokenInterface inputToken2 = input2.next();
int type2 = Type.getEventTypeSubstituted(inputToken2.getEventType(), Context.getDictionary());
@@ -155,16 +155,16 @@
currentToken = Token.END_SEQUENCE_TOKEN;
return;
case Type.INTEGER:
- y = new MXQueryDouble(inputToken.getLong());
+ y = new MXQueryDouble(inputToken2.getLong());
break;
case Type.UNTYPED_ATOMIC:
case Type.UNTYPED:
- y = new MXQueryDouble(inputToken.getText());
+ y = new MXQueryDouble(inputToken2.getText());
break;
case Type.DOUBLE:
case Type.FLOAT:
case Type.DECIMAL:
- y = inputToken.getDouble();
+ y = inputToken2.getDouble();
break;
default:
throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+Type.getTypeQName(type, Context.getDictionary()), loc);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/model/Iterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/model/Iterator.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/model/Iterator.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -768,7 +768,7 @@
protected static XDMIterator getNodeIteratorOrContext(XDMIterator [] subIts, int pos,XQDynamicContext ctx, QueryLocation loc) throws MXQueryException,
DynamicException {
XDMIterator it;
- if (subIts != null && subIts.length == pos) {
+ if (subIts != null && subIts.length >= pos) {
it = subIts[pos-1];
} else {
VariableHolder contextVarHolder = ctx.getContextItem();
@@ -858,7 +858,7 @@
throws MXQueryException {
TokenInterface arg = source.next();
int aType = Type.getEventTypeSubstituted(arg.getEventType(),Context.getDictionary());
- if ( !(aType == Type.STRING ||aType == Type.UNTYPED_ATOMIC || aType == Type.END_SEQUENCE)) {
+ if ( !(Type.typePromoteableTo(aType, Type.STRING,Context.getDictionary()) ||aType == Type.UNTYPED_ATOMIC || aType == Type.END_SEQUENCE)) {
throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Single element of type "+"xs:string"+" expected", loc);
}
return arg.getText();
@@ -867,7 +867,7 @@
protected String getStringValue(XDMIterator source) throws MXQueryException {
TokenInterface arg = source.next();
int aType = Type.getEventTypeSubstituted(arg.getEventType(),Context.getDictionary());
- if ( !(aType == Type.STRING ||aType == Type.UNTYPED_ATOMIC )) {
+ if ( !(Type.typePromoteableTo(aType, Type.STRING,Context.getDictionary()) ||aType == Type.UNTYPED_ATOMIC )) {
throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Single element of type "+"xs:string"+" expected", loc);
}
return arg.getText();
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -399,7 +399,7 @@
if (index < queryLen) {
throw new StaticException(
ErrorCodes.E0003_STATIC_NOT_A_VALID_GRAMMAR_ELEMENT,
- "Error while parsing: could not parse query completely",
+ "Error while parsing: could not parse query completely, trailing part: '"+query.substring(index)+"'",
getCurrentLoc());
}
return result;
Modified: trunk/MXQuery/src/ch/ethz/mxquery/util/FileReader.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/util/FileReader.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/util/FileReader.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -33,7 +33,7 @@
public class FileReader {
public static String getFileContent(String uri, boolean xquery) throws MXQueryException{
- Reader ir = IOLib.getInput(uri, xquery, QueryLocation.OUTSIDE_QUERY_LOC);
+ Reader ir = IOLib.getInput(uri, xquery, null, QueryLocation.OUTSIDE_QUERY_LOC);
return getContents(ir);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/util/IOLib.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/util/IOLib.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery/src/ch/ethz/mxquery/util/IOLib.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -160,8 +160,9 @@
return encoding;
}
- public static Reader getInput (String toOpen, boolean xquery, QueryLocation loc) throws MXQueryException {
- String encoding = "utf-8";
+ public static Reader getInput (String toOpen, boolean xquery,String encoding, QueryLocation loc) throws MXQueryException {
+ if (encoding == null)
+ encoding = "utf-8";
InputStream ins = null;
URI uri;
try {
@@ -205,7 +206,7 @@
try {
ins = new FileInputStream(xml);
// snoop encoding
- encoding = "utf-8";
+ //encoding = "utf-8";
String tempEncoding = IOLib.snoopEncoding8bit(ins, xquery);
if (tempEncoding != null) {
encoding = tempEncoding;
Modified: trunk/MXQuery_Testing/XQTests/Queries/inserttest.xml
===================================================================
--- trunk/MXQuery_Testing/XQTests/Queries/inserttest.xml 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery_Testing/XQTests/Queries/inserttest.xml 2011-05-14 15:31:32 UTC (rev 4340)
@@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8' ?><doc>
-<NEW>2009-04-22T12:24:14.024+01:00</NEW><bla/><bla/><bla/><NEW>2011-04-28T12:45:40.129+01:00</NEW><NEW>2011-04-28T12:45:40.539+01:00</NEW><bla/></doc>
\ No newline at end of file
+<NEW>2009-04-22T12:24:14.024+01:00</NEW><bla/><bla/><bla/><NEW>2011-04-28T12:45:40.129+01:00</NEW><NEW>2011-04-28T12:45:40.539+01:00</NEW><bla/><NEW>2011-05-13T08:34:41.919+01:00</NEW><NEW>2011-05-13T08:34:42.747+01:00</NEW><bla/></doc>
\ No newline at end of file
Modified: trunk/MXQuery_Testing/XQTests/Sources/doc.xml
===================================================================
--- trunk/MXQuery_Testing/XQTests/Sources/doc.xml 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery_Testing/XQTests/Sources/doc.xml 2011-05-14 15:31:32 UTC (rev 4340)
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8' ?><catalog>
- <book id="bk101"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk101"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
@@ -8,7 +8,7 @@
<description>An in-depth look at creating applications
with XML.</description>
</book>
- <book id="bk102"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk102"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
@@ -18,7 +18,7 @@
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
- <book id="bk103"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk103"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
@@ -28,7 +28,7 @@
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
- <book id="bk104"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk104"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
@@ -39,7 +39,7 @@
for the inhabitants of London. Sequel to Maeve
Ascendant.</description>
</book>
- <book id="bk105"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk105"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
@@ -49,7 +49,7 @@
battle one another for control of England. Sequel to
Oberon's Legacy.</description>
</book>
- <book id="bk106"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk106"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
@@ -58,7 +58,7 @@
<description>When Carla meets Paul at an ornithology
conference, tempers fly as feathers get ruffled.</description>
</book>
- <book id="bk107"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk107"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
@@ -67,7 +67,7 @@
<description>A deep sea diver finds true love twenty
thousand leagues beneath the sea.</description>
</book>
- <book id="bk108"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk108"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
@@ -76,7 +76,7 @@
<description>An anthology of horror stories about roaches,
centipedes, scorpions and other insects.</description>
</book>
- <book id="bk109"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk109"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
@@ -86,7 +86,7 @@
Uncertainty Device, James Salway discovers the problems
of being quantum.</description>
</book>
- <book id="bk110"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk110"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
@@ -95,7 +95,7 @@
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.</description>
</book>
- <book id="bk111"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk111"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
@@ -105,7 +105,7 @@
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.</description>
</book>
- <book id="bk112"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
+ <book id="bk112"><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/><test/>
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
Added: trunk/MXQuery_Testing/XQTests/Sources/iso.txt
===================================================================
--- trunk/MXQuery_Testing/XQTests/Sources/iso.txt (rev 0)
+++ trunk/MXQuery_Testing/XQTests/Sources/iso.txt 2011-05-14 15:31:32 UTC (rev 4340)
@@ -0,0 +1,2 @@
+g\xE4nzlich
+fr\xF6hlich
\ No newline at end of file
Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/XQ11FunctionsTest.java
===================================================================
--- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/XQ11FunctionsTest.java 2011-05-14 13:30:29 UTC (rev 4339)
+++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/XQ11FunctionsTest.java 2011-05-14 15:31:32 UTC (rev 4340)
@@ -9,7 +9,7 @@
public void test_fn_round_half() throws Exception{
String query = "fn:round-half-to-even(<a>1.5</a>)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("2", resultBuffer.toString() );
};
@@ -17,32 +17,32 @@
public void test_fn_round_two_1() throws Exception{
String query = "fn:round(1,0)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("1", resultBuffer.toString() );
};
public void test_fn_round_two_2() throws Exception{
String query = "fn:round(1.511111,0) eq fn:round(1.511111)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("true", resultBuffer.toString());
};
public void test_fn_round_two_3() throws Exception{
String query = "fn:round(1.511111,1)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("1.5", resultBuffer.toString());
};
public void test_fn_round_two_4() throws Exception{
String query = "fn:round(1.511111,2)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("1.51", resultBuffer.toString());
};
public void test_string_join_one_1() throws Exception{
String query = "fn:string-join(('Hello','World'))";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("HelloWorld", resultBuffer.toString());
};
// add format-* functions
@@ -52,21 +52,21 @@
public void test_generate_id_1() throws Exception{
String query = "generate-id(<a/>) castable as xs:NCName";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("true", resultBuffer.toString() );
};
public void test_generate_id_2() throws Exception{
String query = "let $src := <a><b/><b/></a> return generate-id($src/b[1]) eq generate-id($src/b[2])";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("false", resultBuffer.toString() );
};
public void test_generate_id_3() throws Exception{
String query = "string-length(<a><b/><b/></a>/generate-id()) gt 0 ";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("true", resultBuffer.toString() );
};
@@ -74,28 +74,28 @@
public void test_math_pi_1() throws Exception{
String query = "math:pi()";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("3.141592653589793", resultBuffer.toString() );
};
public void test_math_sqrt_1() throws Exception{
String query = "math:sqrt(0)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("0", resultBuffer.toString() );
};
public void test_math_sqrt_2() throws Exception{
String query = "math:sqrt(-1)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("NaN", resultBuffer.toString() );
};
public void test_math_sqrt_3() throws Exception{
String query = "math:sqrt(16) eq 4";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("true", resultBuffer.toString() );
};
@@ -103,7 +103,7 @@
public void test_math_sqrt_4() throws Exception{
String query = "math:sqrt(xs:double('INF'))";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("INF", resultBuffer.toString() );
};
@@ -111,137 +111,216 @@
public void test_math_sin_1() throws Exception{
String query = "math:sin(0)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("0", resultBuffer.toString() );
};
public void test_math_sin_2() throws Exception{
String query = "math:sin(math:pi()) lt 2e-16";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("true", resultBuffer.toString() );
};
public void test_math_cos_1() throws Exception{
String query = "math:cos(0)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("1", resultBuffer.toString() );
};
public void test_math_cos_2() throws Exception{
String query = "math:cos(math:pi())";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("-1", resultBuffer.toString() );
};
public void test_math_tan_1() throws Exception{
String query = "math:tan(0)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("0", resultBuffer.toString() );
};
public void test_math_tan_2() throws Exception{
String query = "abs(1-math:tan(math:pi() div 4)) lt 2e-16";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("true", resultBuffer.toString() );
};
public void test_math_asin_1() throws Exception{
String query = "math:asin(0)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("0", resultBuffer.toString() );
};
public void test_math_asin_2() throws Exception{
String query = "abs(math:asin(1) - math:pi() div 2)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("0", resultBuffer.toString() );
};
public void test_math_acos_1() throws Exception{
String query = "abs(math:acos(0) - math:pi() div 2)";
doQuery(prepareQuery(query, false,false, false, true, false));
- //System.out.println(myBuffer.toString());
+ //System.out.println(resultBuffer.toString());
assertEquals("0", resultBuffer.toString() );
};
public void test_math_acos_2() throws Exception{
String query = "math:acos(...
[truncated message content] |