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: <pm_...@us...> - 2011-05-14 13:30:36
|
Revision: 4339 http://mxquery.svn.sourceforge.net/mxquery/?rev=4339&view=rev Author: pm_fischer Date: 2011-05-14 13:30:29 +0000 (Sat, 14 May 2011) Log Message: ----------- delete dom-implementation-registry.jar when building for Java 1.4 Modified Paths: -------------- trunk/MXQuery_Testing/build.xml Modified: trunk/MXQuery_Testing/build.xml =================================================================== --- trunk/MXQuery_Testing/build.xml 2011-05-14 13:29:59 UTC (rev 4338) +++ trunk/MXQuery_Testing/build.xml 2011-05-14 13:30:29 UTC (rev 4339) @@ -56,6 +56,7 @@ <delete dir="${src.dir}/ch/ethz/mxquery/test/dmcq"/> <delete dir="${src.dir}/ch/ethz/mxquery/test/pattern"/> <delete dir="${src.dir}/ch/ethz/mxquery/smstest"/> + <delete file="${resources.dir}/dom-implementation-registry.jar"/> </target> <target name="test" depends="compile" > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2011-05-14 13:30:06
|
Revision: 4338 http://mxquery.svn.sourceforge.net/mxquery/?rev=4338&view=rev Author: pm_fischer Date: 2011-05-14 13:29:59 +0000 (Sat, 14 May 2011) Log Message: ----------- do not use complete subtype substitution in native function calls, extend with Integer and byte types Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-13 21:42:26 UTC (rev 4337) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-14 13:29:59 UTC (rev 4338) @@ -29,7 +29,6 @@ import ch.ethz.mxquery.exceptions.ErrorCodes; import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; -import ch.ethz.mxquery.functions.fn.DataValuesIterator; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.EmptySequenceIterator; import ch.ethz.mxquery.model.Iterator; @@ -77,12 +76,21 @@ // For now, just take exactly a single value if (tok.getEventType()==Type.END_SEQUENCE || subIters[i].next().getEventType() != Type.END_SEQUENCE) throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Expected a single item", loc); - int type = Type.getEventTypeSubstituted(tok.getEventType(), Context.getDictionary()); + int type = tok.getEventType();//Type.getEventTypeSubstituted(tok.getEventType(), Context.getDictionary()); switch (type) { case Type.DOUBLE: invocationParams[i] = new Double(tok.getDouble().getValue()); invocationParamsTypes[i] = Double.TYPE; break; + case Type.INTEGER: + case Type.INT: + invocationParams[i] = new Integer((int)tok.getLong()); + invocationParamsTypes[i] = Integer.TYPE; + break; + case Type.BYTE: + invocationParams[i] = new Byte((byte)tok.getLong()); + invocationParamsTypes[i] = Byte.TYPE; + break; case Type.STRING: case Type.ANY_URI: invocationParams[i] = new String(tok.getText()); Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java =================================================================== --- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java 2011-05-13 21:42:26 UTC (rev 4337) +++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java 2011-05-14 13:29:59 UTC (rev 4338) @@ -46,5 +46,17 @@ assertEquals("false", resultBuffer.toString().trim() ); }; + public void test_int_arg() throws Exception{ + String query = "declare namespace jint ='java:java.lang.Integer'; jint:bitCount(42)"; + doQuery(prepareQuery(query, false,false, false, false, false)); + System.out.println(resultBuffer.toString()); + assertEquals("3", resultBuffer.toString().trim() ); + }; + public void test_byte_arg() throws Exception{ + String query = "declare namespace jint ='java:java.lang.Byte'; jint:toString(xs:byte(42))"; + doQuery(prepareQuery(query, false,false, false, false, false)); + System.out.println(resultBuffer.toString()); + assertEquals("42", resultBuffer.toString().trim() ); + }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2011-05-13 21:42:33
|
Revision: 4337 http://mxquery.svn.sourceforge.net/mxquery/?rev=4337&view=rev Author: timchurch Date: 2011-05-13 21:42:26 +0000 (Fri, 13 May 2011) Log Message: ----------- - Generate XML file from Android contacts info - Require min Android SDK version 8 (2.2) Modified Paths: -------------- trunk/MXQuery_Android_App/AndroidManifest.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-13 18:18:29 UTC (rev 4336) +++ trunk/MXQuery_Android_App/AndroidManifest.xml 2011-05-13 21:42:26 UTC (rev 4337) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="ch.ethz.mxquery.android" +<manifest package="ch.ethz.mxquery.android" android:versionCode="1" - android:versionName="1.0"> + 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> - <application android:icon="@drawable/icon" android:label="@string/app_name"> + <application android:icon="@drawable/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"/> 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-13 18:18:29 UTC (rev 4336) +++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-13 21:42:26 UTC (rev 4337) @@ -1,9 +1,17 @@ package ch.ethz.mxquery.android; +import java.io.BufferedReader; import java.io.BufferedWriter; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.StringWriter; +import org.xmlpull.v1.XmlSerializer; + import android.app.Activity; import android.app.Dialog; import android.app.ProgressDialog; @@ -12,8 +20,12 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.database.Cursor; +import android.net.Uri; import android.os.Bundle; import android.os.IBinder; +import android.provider.ContactsContract; +import android.util.Xml; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; @@ -46,6 +58,7 @@ public static final String STATE_CHANGE_SETTINGS = "STATE_CHANGE_SETTINGS"; public static final int QUERY_RUNNING_DIALOG = 1; + public static final String UNDEFINED_LABEL = "Undefined"; protected Dialog onCreateDialog(int id) { ProgressDialog dialog = new ProgressDialog(mActivity); @@ -88,6 +101,7 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + /* MXQuery.init(this); // set up sample file for testing fn:doc() @@ -101,6 +115,7 @@ } catch (Exception e) { e.printStackTrace(); } + */ setContentView(R.layout.main); mButton = (Button) findViewById(R.id.button); @@ -167,6 +182,10 @@ runQueryOnService(mInputView.getText().toString()); } }); + + //TESTING contacts XML generation + generateContactsXML(); + printContactsXML(); /* * The following is a code to test reading a query from a static file. @@ -329,4 +348,192 @@ }); } + /** + * 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"); + serializer.startTag(null, "_ID"); + serializer.text(id); + serializer.endTag(null, "_ID"); + serializer.startTag(null, "LOOKUP_KEY"); + serializer.text(lookupKey); + serializer.endTag(null, "LOOKUP_KEY"); + serializer.startTag(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"); + } + if(lastTimeContacted != null) { + 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) { + 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"); + } + + //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"); + } + + 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; + 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) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-13 18:18:36
|
Revision: 4336 http://mxquery.svn.sourceforge.net/mxquery/?rev=4336&view=rev Author: maxspeicher Date: 2011-05-13 18:18:29 +0000 (Fri, 13 May 2011) Log Message: ----------- - added 2 new queries - added batch script for installing APK on emulator Modified Paths: -------------- trunk/MXQuery_Android_App/res/layout/main.xml trunk/MXQuery_Android_App/res/values/strings.xml trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java Added Paths: ----------- trunk/MXQuery_Android_App/install_apk.bat Added: trunk/MXQuery_Android_App/install_apk.bat =================================================================== --- trunk/MXQuery_Android_App/install_apk.bat (rev 0) +++ trunk/MXQuery_Android_App/install_apk.bat 2011-05-13 18:18:29 UTC (rev 4336) @@ -0,0 +1,2 @@ +adb uninstall ch.ethz.mxquery.android +adb install ./bin/MXQuery_Android_app.apk Modified: trunk/MXQuery_Android_App/res/layout/main.xml =================================================================== --- trunk/MXQuery_Android_App/res/layout/main.xml 2011-05-13 18:16:48 UTC (rev 4335) +++ trunk/MXQuery_Android_App/res/layout/main.xml 2011-05-13 18:18:29 UTC (rev 4336) @@ -3,7 +3,8 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true"> - <LinearLayout android:layout_width="fill_parent" + <LinearLayout android:id="@+id/linearLayout" + android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/sampleQueryLabel" Modified: trunk/MXQuery_Android_App/res/values/strings.xml =================================================================== --- trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-13 18:16:48 UTC (rev 4335) +++ trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-13 18:18:29 UTC (rev 4336) @@ -17,6 +17,8 @@ <item>@string/namespace</item> <item>@string/fibonacci</item> <item>@string/native_java</item> + <item>@string/manipulate_ui</item> + <item>@string/android_doc</item> </string-array> <string name="hello_world">Hello World</string> @@ -26,6 +28,8 @@ <string name="namespace">Namespace</string> <string name="fibonacci">Fibonacci</string> <string name="native_java">Native Java</string> + <string name="manipulate_ui">Manipulate UI</string> + <string name="android_doc">android:doc()</string> <string name="hello_world_xquery">\"Hello World\"</string> <string name="addition_xquery">5+5</string> @@ -57,5 +61,15 @@ declare namespace m = \"java:java.lang.Math\";\n m:random() </string> + <string name="manipulate_ui_xquery"> + declare namespace m = \"java:ch.ethz.mxquery.android.MXQuery\";\n + declare namespace a = \"java:ch.ethz.mxquery.android.Start\";\n + let $x := m:getActivity()\n + return a:updateUiFromXquery($x, \"Hello XQuery!\") + </string> + <string name="android_doc_xquery"> + declare namespace android = \"java:ch.ethz.mxquery.android.MXQuery\";\n + 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-13 18:16:48 UTC (rev 4335) +++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-13 18:18:29 UTC (rev 4336) @@ -1,5 +1,9 @@ package ch.ethz.mxquery.android; +import java.io.BufferedWriter; +import java.io.OutputStreamWriter; +import java.io.StringWriter; + import android.app.Activity; import android.app.Dialog; import android.app.ProgressDialog; @@ -20,6 +24,12 @@ import android.widget.Spinner; import android.widget.TextView; import ch.ethz.mxquery.android.MXQueryService.MXQueryServiceBinder; +import ch.ethz.mxquery.xqj.MXQueryXQDataSource; +import ch.ethz.repackaged.xquery.XQConnection; +import ch.ethz.repackaged.xquery.XQDataSource; +import ch.ethz.repackaged.xquery.XQException; +import ch.ethz.repackaged.xquery.XQExpression; +import ch.ethz.repackaged.xquery.XQSequence; public class Start extends Activity { @@ -31,6 +41,8 @@ // private XQueryAsyncTask mTask; protected MXQueryService mService; protected boolean mIsBound = false; + + protected XQDataSource xqjd = new MXQueryXQDataSource(); public static final String STATE_CHANGE_SETTINGS = "STATE_CHANGE_SETTINGS"; public static final int QUERY_RUNNING_DIALOG = 1; @@ -76,6 +88,20 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + MXQuery.init(this); + + // set up sample file for testing fn:doc() + try { + BufferedWriter save = new BufferedWriter(new OutputStreamWriter(openFileOutput("test.xml", 0))); + save.write( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<test><bla/></test>" + ); + save.close(); + } catch (Exception e) { + e.printStackTrace(); + } + setContentView(R.layout.main); mButton = (Button) findViewById(R.id.button); mSpinner = (Spinner) findViewById(R.id.sample_query_spinner); @@ -108,6 +134,10 @@ mInputView.setText(getString(R.string.fibonacci_xquery)); } else if (item.equals(getString(R.string.native_java))) { 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.android_doc))) { + mInputView.setText(getString(R.string.android_doc_xquery)); } } @@ -157,7 +187,24 @@ * e.printStackTrace(); }/* */ } + + protected String runQuery(String query) { + StringWriter result = new StringWriter(); + + 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(); + } + protected void runQueryOnService(String query) { mResultView.setText(""); mActivity.showDialog(QUERY_RUNNING_DIALOG); @@ -274,4 +321,12 @@ mActivity.removeDialog(QUERY_RUNNING_DIALOG); } + public void updateUiFromXquery(final String text) { + runOnUiThread(new Runnable() { + public void run() { + mButton.setText(text); + } + }); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-13 18:16:54
|
Revision: 4335 http://mxquery.svn.sourceforge.net/mxquery/?rev=4335&view=rev Author: maxspeicher Date: 2011-05-13 18:16:48 +0000 (Fri, 13 May 2011) Log Message: ----------- - added java.lang.CharSequence to Java/XQuery type mapping - added helper class (MXQuery.java) for passing the Android application context to the library - changed IOLib.java to use Android-specific IO (not working yet) Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java Added Paths: ----------- trunk/MXQuery/android/src/ch/ethz/mxquery/android/ trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java trunk/MXQuery/android/src/ch/ethz/mxquery/util/ trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java Added: trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java =================================================================== --- trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java (rev 0) +++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java 2011-05-13 18:16:48 UTC (rev 4335) @@ -0,0 +1,59 @@ +package ch.ethz.mxquery.android; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; + +import android.app.Activity; +import android.content.Context; +import android.widget.Button; +import android.widget.TextView; + +public class MXQuery { + + private static Context ctx; + private static Activity act; + + public static void init(Activity act) { + MXQuery.ctx = act.getApplicationContext(); + MXQuery.act = act; + } + + public static Context getContext() { + return ctx; + } + + public static Activity getActivity() { + return act; + } + + public static String doc(String fileName) { + String result = ""; + + try { + BufferedReader in = new BufferedReader(new InputStreamReader( + ctx.openFileInput(fileName))); + String line; + + while ((line = in.readLine()) != null) { + result += line; + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return result; + } + + public static Button getButton(int id) { + return (Button) act.findViewById(id); + } + + public static TextView getTextView(int id) { + return (TextView) act.findViewById(id); + } + +} Added: trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java =================================================================== --- trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java (rev 0) +++ trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-05-13 18:16:48 UTC (rev 4335) @@ -0,0 +1,263 @@ +/* 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.util; + +import java.io.BufferedInputStream; +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 java.io.Reader; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +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; +import ch.ethz.mxquery.exceptions.QueryLocation; + +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; + 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); + } + } + + } 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 { + if (in != null) + try { + in.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (out != null) + try { + out.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * Check the file encoding using a 8bit representation + * @param ins Input stream to check + * @param xquery snoop an xquery file, not an XML file + * @return Encoding String if detected, otherwise null + * @throws UnsupportedEncodingException + * @throws IOException + */ + + public static final String snoopEncoding8bit(InputStream ins, boolean xquery) throws UnsupportedEncodingException, IOException { + String encoding = null; + String typeToSearch = "?xml"; + if (xquery) + typeToSearch = "xquery"; + + // Check all the encoding that are 8bit-oriented for the normal characters + InputStreamReader rs = new InputStreamReader(ins, "us-ascii"); + char [] cbuf = new char[1025]; + int bytes = rs.read(cbuf, 0, 1024); + if (bytes > 0 ) { + String startLine = new String(cbuf); + if (startLine.indexOf(typeToSearch) >= 0) { + int encodingPos; + if (!xquery) { + encodingPos = startLine.indexOf("encoding=\""); + if (encodingPos > 0) { + String tempEncoding = startLine.substring(encodingPos + 10); + int endEncoding = tempEncoding.indexOf('"'); + encoding = tempEncoding.substring(0, endEncoding); + } + } + else { + int xqPos = startLine.indexOf("xquery"); + if (xqPos >= 0 ) { + encodingPos = startLine.indexOf("encoding", xqPos+1); + if (encodingPos > 0) { + int sep = startLine.indexOf(";", encodingPos + 8); + if (sep > 0) { + String tempEncoding = startLine.substring(encodingPos + 8, sep); + char delim = '"'; + int startDelim = tempEncoding.indexOf(delim); + int endDelim = tempEncoding.indexOf(delim,startDelim+1); + if (endDelim >=0 && endDelim > startDelim+1) + encoding = tempEncoding.substring(startDelim+1, endDelim); + } + } + } + } + } + } + return encoding; + } + + /** + * Check the file encoding using a 16bit representation + * @param ins Input stream to check + * @param xquery TODO + * @return Encoding String if detected, otherwise null + * @throws UnsupportedEncodingException + * @throws IOException + */ + + public static final String snoopEncoding16bit(InputStream ins, boolean xquery) throws UnsupportedEncodingException, IOException { + + String encoding = null; + String typeToSearch = "?xml"; + if (xquery) + typeToSearch = "xquery"; + + InputStreamReader rs = new InputStreamReader(ins, "utf-16"); + char [] cbuf = new char[1025]; + int bytes = rs.read(cbuf, 0, 1024); + if (bytes > 0 ) { + String startLine = new String(cbuf); + if (startLine.indexOf(typeToSearch) >= 0) { + encoding = "utf-16"; + } + } + return encoding; + } + + public static Reader getInput (String toOpen, boolean xquery, QueryLocation loc) throws MXQueryException { + String encoding = "utf-8"; + InputStream ins = null; + URI uri; + try { + uri = new URI(toOpen); + } catch (URISyntaxException e) { + throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC, "Invalid URI given to fn:doc", loc); + } + 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"; + BufferedInputStream bufs = new BufferedInputStream(ins); + bufs.mark(16384); + String tempEncoding = IOLib.snoopEncoding8bit(bufs, xquery); + if (tempEncoding != null) { + encoding = tempEncoding; + } else { + bufs.reset(); + bufs.mark(16384); + tempEncoding = IOLib.snoopEncoding16bit(bufs, xquery); + if (tempEncoding != null) { + encoding = tempEncoding; + } + } + bufs.reset(); + 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); + } + } 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); + } + } + } + + 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); + return new PrintStream(outw,false,encoding); + } + + public static String getSystemBaseUri() { + String curDir = System.getProperty("user.dir"); + File fl = new File(curDir); + return fl.toURI().toString(); + } +} Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-12 16:21:56 UTC (rev 4334) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-13 18:16:48 UTC (rev 4335) @@ -1,6 +1,7 @@ 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; @@ -73,6 +74,7 @@ public static Context getNativeMethods(String className) throws MXQueryException{ Context ctx = new Context(); + try { Class toImport = Class.forName(className); @@ -151,6 +153,29 @@ } } + + 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(); @@ -181,7 +206,9 @@ 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); + 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")) Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-12 16:21:56 UTC (rev 4334) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-13 18:16:48 UTC (rev 4335) @@ -15,6 +15,7 @@ package ch.ethz.mxquery.iterators; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Vector; @@ -54,7 +55,6 @@ this.native_function = function; this.resultSeqTypeIt = returnSeqTypeIt; //this.paramNames = paramNames; - this.native_function = function; this.methodName = methodName; this.returnType = returnType; this.paramTypes = paramTypes; @@ -114,14 +114,20 @@ try { Method meth = null; + Field field = null; Object res; if (methodName.equals("new")) { Constructor con = native_function.getConstructor(invocationParamsTypes); res = con.newInstance(invocationParams); } else { - meth = native_function.getMethod(methodName, invocationParamsTypes); - res = meth.invoke(instanceToCall, invocationParams); + try { + meth = native_function.getMethod(methodName, invocationParamsTypes); + res = meth.invoke(instanceToCall, invocationParams); + } catch (NoSuchMethodException e) { + field = native_function.getField(methodName); + res = field.get(instanceToCall); + } } try { @@ -135,22 +141,18 @@ this.current = new TokenIterator(context, wrap, loc, false); } } catch (SecurityException e) { - // TODO Auto-generated catch block e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { - // TODO Auto-generated catch block e.printStackTrace(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2011-05-12 16:22:02
|
Revision: 4334 http://mxquery.svn.sourceforge.net/mxquery/?rev=4334&view=rev Author: pm_fischer Date: 2011-05-12 16:21:56 +0000 (Thu, 12 May 2011) Log Message: ----------- avoid spurious cast instantiation causing regressions Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/TypeInfo.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/TypeInfo.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/TypeInfo.java 2011-05-12 11:17:27 UTC (rev 4333) +++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/TypeInfo.java 2011-05-12 16:21:56 UTC (rev 4334) @@ -153,7 +153,7 @@ } public boolean isUndefined(){ - return (type == UNDEFINED); + return (type == Type.ITEM && occurID == Type.OCCURRENCE_IND_ZERO_OR_MORE); } public TypeInfo [] getParameterTypes() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2011-05-12 11:17:34
|
Revision: 4333 http://mxquery.svn.sourceforge.net/mxquery/?rev=4333&view=rev Author: pm_fischer Date: 2011-05-12 11:17:27 +0000 (Thu, 12 May 2011) Log Message: ----------- Fix an Android build problem Modified Paths: -------------- trunk/MXQuery/android/src/ch/ethz/mxquery/query/parser/SchemaParser.java Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/query/parser/SchemaParser.java =================================================================== --- trunk/MXQuery/android/src/ch/ethz/mxquery/query/parser/SchemaParser.java 2011-05-12 11:11:34 UTC (rev 4332) +++ trunk/MXQuery/android/src/ch/ethz/mxquery/query/parser/SchemaParser.java 2011-05-12 11:17:27 UTC (rev 4333) @@ -300,7 +300,7 @@ // System.out.println(typeDef.getName()+":"+((XSConstructorIterator)it).getMfacetsList()); } - Function function = new Function(null, signature, it, null, -1); + Function function = new Function(null, signature, it, null, null); ctx.addFunction(function); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2011-05-12 11:11:40
|
Revision: 4332 http://mxquery.svn.sourceforge.net/mxquery/?rev=4332&view=rev Author: pm_fischer Date: 2011-05-12 11:11:34 +0000 (Thu, 12 May 2011) Log Message: ----------- Adapt new methods in GWT Function Gallery to HOF-induced changes Modified Paths: -------------- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-12 11:10:38 UTC (rev 4331) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-12 11:11:34 UTC (rev 4332) @@ -471,7 +471,7 @@ ch.ethz.mxquery.functions.b.JsEval iter = new ch.ethz.mxquery.functions.b.JsEval(); iter.setContext(context, false); - type = -1; + type = null; function = new Function( null,signature, @@ -498,7 +498,7 @@ ch.ethz.mxquery.functions.b.Timer iter = new ch.ethz.mxquery.functions.b.Timer(); iter.setContext(context, false); - type = -1; + type = null; function = new Function( null,signature, @@ -519,7 +519,7 @@ ch.ethz.mxquery.functions.b.GetCookieNames iter = new ch.ethz.mxquery.functions.b.GetCookieNames(); iter.setContext(context, false); - type = -1; + type = null; function = new Function( null,signature, @@ -543,7 +543,7 @@ ch.ethz.mxquery.functions.b.GetCookie iter = new ch.ethz.mxquery.functions.b.GetCookie(); iter.setContext(context, false); - type = -1; + type = null; function = new Function( null,signature, @@ -567,7 +567,7 @@ ch.ethz.mxquery.functions.b.RemoveCookie iter = new ch.ethz.mxquery.functions.b.RemoveCookie(); iter.setContext(context, false); - type = -1; + type = null; function = new Function( null,signature, @@ -594,7 +594,7 @@ ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie(); iter.setContext(context, false); - type = -1; + type = null; function = new Function( null,signature, @@ -624,7 +624,7 @@ ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie(); iter.setContext(context, false); - type = -1; + type = null; function = new Function( null,signature, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2011-05-12 11:10:50
|
Revision: 4331 http://mxquery.svn.sourceforge.net/mxquery/?rev=4331&view=rev Author: pm_fischer Date: 2011-05-12 11:10:38 +0000 (Thu, 12 May 2011) Log Message: ----------- Merge HOF implementation Modified Paths: -------------- trunk/MXQuery/midp_src/ch/ethz/mxquery/query/webservice/WSDLHandler.java trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/Type.java trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/TypeInfo.java trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/NamedToken.java trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/QNameToken.java trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/Token.java trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/TokenInterface.java trunk/MXQuery/src/ch/ethz/mxquery/exceptions/ErrorCodes.java trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml trunk/MXQuery/src/ch/ethz/mxquery/functions/Function.java trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionGallery.java trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionSignature.java trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Abs.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Deep_equal.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNString.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Node_Name.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Put.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubString.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubstringAfter.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubstringBefore.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Translate.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/UpperCase.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/SequenceTypeIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCall.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/VariableIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java trunk/MXQuery/src/ch/ethz/mxquery/model/Iterator.java trunk/MXQuery/src/ch/ethz/mxquery/model/XDMIterator.java trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java trunk/MXQuery/src/ch/ethz/mxquery/query/parser/SEParser.java trunk/MXQuery/src/ch/ethz/mxquery/query/parser/SchemaParser.java trunk/MXQuery/src/ch/ethz/mxquery/query/webservice/WSDLGenerator.java trunk/MXQuery/src/ch/ethz/mxquery/query/webservice/WSDLHandler.java trunk/MXQuery/src/ch/ethz/mxquery/query/webservice/WSServer.java trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/StreamStoreInput.java trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java trunk/MXQuery/src/examples/ExternalFunctionExample.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/Function.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/TypeTest.java Added Paths: ----------- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/FunctionItemToken.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Function_arity.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Function_name.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/ClosureIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/FunctionItemWrapperIterator.java Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/query/webservice/WSDLHandler.java =================================================================== --- trunk/MXQuery/midp_src/ch/ethz/mxquery/query/webservice/WSDLHandler.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/midp_src/ch/ethz/mxquery/query/webservice/WSDLHandler.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -201,7 +201,7 @@ params[i] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE); } FunctionSignature signature = new FunctionSignature(functionName,params,FunctionSignature.EXTERNAL_FUNCTION,XDMIterator.EXPR_CATEGORY_SEQUENTIAL,true,false); - Function function = new Function(null,signature,wf,null,-1); + Function function = new Function(null,signature,wf,null,null); context.addFunction(function, true, true); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/Type.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/Type.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/Type.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -44,6 +44,8 @@ public final static int ITEM = 0; + public final static int FUNCTION_ITEM = 1; + public final static int NODE = 2; // 0000000000000000000000000000010 /** Token types */ @@ -197,6 +199,9 @@ public static final int TYPE_NK_EMPTY_SEQ_TEST = 64; /** occurrence indicators consts */ + + public final static int OCCURRENCE_IND_EMPTY = 0; + public final static int OCCURRENCE_IND_EXACTLY_ONE = 1; public final static int OCCURRENCE_IND_ZERO_OR_ONE = 2; @@ -625,7 +630,9 @@ case END_SEQUENCE: q = new QName(null, "END_SEQUENCE"); break; - + case FUNCTION_ITEM: + q = new QName(null, "function(*)"); + break; default: throw new RuntimeException("Incorrect type passed. Type " + type + " is not supported in method getTypeQName"); } @@ -1093,4 +1100,33 @@ public static boolean isNilled(int type) { return ((type & MASK_CHECK_NILLABLE) == MASK_CHECK_NILLABLE); } + /** + * Check if aocc is covered by bocc, as in XQ 3.0: 2.5.5.1 The SequenceType Subtype Judgement + * @param aocc Occurence indicator that needs to be checked + * @param bocc Occurence indicator that is provided + * @return true if aocc is contained by bocc, false otherwise + */ + public static boolean isOccCompatible(int aocc, int bocc) { + if (aocc == bocc) + return true; + switch (bocc) { + case Type.OCCURRENCE_IND_EMPTY: + return false; + case Type.OCCURRENCE_IND_EXACTLY_ONE: + return false; + case Type.OCCURRENCE_IND_ZERO_OR_ONE: + if (aocc == Type.OCCURRENCE_IND_ZERO_OR_MORE || aocc==Type.OCCURRENCE_IND_ONE_OR_MORE) + return false; + else return true; + case Type.OCCURRENCE_IND_ZERO_OR_MORE: + return true; + case Type.OCCURRENCE_IND_ONE_OR_MORE: + if (aocc == Type.OCCURRENCE_IND_EXACTLY_ONE) + return true; + else return false; + } + // TODO: Infinite types + return true; + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/TypeInfo.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/TypeInfo.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/TypeInfo.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -31,6 +31,8 @@ private int occurID = UNDEFINED; private XQName qn = null; private int typeAnnotation =UNDEFINED; + private TypeInfo [] paramTypes = null; + private TypeInfo returnType=null; private final static int MASK_GET_START_TAG = Integer.parseInt("0001100000000000000000000000000", 2); private final static int MASK_CLEAN_START_TAG = Integer.parseInt("1110011111111111111111111111111", 2); @@ -56,6 +58,14 @@ this.qn = name; this.typeAnnotation = typeAn; } + + public TypeInfo(int type, int occurIndID, TypeInfo[] params,TypeInfo retType) { + this.type = type; + this.occurID = occurIndID; + this.paramTypes = params; + this.returnType = retType; + } + public int getTypeAnnotation() { int t; @@ -67,8 +77,9 @@ t = this.type & MASK_CLEAN_START_TAG; } - if (t == 0) return -1; - else return t; + if (t == 0) return Type.ANY_TYPE; + else + return t; //return typeAnnotation; } @@ -145,11 +156,21 @@ return (type == UNDEFINED); } + public TypeInfo [] getParameterTypes() { + return paramTypes; + } + + public TypeInfo getReturnType() { + return returnType; + } + public TypeInfo copy() { if (typeAnnotation != UNDEFINED) return new TypeInfo(type,occurID,qn,typeAnnotation); + else if (type ==Type.FUNCTION_ITEM) + return new TypeInfo(type, occurID, paramTypes, returnType); else - return new TypeInfo(type, occurID,qn); + return new TypeInfo(type, occurID,qn); } public String toString() { Added: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/FunctionItemToken.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/FunctionItemToken.java (rev 0) +++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/FunctionItemToken.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -0,0 +1,54 @@ +package ch.ethz.mxquery.datamodel.xdm; + +import java.util.Enumeration; + +import ch.ethz.mxquery.datamodel.QName; +import ch.ethz.mxquery.datamodel.types.Type; +import ch.ethz.mxquery.functions.Function; +import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.Hashtable; + +public class FunctionItemToken extends Token{ + Function func; + Hashtable closure; + public FunctionItemToken(Function fun) { + super(Type.FUNCTION_ITEM,null,null); + func = fun; + } + public FunctionItemToken(Function fun, Hashtable closure) { + super(Type.FUNCTION_ITEM,null,null); + func = fun; + this.closure = closure; + } + + public long getLong() { + return func.getFunctionSignature().getArity(); + } + public QName getQNameTokenValue() { + return (QName)func.getFunctionSignature().getName(); + } + public Function getFunction() { + return func; + } + public TokenInterface copy() { + return new FunctionItemToken(func,closure); + } + public QName [] getClosureVarNames() { + if (closure != null) { + QName [] res = new QName[closure.size()]; + Enumeration varNames = closure.keys(); + int i=0; + while (varNames.hasMoreElements()) + res[i++] = (QName) varNames.nextElement(); + return res; + } else return new QName[]{}; + } + + public XDMIterator getClosureValue(QName qn) { + return (XDMIterator) closure.get(qn); + } + + public FunctionItemToken coerce(Function fun) { + return new FunctionItemToken(fun, closure); + } +} Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/NamedToken.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/NamedToken.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/NamedToken.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -32,8 +32,6 @@ public String [] getIDREFS(); - public String getPrefix(); - public NamedToken copy(XQName newName) throws MXQueryException; public NamedToken copyStrip(); Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/QNameToken.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/QNameToken.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/QNameToken.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -19,7 +19,7 @@ import ch.ethz.mxquery.datamodel.QName; import ch.ethz.mxquery.datamodel.types.Type; -public final class QNameToken extends Token { +public class QNameToken extends Token { private final QName value; public QNameToken(Identifier id, QName value) { @@ -29,25 +29,15 @@ public QNameToken(QNameToken token) { super(token); - this.value = token.getQName(); + this.value = token.getQNameTokenValue(); } - - public QName getQName() { - return this.value; - } - - + /* (non-Javadoc) * @see ch.ethz.mxquery.util.tokens.Token#getNS() */ public String getNS() { return value.getNamespaceURI(); } - - public void setNS(String uri) { - value.setNamespaceURI(uri); - } - public QName getQNameTokenValue() { return this.value; Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/Token.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/Token.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/Token.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -153,6 +153,14 @@ } /* (non-Javadoc) + * @see ch.ethz.mxquery.datamodel.xdm.TokenInterface#getLocal() + */ + public String getPrefix() { + return null; + } + + + /* (non-Javadoc) * @see ch.ethz.mxquery.datamodel.xdm.TokenInterface#setId(ch.ethz.mxquery.datamodel.Identifier) */ public void setNodeId(Identifier id) throws MXQueryException{ Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/TokenInterface.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/TokenInterface.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/TokenInterface.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -30,6 +30,8 @@ public abstract String getNS(); public abstract String getLocal(); + + public abstract String getPrefix(); /** * Assigns a node ID to this node * While tokens are meant to be immutable, we make an exception Modified: trunk/MXQuery/src/ch/ethz/mxquery/exceptions/ErrorCodes.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/exceptions/ErrorCodes.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/exceptions/ErrorCodes.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -230,6 +230,9 @@ public final static QName F0033_REGULAR_EXPRESSION_MATCHES_EMPTY = new QName(XQStaticContext.URI_ERR,"err","FORX0003"); public final static QName F0034_INVALID_REPLACEMENT_STRING = new QName(XQStaticContext.URI_ERR,"err","FORX0004"); public final static QName F0035_AGUMENT_NOD_NO_TYPED_VALUE = new QName(XQStaticContext.URI_ERR,"err","FOTY0012"); + public final static QName F0036_FUNCTION_ITEM_AT_FN_DATA = new QName(XQStaticContext.URI_ERR,"err","FOTY0013"); + public final static QName F0037_FUNCTION_ITEM_AT_FN_STRING = new QName(XQStaticContext.URI_ERR,"err","FOTY0014"); + public final static QName F0038_FUNCTION_ITEM_AT_DEEP_EQUAL = new QName(XQStaticContext.URI_ERR,"err","FOTY0015"); // Serializer error codes public final static QName S0001_ATTRIBUTE_OR_NAMESPACE_NOT_ALLOWED_HERE = new QName(XQStaticContext.URI_ERR,"err","SENR0001"); Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -175,7 +175,7 @@ TypeInfo requestElement = new TypeInfo(Type.START_TAG, Type.OCCURRENCE_IND_EXACTLY_ONE,requestName); - SequenceTypeIterator sq = new SequenceTypeIterator(requestElement, true, false, childContext, loc); + SequenceTypeIterator sq = new SequenceTypeIterator(requestElement, true, false, childContext, loc, false); sq.setSubIters(subIters[0]); Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/FG.xml 2011-05-12 11:10:38 UTC (rev 4331) @@ -388,6 +388,20 @@ <className>Floor</className> </functionDescription> <functionDescription> + <functionName>function-name</functionName> + <parameters> + <paramType>function(*)</paramType> + </parameters> + <className>Function_name</className> + </functionDescription> + <functionDescription> + <functionName>function-arity</functionName> + <parameters> + <paramType>function(*)</paramType> + </parameters> + <className>Function_arity</className> + </functionDescription> + <functionDescription> <functionName>generate-id</functionName> <parameters> <paramType>node()</paramType> Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/Function.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/Function.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/Function.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -19,6 +19,7 @@ import ch.ethz.mxquery.contextConfig.Context; 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; @@ -38,20 +39,20 @@ protected String className; - protected FunctionSignature signature; + FunctionSignature signature; protected XDMIterator iter; - int returnType = -1; + TypeInfo returnType = null; String operation = null; public Function(String className, FunctionSignature signature, - XDMIterator iter, String op, int dataType) { + XDMIterator iter, String op, TypeInfo retDataType) { this.className = className; this.iter = iter; this.signature = signature; this.operation = op; - this.returnType = dataType; + this.returnType = retDataType; if (iter != null) return; @@ -78,8 +79,8 @@ public Function getAsExternalFunction(String prefix) { QName fName = new QName(signature.getName().getNamespaceURI(), prefix, signature.getName().getLocalPart()); - FunctionSignature newSig = new FunctionSignature(fName, signature - .getParameterTypes(), FunctionSignature.EXTERNAL_FUNCTION, + FunctionSignature newSig = new FunctionSignature(fName, signature.paramTypes + , FunctionSignature.EXTERNAL_FUNCTION, signature.getExpressionCategory(), false, true); Function func = new Function(className, newSig, iter, operation, returnType); return func; @@ -116,9 +117,8 @@ * Get the signature of this function * * @return a copy of the signature - * @throws MXQueryException */ - public FunctionSignature getFunctionSignature() throws MXQueryException { + public FunctionSignature getFunctionSignature() { if (signature != null) { return signature.copy(); } else { @@ -151,12 +151,12 @@ try { XDMIterator function = (XDMIterator) (Class.forName(className) .newInstance()); - if (operation != null || returnType != -1) { + if (operation != null || returnType != null) { RequestTypeMulti mult = (RequestTypeMulti)function; if (operation != null) mult.setOperation(operation); - if (returnType != -1) - mult.setReturnType(returnType); + if (returnType != null) + mult.setReturnType(returnType.getType()); } return function; } catch (ClassNotFoundException e) { @@ -182,4 +182,25 @@ null, false, nestedPredCtxStack), operation, returnType); return func; } + + + public TypeInfo getReturnType() throws MXQueryException { + if (returnType != null) + return returnType; + if (iter!=null) + return iter.getStaticType(); + else { + XDMIterator it = loadClass(); + return it.getStaticType(); + } + + } + + public QName[] getClosure() { + if (iter!=null && iter instanceof UserdefFuncCall) { + UserdefFuncCall ud = (UserdefFuncCall)iter; + return ud.getClosure(); + } else + return null; + } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionGallery.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -122,16 +122,21 @@ public Function get(QName name, int arity) throws MXQueryException{ // fix for fn:contains - any arity > 2 possible // TODO: refine to also include in the prefix/namespace - if (name.getLocalPart().equals("concat") && arity > 2) - arity = 2; + int localArity = arity; + if (name.getLocalPart().equals("concat") && name.getNamespaceURI().equals(Context.URI_FN)&& arity > 2) + localArity = 2; // TODO: More elegant way. For now, create dummy signature with empty types - TypeInfo [] typePlaceholder = new TypeInfo[arity]; + TypeInfo [] typePlaceholder = new TypeInfo[localArity]; for (int i=0;i<typePlaceholder.length;i++) { typePlaceholder[i] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE); } FunctionSignature signature = new FunctionSignature(name,typePlaceholder); Function function = (Function)functions.get(signature); if(function != null){ + if (name.getLocalPart().equals("concat") && + name.getNamespaceURI().equals(Context.URI_FN)&& arity > 2) { + function.signature.arity = arity; + } return function; }else{ return null; @@ -233,7 +238,7 @@ xpp.require(XmlPullParser.START_TAG, null, "functionDescription"); xpp.nextTag(); String operation = null; - int type = -1; + TypeInfo type = null; while (!xpp.getName().equals("functionDescription") && xpp.getEventType() != XmlPullParser.END_TAG) { String elementName = xpp.getName(); if (elementName.equals("functionName")) { @@ -254,8 +259,9 @@ operation = xpp.getAttributeValue("", "op"); String rawType = xpp.getAttributeValue("", "type"); funcDesc[2] = xpp.nextText(); - if (rawType != null) - type = getType(rawType,ctx); + if (rawType != null) { + type = new TypeInfo(getType(rawType,ctx),getOccur(rawType)); + } } else { // element ignored System.out.println("element ignored!"); @@ -303,9 +309,12 @@ }else if (rawType.equals("node()")){ return Type.NODE; }else if (rawType.equals("element()")){ - return Type.ITEM;//TODO: fix it! + return Type.START_TAG; + }else if (rawType.startsWith("function(")){ + return Type.FUNCTION_ITEM; }else{ XQName qname = new QName(rawType); + if (qname.getNamespacePrefix()==null){ if (qname.getLocalPart().equals("numeric")){ qname = new QName(Context.URI_MXQ,Context.NS_MXQ,"number"); Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionSignature.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionSignature.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/FunctionSignature.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -15,8 +15,10 @@ package ch.ethz.mxquery.functions; +import ch.ethz.mxquery.contextConfig.XQStaticContext; import ch.ethz.mxquery.datamodel.QName; import ch.ethz.mxquery.datamodel.XQName; +import ch.ethz.mxquery.datamodel.types.Type; import ch.ethz.mxquery.datamodel.types.TypeInfo; import ch.ethz.mxquery.model.XDMIterator; @@ -32,6 +34,8 @@ TypeInfo [] paramTypes; + int arity = 0; + protected int type; protected int expressionType; @@ -59,6 +63,8 @@ expressionType = exprType; nondet = nondeterministic; privateScope = isPrivate; + if (this.paramTypes != null) + arity = paramTypes.length; } /** * Checks the equality of Function Signatures. @@ -80,7 +86,7 @@ * since the type of parameters is irrelevant */ public int hashCode() { - return (qname.hashCode() << 3) | paramTypes.length; + return (qname.hashCode() << 3) | arity; } /** * Returns the name of this function as qualified QName @@ -94,20 +100,20 @@ * @return The number of parameters */ public int getArity() { - if (paramTypes != null) - return this.paramTypes.length; - else - return 0; + return arity; } /** * Returns the type information for each of the parameters * @return A type information for each parameter, an empty TypeInfo[] if no parameters in the function */ - public TypeInfo [] getParameterTypes() { - if (paramTypes != null) - return paramTypes; + public TypeInfo getParameterTypes(int pos) { + if (paramTypes != null && pos < paramTypes.length) + return paramTypes[pos]; else - return new TypeInfo[]{}; + if (qname.getLocalPart().equals("concat") && qname.getNamespaceURI().equals(XQStaticContext.URI_FN)) + return new TypeInfo(Type.ANY_ATOMIC_TYPE,Type.OCCURRENCE_IND_ZERO_OR_ONE); + else + throw new RuntimeException("Trying to access an invalid parameter specification"); } /** * Get the type of function: built-in/system, user-defined, external @@ -140,7 +146,12 @@ } public FunctionSignature copy() { - return new FunctionSignature(qname.copy(), paramTypes, type, expressionType, nondet, privateScope); + QName qn = null; + if (qname != null) + qn = qname.copy(); + FunctionSignature fs = new FunctionSignature(qn, paramTypes, type, expressionType, nondet, privateScope); + fs.arity = arity; + return fs; } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -156,7 +156,7 @@ 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, 0); + 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) { Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Abs.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Abs.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Abs.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -96,7 +96,7 @@ } double valU = Math.abs(db.getValue()); currentToken = new DoubleToken(null,new MXQueryDouble(valU)); - + break; default: throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Invalid argument type", loc); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -31,6 +31,7 @@ import ch.ethz.mxquery.datamodel.xdm.TokenInterface; import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken; 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; @@ -460,6 +461,8 @@ case Type.END_DOCUMENT: level--; break; + case Type.FUNCTION_ITEM: + throw new DynamicException(ErrorCodes.F0036_FUNCTION_ITEM_AT_FN_DATA, "Function Items do not have a typed value, thus cannot be atomized", loc); case Type.END_SEQUENCE: return new EmptySequenceIterator(context, loc); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Deep_equal.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Deep_equal.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Deep_equal.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -100,6 +100,9 @@ if (Type.isTextNode(t2Ev)) t2Ev = Type.getTextNodeValueType(t2Ev); + if (t1Ev == Type.FUNCTION_ITEM || t2Ev == Type.FUNCTION_ITEM) + throw new TypeException(ErrorCodes.F0038_FUNCTION_ITEM_AT_DEEP_EQUAL, "Function items not allow in fn:deep-equal()",loc); + if ((Type.isAtomicType(t1Ev, null)||t1Ev == Type.UNTYPED) && (Type.isAtomicType(t2Ev, null)||t2Ev == Type.UNTYPED)) { try { // TODO: support NaN Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNString.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNString.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNString.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -21,6 +21,7 @@ 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.DynamicException; import ch.ethz.mxquery.exceptions.ErrorCodes; import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.TypeException; @@ -35,7 +36,15 @@ // fn:string always atomizes! input = DataValuesIterator.getDataIterator(it,context); StringBuffer res = new StringBuffer(); - TokenInterface tok = input.next(); + TokenInterface tok; + try { + tok = input.next(); + } catch (DynamicException de) { + if (de.getErrorCode().equals(ErrorCodes.F0036_FUNCTION_ITEM_AT_FN_DATA)) + throw new DynamicException(ErrorCodes.F0037_FUNCTION_ITEM_AT_FN_STRING, "Function items do not have a string value", loc); + else + throw de; + } if (tok.getEventType()!=Type.END_SEQUENCE) { res.append(tok.getValueAsString()); tok = input.next(); Copied: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Function_arity.java (from rev 4330, trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNString.java) =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Function_arity.java (rev 0) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Function_arity.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -0,0 +1,53 @@ +/* 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.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.LongToken; +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 Function_arity extends TokenBasedIterator { + protected void init() throws MXQueryException { + TokenInterface tok = subIters[0].next(); + + if (tok.getEventType() != Type.FUNCTION_ITEM && subIters[0].next().getEventType() != Type.END_SEQUENCE) { + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Expected a single function item", loc); + } + + currentToken = new LongToken(Type.INTEGER, null, tok.getLong()); + } + + public TypeInfo getStaticType() { + return new TypeInfo(Type.INTEGER,Type.OCCURRENCE_IND_EXACTLY_ONE); + } + + protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { + XDMIterator copy = new Function_arity(); + copy.setContext(context, true); + copy.setSubIters(subIters); + return copy; + } +} Copied: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Function_name.java (from rev 4330, trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/FNString.java) =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Function_name.java (rev 0) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Function_name.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -0,0 +1,58 @@ +/* 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.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.QNameToken; +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; + +public class Function_name extends TokenBasedIterator { + protected void init() throws MXQueryException { + TokenInterface tok = subIters[0].next(); + + if (tok.getEventType() != Type.FUNCTION_ITEM && subIters[0].next().getEventType() != Type.END_SEQUENCE) { + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Expected a single function item", loc); + } + + if (tok.getQNameTokenValue() != null) { + currentToken = new QNameToken(null,tok.getQNameTokenValue()); + } else { + currentToken = Token.END_SEQUENCE_TOKEN; + } + } + + public TypeInfo getStaticType() { + return new TypeInfo(Type.QNAME,Type.OCCURRENCE_IND_EXACTLY_ONE); + } + + protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { + XDMIterator copy = new Function_name(); + copy.setContext(context, true); + copy.setSubIters(subIters); + return copy; + } +} 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-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Node_Name.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -59,10 +59,8 @@ switch (i) { case Type.START_TAG: case Type.PROCESSING_INSTRUCTION: - String qname = inputToken.getName(); - QNameToken qn = new QNameToken(null,new QName(qname)); - if (inputToken.getNS() != null) - qn.setNS(inputToken.getNS()); + QName q = new QName(inputToken.getNS(),inputToken.getPrefix(),inputToken.getLocal()); + QNameToken qn = new QNameToken(null,q); currentToken = qn; break; case Type.START_DOCUMENT: Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Put.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Put.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Put.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -52,7 +52,7 @@ protected void createUpdateList() throws MXQueryException { TypeInfo ti = new TypeInfo(Type.NODE,Type.OCCURRENCE_IND_EXACTLY_ONE); - XDMIterator nodeParam = new SequenceTypeIterator(ti,true, false, context,loc); + XDMIterator nodeParam = new SequenceTypeIterator(ti,true, false, context,loc, false); TokenInterface tok; nodeParam.setSubIters(subIters[0]); nodeParam.setResettable(true); Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubString.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubString.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubString.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -29,16 +29,14 @@ public class SubString extends TokenBasedIterator { protected void init() throws MXQueryException { - XDMIterator input = subIters[0]; - TokenInterface inputToken = input.next(); - int type = inputToken.getEventType(); + String in = getStringValueOrEmpty(subIters[0]); - if (type == Type.END_SEQUENCE) { + if (in == null) { currentToken = new TextToken(null, ""); return; } // use string constructor to work around bug in JDK 1.5 for offset - String res = new String(inputToken.getText()); + String res = new String(in); TokenInterface inputToken1 = subIters[1].next(); int type1 = Type.getEventTypeSubstituted(inputToken1.getEventType(), Context.getDictionary()); Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubstringAfter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubstringAfter.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubstringAfter.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -20,12 +20,9 @@ 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.model.TokenBasedIterator; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.Set; @@ -33,21 +30,13 @@ public class SubstringAfter 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 res2 = getStringValueOrEmpty(subIters[1]); + + String res = getStringValueOrEmpty(subIters[0]); 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); @@ -55,17 +44,11 @@ } String result = null; - - String res2 = ""; - if (type2 != Type.END_SEQUENCE) - res2 = inputToken2.getText(); + if (res2 == null) + res2 = ""; - String res = ""; - if (type != Type.END_SEQUENCE) - res = inputToken1.getText(); - - if (res2.equals("")) - result = res; + if (res == null) + result = ""; else { int sPos = res.indexOf(res2); if (sPos >= 0 ) { Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubstringBefore.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubstringBefore.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/SubstringBefore.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -20,12 +20,9 @@ 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.model.TokenBasedIterator; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.Set; @@ -33,39 +30,23 @@ public class SubstringBefore 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 res2 = getStringValueOrEmpty(subIters[1]); + + String res = getStringValueOrEmpty(subIters[0]); + 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); } - - + String result = null; - - String res2 = ""; - if (type2 != Type.END_SEQUENCE) - res2 = inputToken2.getText(); - String res = ""; - if (type != Type.END_SEQUENCE) - res = inputToken1.getText(); - - if (res2.equals("")) + if (res2 == null || res == null) result = ""; else { int sPos = res.indexOf(res2); Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Translate.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Translate.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Translate.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -22,10 +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.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,25 +31,17 @@ 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(); - - if (arg.getEventType() == Type.END_SEQUENCE) { + + String sArg = getStringValueOrEmpty(subIters[0]); + + 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.codePointAt(i); @@ -71,7 +60,7 @@ currentToken = new TextToken(null, translate(sArg)); } - + private String translate(String input) { StringBuffer result = new StringBuffer(); Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/UpperCase.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/UpperCase.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/UpperCase.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -46,7 +46,7 @@ currentToken = new TextToken(null, res.toUpperCase()); break; default: - throw new TypeException(ErrorCodes.F0028_INVALID_ARGUMENT_TYPE, "Invalid argument type"+Type.getTypeQName(inputToken.getEventType(), Context.getDictionary()), loc); + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Invalid argument type"+Type.getTypeQName(inputToken.getEventType(), Context.getDictionary()), loc); } } public TypeInfo getStaticType() { Added: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ClosureIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ClosureIterator.java (rev 0) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ClosureIterator.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -0,0 +1,64 @@ +/* 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.iterators; + + +import java.util.Vector; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.QName; +import ch.ethz.mxquery.datamodel.xdm.FunctionItemToken; +import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.exceptions.QueryLocation; +import ch.ethz.mxquery.functions.Function; +import ch.ethz.mxquery.model.TokenBasedIterator; +import ch.ethz.mxquery.model.VariableHolder; +import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.Hashtable; + +public class ClosureIterator extends TokenBasedIterator { + + Function func; + QName [] closure; + + + + public ClosureIterator(Context context, Function func, + QName[] closure, QueryLocation loc) { + super(context,loc); + this.func = func; + this.closure = closure; + } + + + protected void init() throws MXQueryException { + // initialize all closure values from context + Hashtable closureVals = new Hashtable(); + for (int i=0;i<closure.length;i++) { + VariableHolder vh = context.getVariable(closure[i]); + closureVals.put(closure[i], vh.getIter()); + } + currentToken = new FunctionItemToken(func, closureVals); + } + + + protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { + XDMIterator copy = new ClosureIterator(context, func,closure,loc); + copy.setSubIters(subIters); + return copy; + + } +} Added: trunk/MXQuery/src/ch/ethz/mxquery/iterators/FunctionItemWrapperIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/FunctionItemWrapperIterator.java (rev 0) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/FunctionItemWrapperIterator.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -0,0 +1,142 @@ +/* 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.iterators; + +/** + * Wrapper for function item, providing the facilities for partial application, function coercion, closure, etc + * + * */ + +import java.util.Enumeration; +import java.util.Vector; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.xdm.TokenInterface; +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.exceptions.TypeException; +import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.Hashtable; + +public class FunctionItemWrapperIterator extends CurrentBasedIterator { + + XDMIterator wrappedFunction; + Hashtable paramMap; // free parameters with their position, mapping wrapped pos->caller pos + Hashtable appliedParams; // bound parameters, mapping wrapped pos->iterator + + + + public FunctionItemWrapperIterator(Context ctx, XDMIterator wrappedFunction, + Hashtable paramMap, Hashtable appliedParams,QueryLocation loc) { + super(ctx,loc); + this.wrappedFunction = wrappedFunction; + this.paramMap = paramMap; + this.appliedParams = appliedParams; + + } + + + protected void init() throws MXQueryException { + // first step: partial functions: + // set the subIterators for the parameters + current = wrappedFunction; + + if (subIters.length != paramMap.size()) + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Wrong number of parameters for dynamic function invocation", loc); + XDMIterator [] actualSubs = new XDMIterator[paramMap.size()+appliedParams.size()]; + Enumeration applKeys = appliedParams.keys(); + while (applKeys.hasMoreElements()) { + Integer wrappedPos = (Integer) applKeys.nextElement(); + XDMIterator applIter = (XDMIterator) appliedParams.get(wrappedPos); + actualSubs[wrappedPos.intValue()] = applIter; + } + + Enumeration paramKeys = paramMap.keys(); + while (paramKeys.hasMoreElements()) { + Integer wrappedPos = (Integer) paramKeys.nextElement(); + Integer paramPos = (Integer) paramMap.get(wrappedPos); + actualSubs[wrappedPos.intValue()] = subIters[paramPos.intValue()]; + } + + current.setSubIters(actualSubs); + + } + + + protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { + XDMIterator copy = new FunctionItemWrapperIterator(context, wrappedFunction,paramMap, appliedParams,loc); + copy.setSubIters(subIters); + return copy; + + } + + public TokenInterface next() throws MXQueryException { + if (called == 0) { + init(); + called++; + } + return current.next(); + } + + public void setResettable(boolean r) throws MXQueryException { + wrappedFunction.setResettable(r); + super.setResettable(r); + } + + + public XDMIterator[] getAllSubIters() { + XDMIterator [] res; + if (subIters != null) { + res = new XDMIterator [subIters.length+1]; + for (int i=0;i<subIters.length;i++) + res[i] = subIters[i]; + } + else { + res = new XDMIterator[1]; + } + res[res.length-1] = wrappedFunction; + return res; + } + + + protected void freeResources(boolean restartable) + throws MXQueryException { + super.freeResources(restartable); +// if (!restartable) + current = null; + } + + protected void resetImpl() throws MXQueryException { + // Do not reset current to keep function + // TODO: do we need to reset it with dynamic invocation? + called = 0; + if (current != null) + current.reset(); + this.endOfSeq = false; + if (exprCategory == EXPR_CATEGORY_UPDATING && pendingUpdateList != null) { + pendingUpdateList.clear(); + } + if (subIters != null) { + for (int i = 0; i < subIters.length; i++) { + subIters[i].reset(); + } + } + depth = 0; + } +} Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -207,19 +207,6 @@ } subIters = subIt; } - - private XDMIterator insertAtomizationCast(TypeInfo parType, XDMIterator toAdapt) { - if (parType != null && parType.getType() != TypeInfo.UNDEFINED - && Type.isAtomicType(parType.getType(), Context.getDictionary())) - toAdapt = DataValuesIterator.getDataIterator(toAdapt, toAdapt.getContext()); - - if (parType != null && parType.getType() != TypeInfo.UNDEFINED && - (parType.getType() != Type.END_SEQUENCE) && - parType.getType() != Type.ANY_ATOMIC_TYPE && !Type.isNode(parType.getType()) - && !Type.isTypeOrSubTypeOf(toAdapt.getStaticType().getType(),parType.getType(), Context.getDictionary()) && parType.getType() != Type.ITEM) - toAdapt = new CastAsIterator(toAdapt.getContext(), toAdapt, parType, false, true,loc); - return toAdapt; - } protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { NativeFuncCall copy = new NativeFuncCall( Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/SequenceTypeIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/SequenceTypeIterator.java 2011-05-09 22:45:21 UTC (rev 4330) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/SequenceTypeIterator.java 2011-05-12 11:10:38 UTC (rev 4331) @@ -26,12 +26,15 @@ 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.FunctionItemToken; 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.QueryLocation; import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.functions.Function; +import ch.ethz.mxquery.functions.FunctionSignature; import ch.ethz.mxquery.model.CheckNodeType; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.XDMIterator; @@ -41,10 +44,11 @@ private boolean streaming = false; private boolean atomicTypeTest = true; + private boolean functionTypeTest = false; private boolean checkTokensType = true; private TypeInfo tInfo = null; private boolean promote = false; - + private boolean coerce = false; private String node_name = null; private String node_name_uri = null; private int itemCount = 0; @@ -52,17 +56,21 @@ /** * @param ctx TODO + * @param coerce TODO * */ - public SequenceTypeIterator(TypeInfo tInfo, boolean streaming, boolean promote, Context ctx, QueryLocation location){ + public SequenceTypeIterator(TypeInfo tInfo, boolean streaming, boolean promote, Context ctx, QueryLocation location, boolean coerce){ super(ctx, location); this.tInfo = tInfo; this.streaming = streaming; this.promote = promote; + this.coerce = coerce; int type = tInfo.getType(); if ( ! Type.isAtomicType(type, Context.getDictionary()) ) { atomicTypeTest = false; } + if (type == Type.FUNCTION_ITEM) + functionTypeTest = true; } public TokenInterface next() throws MXQueryException { @@ -126,14 +134,19 @@ int typeAnn = tInfo.getTypeAnnotation(); String name = node_name; String[] tokens = QName.parseQName(node_name); - if (tokens.length > 1) name = tokens[1]; - if (typeAnn == 39 || typeAnn == 35 ) + if (coerce && tInfo.getType() == Type.FUNCTION_ITEM) { + tok = coerceFunctionItem((FunctionItemToken)tok, tInfo); + return tok; + } else { + if (tokens.length > 1) name = tokens[1]; + if (typeAnn == 39 || typeAnn == 35 ) throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Sequence Type Matching Failed",loc); - else if (typeAnn != -1&& name!=null&& !name.equals("*")) + else if (typeAnn != -1&& name!=null&& !name.equals("*")) throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Sequence Type Matching Failed: Expected {"+node_name_uri+"}:"+name+" with type: "+Type.getTypeQName(tInfo.getTypeAnnotation(), Context.getDictionary())+", encountered {"+tok.getNS()+"}:"+tok.getName()+" with type "+Type.getTypeQName(tok.getTypeAnnotation(), Context.getDictionary()), loc); - else if ( name ==null || typeAnn != -1 && name.equals("*")) + else if ( name ==null || typeAnn != -1 && name.equals("*")) throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Sequence Type Matching Failed: Incorrect type: Expected "+Type.getTypeQName(typeAnn, Context.getDictionary())+", encountered type :"+Type.getTypeQName(tok.getTypeAnnotation(), Context.getDictionary()), loc); - else throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Sequence Type Matching Failed : Incorrect type: Expected "+Type.getTypeQName(tInfo.getType(), Context.getDictionary())+" encountered: "+Type.getTypeQName(tok.getEventType(), Context.getDictionary()), loc); + else throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Sequence Type Matching Failed : Incorrect type: Expected "+Type.getTypeQName(tInfo.getType(), Context.getDictionary())+" encountered: "+Type.getTypeQName(tok.getEventType(), Context.getDictionary()), loc); + } } else return tok; } @@ -248,8 +261,11 @@ itemCount++; if (this.atomicTypeTest) - return isAtomicTypeItemFine(tok); + return isAtomicTypeItemFine(tok); else + if (functionTypeTest) + return isFunctionItemFine(tok); + else return isNodeKindTypeItemFine(tok); } @@ -321,7 +337,30 @@ } } - + private boolean isFunctionItemFine(TokenInterface tok) throws MXQueryException { + if (tok.getEventType()!=Type.FUNCTION_ITEM) + return false; + TypeInfo [] params = tInfo.getParameterTypes(); + if (params != null) { + FunctionSignature fs = ((FunctionItemToken)tok).getFunction().getFunctionSignature(); + if (fs.getArity() != params.length) + return false; + for (int i=0;i<params.length;i++) { + if (!Type.isTypeOrSubTypeOf(params[i].getType(),fs.getParameterTypes(i).getType(), Context.getDictionary()) || + !Type.isTypeOrSubTypeOf(params[i].getTypeAnnotation(), fs.getParameterTypes(i).getTypeAnnotation(), Context.getDictionary()) || + !Type.isOccCompatible(params[i].getOccurID(),fs.getParameterTypes(i).getOccurID(... [truncated message content] |
From: <et...@us...> - 2011-05-09 22:45:27
|
Revision: 4330 http://mxquery.svn.sourceforge.net/mxquery/?rev=4330&view=rev Author: etterth Date: 2011-05-09 22:45:21 +0000 (Mon, 09 May 2011) Log Message: ----------- - Fixed IE9 XML bug (the IE8 functions were taken ) - Fixed asynchronous WeatherREST samples Modified Paths: -------------- trunk/MXQuery/xqib_samples/WeatherRESTasync.html trunk/MXQuery/xqib_samples/WeatherRESTasyncSlow.html trunk/MXQuery/xqib_samples/WeatherRESTasyncSlowCached.html trunk/MXQuery/xqib_samples/WeatherRESTread.html trunk/MXQuery/xqib_samples/timer.html trunk/MXQuery/xqib_src/ch/ethz/mxquery.gwt.xml Modified: trunk/MXQuery/xqib_samples/WeatherRESTasync.html =================================================================== --- trunk/MXQuery/xqib_samples/WeatherRESTasync.html 2011-05-09 21:46:10 UTC (rev 4329) +++ trunk/MXQuery/xqib_samples/WeatherRESTasync.html 2011-05-09 22:45:21 UTC (rev 4330) @@ -44,8 +44,8 @@ }; declare updating function local:getWeather($loc, $evtObj) { - http-client:async-request(xs:QName('local:weatherResult'), - <http-client:request href="forecast2.xml" method="get"/> + http-client:async-request(<http-client:request href="forecast2.xml" method="get"/>, + xs:QName('local:weatherResult') ) }; Modified: trunk/MXQuery/xqib_samples/WeatherRESTasyncSlow.html =================================================================== --- trunk/MXQuery/xqib_samples/WeatherRESTasyncSlow.html 2011-05-09 21:46:10 UTC (rev 4329) +++ trunk/MXQuery/xqib_samples/WeatherRESTasyncSlow.html 2011-05-09 22:45:21 UTC (rev 4330) @@ -45,7 +45,7 @@ declare updating function local:getWeather($loc, $evtObj) { ( - http-client:async-request(xs:QName('local:weatherResult'), <http-client:request href="http://n.ethz.ch/~etterth/slowserver.php?file=forecast2.xml" method="get"/>), + http-client:async-request( <http-client:request href="http://n.ethz.ch/~etterth/slowserver.php?file=forecast2.xml" method="get"/>, xs:QName('local:weatherResult')), insert node <div>Loading: <img src="img/Loading_2_transparent.gif" /> Modified: trunk/MXQuery/xqib_samples/WeatherRESTasyncSlowCached.html =================================================================== --- trunk/MXQuery/xqib_samples/WeatherRESTasyncSlowCached.html 2011-05-09 21:46:10 UTC (rev 4329) +++ trunk/MXQuery/xqib_samples/WeatherRESTasyncSlowCached.html 2011-05-09 22:45:21 UTC (rev 4330) @@ -45,7 +45,7 @@ declare updating function local:getWeather($loc, $evtObj) { ( - http-client:async-read(xs:QName('local:weatherResult'), "http://n.ethz.ch/~etterth/slowserver.php?file=forecast2.xml"), + http-client:async-read("http://n.ethz.ch/~etterth/slowserver.php?file=forecast2.xml",xs:QName('local:weatherResult')), insert node <div>Loading: <img src="img/Loading_2_transparent.gif" /> Modified: trunk/MXQuery/xqib_samples/WeatherRESTread.html =================================================================== --- trunk/MXQuery/xqib_samples/WeatherRESTread.html 2011-05-09 21:46:10 UTC (rev 4329) +++ trunk/MXQuery/xqib_samples/WeatherRESTread.html 2011-05-09 22:45:21 UTC (rev 4330) @@ -44,8 +44,8 @@ }; declare updating function local:getWeather($loc, $evtObj) { - http-client:async-read(xs:QName('local:weatherResult'), - "forecast2.xml" + http-client:async-read("forecast2.xml", +xs:QName('local:weatherResult') ) }; Modified: trunk/MXQuery/xqib_samples/timer.html =================================================================== --- trunk/MXQuery/xqib_samples/timer.html 2011-05-09 21:46:10 UTC (rev 4329) +++ trunk/MXQuery/xqib_samples/timer.html 2011-05-09 22:45:21 UTC (rev 4330) @@ -7,8 +7,8 @@ <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script> <script type="application/xquery"> declare updating function local:listener() { + b:timer(1000, xs:QName('local:listener')), insert node <div>{fn:current-time()}</div> as last into b:dom()//body -, b:timer(1000, xs:QName('local:listener')) }; b:timer(1000, xs:QName('local:listener')) Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery.gwt.xml =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery.gwt.xml 2011-05-09 21:46:10 UTC (rev 4329) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery.gwt.xml 2011-05-09 22:45:21 UTC (rev 4330) @@ -51,11 +51,11 @@ <when-property-is name="user.agent" value="opera" /> </replace-with> - <replace-with class="ch.ethz.mxquery.util.browser.dom.DOMImplIE8"> + <!-- <replace-with class="ch.ethz.mxquery.util.browser.dom.DOMImplIE8"> <when-type-is class="ch.ethz.mxquery.util.browser.dom.DOMImpl" /> <when-property-is name="user.agent" value="ie8" /> - </replace-with> + </replace-with> --> <replace-with class="ch.ethz.mxquery.util.browser.dom.DOMImplIE"> <when-type-is class="ch.ethz.mxquery.util.browser.dom.DOMImpl" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-09 21:46:16
|
Revision: 4329 http://mxquery.svn.sourceforge.net/mxquery/?rev=4329&view=rev Author: maxspeicher Date: 2011-05-09 21:46:10 +0000 (Mon, 09 May 2011) Log Message: ----------- added a first, basic Java Native function to the UI 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-09 18:42:51 UTC (rev 4328) +++ trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-09 21:46:10 UTC (rev 4329) @@ -16,6 +16,7 @@ <item>@string/function</item> <item>@string/namespace</item> <item>@string/fibonacci</item> + <item>@string/native_java</item> </string-array> <string name="hello_world">Hello World</string> @@ -24,6 +25,7 @@ <string name="function">Function</string> <string name="namespace">Namespace</string> <string name="fibonacci">Fibonacci</string> + <string name="native_java">Native Java</string> <string name="hello_world_xquery">\"Hello World\"</string> <string name="addition_xquery">5+5</string> @@ -51,5 +53,9 @@ };\n\n local:fib-recur(10) </string> + <string name="native_java_xquery"> + declare namespace m = \"java:java.lang.Math\";\n + m:random() + </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-09 18:42:51 UTC (rev 4328) +++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-09 21:46:10 UTC (rev 4329) @@ -75,7 +75,7 @@ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + setContentView(R.layout.main); mButton = (Button) findViewById(R.id.button); mSpinner = (Spinner) findViewById(R.id.sample_query_spinner); @@ -106,6 +106,8 @@ mInputView.setText(getString(R.string.namespace_xquery)); } else if (item.equals(getString(R.string.fibonacci))) { mInputView.setText(getString(R.string.fibonacci_xquery)); + } else if (item.equals(getString(R.string.native_java))) { + mInputView.setText(getString(R.string.native_java_xquery)); } } @@ -271,4 +273,5 @@ mResultView.setText(result); mActivity.removeDialog(QUERY_RUNNING_DIALOG); } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-09 18:42:57
|
Revision: 4328 http://mxquery.svn.sourceforge.net/mxquery/?rev=4328&view=rev Author: maxspeicher Date: 2011-05-09 18:42:51 +0000 (Mon, 09 May 2011) Log Message: ----------- mapped the "void" return type of native Java functions to an empty sequence Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-09 13:52:36 UTC (rev 4327) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-09 18:42:51 UTC (rev 4328) @@ -30,6 +30,7 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.functions.fn.DataValuesIterator; import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.EmptySequenceIterator; import ch.ethz.mxquery.model.Iterator; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.xdmio.XDMAtomicItemFactory; @@ -112,18 +113,23 @@ } try { + Method meth = null; Object res; if (methodName.equals("new")) { Constructor con = native_function.getConstructor(invocationParamsTypes); res = con.newInstance(invocationParams); } else { - Method meth = native_function.getMethod(methodName, invocationParamsTypes); + meth = native_function.getMethod(methodName, invocationParamsTypes); res = meth.invoke(instanceToCall, invocationParams); } try { - this.current = XDMAtomicItemFactory.createAtomicItemType(res); + if (meth != null && meth.getReturnType().getName().equals("void")) { + this.current = new EmptySequenceIterator(context,loc); + } else { + this.current = XDMAtomicItemFactory.createAtomicItemType(res); + } }catch (MXQueryException me) { WrappedObjectToken wrap = new WrappedObjectToken(res); this.current = new TokenIterator(context, wrap, loc, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <et...@us...> - 2011-05-09 13:52:42
|
Revision: 4327 http://mxquery.svn.sourceforge.net/mxquery/?rev=4327&view=rev Author: etterth Date: 2011-05-09 13:52:36 +0000 (Mon, 09 May 2011) Log Message: ----------- - fn:currenttime is now set in invokeModule - added b:js-eval($script as xs:string) Modified Paths: -------------- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java Added Paths: ----------- trunk/MXQuery/xqib_samples/js-eval.html trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsEval.java Added: trunk/MXQuery/xqib_samples/js-eval.html =================================================================== --- trunk/MXQuery/xqib_samples/js-eval.html (rev 0) +++ trunk/MXQuery/xqib_samples/js-eval.html 2011-05-09 13:52:36 UTC (rev 4327) @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>XQIB: Sample page</title> + <meta charset="UTF-8"/> + <link href="style.css" rel="stylesheet" type="text/css"> + <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script> + <script type="application/xquery"> + + + b:js-eval('window.alert("eval!")') + + </script> + </head> + <body> + <h1>timer</h1> + + </body> +</html> Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-05-09 02:20:28 UTC (rev 4326) +++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-05-09 13:52:36 UTC (rev 4327) @@ -186,6 +186,8 @@ } int arity = subiterators.length; Function function = functionname.context.getFunction(functionname.qname, arity); + //set currenttime + functionname.context.setCurrentTime(null); XDMIterator func = function.getFunctionImplementation(new Context(functionname.context)); func.setSubIters(subiterators); // func.setContext(getContext(), true); Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-05-09 02:20:28 UTC (rev 4326) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-05-09 13:52:36 UTC (rev 4327) @@ -2,6 +2,21 @@ <functionGallery basePackage="ch.ethz.mxquery.functions."> <functionGroup prefix="b" namespace="http://xqib.org"> <functionDescription> + <functionName>js-eval</functionName> + <parameters> + <paramType>xs:string</paramType> + </parameters> + <className>JsEval</className> + </functionDescription> + <functionDescription> + <functionName>timer</functionName> + <parameters> + <paramType>xs:integer</paramType> + <paramType>QName</paramType> + </parameters> + <className>Timer</className> + </functionDescription> + <functionDescription> <functionName>getCookieNames</functionName> <className>GetCookieNames</className> </functionDescription> Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-09 02:20:28 UTC (rev 4326) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-09 13:52:36 UTC (rev 4327) @@ -453,6 +453,57 @@ qn = new QName( "http://xqib.org", "b", + "js-eval"); + paramTypes = new TypeInfo[1]; + + paramTypes[0] = new TypeInfo(getType( + "xs:string",ctx),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 = -1; + + 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(getType( + "xs:integer",ctx),getOccur("xs:integer"),null); + + paramTypes[1] = new TypeInfo(getType( + "QName",ctx),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 = -1; + + function = new Function( + null,signature, + iter, null, type ); + fg.add(function); + } + + qn = new QName( + "http://xqib.org", + "b", "getCookieNames"); paramTypes = new TypeInfo[0]; Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsEval.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsEval.java (rev 0) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsEval.java 2011-05-09 13:52:36 UTC (rev 4327) @@ -0,0 +1,40 @@ +package ch.ethz.mxquery.functions.b; + +import java.util.Vector; + +import ch.ethz.mxquery.contextConfig.Context; +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; + +public class JsEval extends TokenBasedIterator { + + @Override + protected void init() throws MXQueryException { + TokenInterface tok = subIters[0].next(); + String script = tok.getValueAsString(); + if (script == null){ + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Invalid argument type", loc); + } + eval(script); + currentToken = Token.END_SEQUENCE_TOKEN; + } + + @Override + protected XDMIterator copy(Context context, XDMIterator[] subIters, + Vector nestedPredCtxStack) throws MXQueryException { + JsEval copy = new JsEval(); + copy.setSubIters(subIters); + copy.setContext(context, true); + return copy; + } + + protected native void eval(String script)/*-{ + eval(script); + }-*/; + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <et...@us...> - 2011-05-09 02:20:35
|
Revision: 4326 http://mxquery.svn.sourceforge.net/mxquery/?rev=4326&view=rev Author: etterth Date: 2011-05-09 02:20:28 +0000 (Mon, 09 May 2011) Log Message: ----------- - Cookies added - Fixed build - Asynchronous expath now with handler as last parameter - Fixed a bug with setting the value in input elements - The setup script no longer destroys the root's .svn Modified Paths: -------------- trunk/MXQuery/xqib_setup_env.sh trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/EXPathHTTP.xml trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml Added Paths: ----------- trunk/MXQuery/xqib_samples/cookies.html trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookie.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookieNames.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveCookie.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetCookie.java Added: trunk/MXQuery/xqib_samples/cookies.html =================================================================== --- trunk/MXQuery/xqib_samples/cookies.html (rev 0) +++ trunk/MXQuery/xqib_samples/cookies.html 2011-05-09 02:20:28 UTC (rev 4326) @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>XQIB: Sample page</title> + <meta charset="UTF-8"/> + <link href="style.css" rel="stylesheet" type="text/css"> + <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script> + <script type="application/xquery"> + import module namespace http-client = "http://expath.org/ns/http-client"; + + declare updating function local:getCookie($loc, $evtObj) { + let $name := b:dom()//input[@id='name']/@value + let $value := b:getCookie($name) + return if ($value) then + + (replace value of node b:dom()//div[@id='status'] with ('the value of', $name, 'is', $value), + replace value of node b:dom()//input[@id='value']/@value with $value) + else + (replace value of node b:dom()//div[@id='status'] with concat('there is no cookie with name "', $name , '"')) + }; + + declare updating function local:setCookie($loc, $evtObj) { + b:setCookie(b:dom()//input[@id='name']/@value, b:dom()//input[@id='value']/@value) + }; + + + b:addEventListener(b:dom()//input[@id="getbutton"], "onclick", xs:QName("local:getCookie")), + b:addEventListener(b:dom()//input[@id="setbutton"], "onclick", xs:QName("local:setCookie")) + + </script> + </head> + <body> + <h1>Cookies</h1> + <p/> + <div>Name: <input type="text" value="" style="font-size: 30pt; font-weight: bold" id="name"/></div> + <div>Value: <input type="text" value="" style="font-size: 30pt; font-weight: bold" id="value"/></div> + + <input type="button" value="Set" style="font-size: 30pt; font-weight: bold" id="setbutton"/> + <input type="button" value="Get" style="font-size: 30pt; font-weight: bold" id="getbutton"/> + <div id="status"></div> + </body> +</html> \ No newline at end of file Modified: trunk/MXQuery/xqib_setup_env.sh =================================================================== --- trunk/MXQuery/xqib_setup_env.sh 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_setup_env.sh 2011-05-09 02:20:28 UTC (rev 4326) @@ -1,5 +1,10 @@ cp .classpath mxquery.classpath -cp -rf xqib_files/* . -cp -rf xqib_files/.* . +#mkdir $(find xqib_files/ -type d | grep -v '.svn' ) +#cp $(find xqib_files/ | grep -v '.svn' ) . +#cp -rf xqib_files/* . +#cp -rf xqib_files/.* . +(cd xqib_files ; tar --exclude='.svn' -c -f - .) | tar xfv - ant xqib-js_prepare -cp -rf xqib_samples/* war + +#cp -rf xqib_samples/* war +(cd xqib_samples ; tar --exclude='.svn' -c -f - .) | (cd war ; tar xfv -) Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -150,6 +150,7 @@ try { log.log(LogLevel.FINER, "Calling eventcallback " + functionname.qname.toString()); ListBasedIterator eventiter = new EventIterator(event); + eventiter.setContext(new Context(), true); Iterator[] subiterators = { nodeiter, eventiter }; QName qn = functionname.qname; qn.setNamespaceURI(functionname.context.getNamespace( @@ -164,7 +165,7 @@ // TODO Auto-generated catch block Environment.displayErrorMessage(new StringBuffer(), null, e, - false); + true); e.printStackTrace(); } } @@ -324,6 +325,11 @@ } catch (Exception ex) { } } + else {//query == nulll + queryResult.append(err.getErrorCode() + " " + + err.getMessage() + "\n"); + + } for (StackTraceElement trace : err.getStackTrace()) { queryResult.append("\n"); queryResult.append(trace.toString()); Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/EXPathHTTP.xml =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/EXPathHTTP.xml 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/EXPathHTTP.xml 2011-05-09 02:20:28 UTC (rev 4326) @@ -29,27 +29,27 @@ <functionDescription> <functionName>async-request</functionName> <parameters> - <paramType>QName</paramType> <paramType>element()?</paramType> <paramType>string?</paramType> <paramType>item()*</paramType> + <paramType>QName</paramType> </parameters> <className op="async">HttpIO</className> </functionDescription> <functionDescription> <functionName>async-request</functionName> <parameters> - <paramType>QName</paramType> <paramType>element()?</paramType> <paramType>string?</paramType> + <paramType>QName</paramType> </parameters> <className op="async">HttpIO</className> </functionDescription> <functionDescription> <functionName>async-request</functionName> <parameters> + <paramType>element()?</paramType> <paramType>QName</paramType> - <paramType>element()?</paramType> </parameters> <className op="async">HttpIO</className> </functionDescription> @@ -63,10 +63,10 @@ <functionDescription> <functionName>async-read</functionName> <parameters> + <paramType>xs:string</paramType> <paramType>QName</paramType> - <paramType>xs:string</paramType> </parameters> <className op="async read">HttpIO</className> </functionDescription> </functionGroup> -</functionGallery> \ No newline at end of file +</functionGallery> 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-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -172,7 +172,7 @@ private void init() throws MXQueryException { if (async) { - XDMIterator handleriter = subIters[0]; + XDMIterator handleriter = subIters[subIters.length - 1]; this.asynchandlername = handleriter.next().getQNameTokenValue(); if (asynchandlername != null) { if (this.getContext().getRootContext() @@ -209,8 +209,8 @@ } XDMIterator[] oldsubiters = subIters; subIters = new XDMIterator[oldsubiters.length - 1]; - for (int i = 1; i < oldsubiters.length; i++) { - subIters[i - 1] = oldsubiters[i]; + for (int i = 0; i < oldsubiters.length-1; i++) { + subIters[i] = oldsubiters[i]; } } Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-05-09 02:20:28 UTC (rev 4326) @@ -2,9 +2,46 @@ <functionGallery basePackage="ch.ethz.mxquery.functions."> <functionGroup prefix="b" namespace="http://xqib.org"> <functionDescription> + <functionName>getCookieNames</functionName> + <className>GetCookieNames</className> + </functionDescription> + <functionDescription> + <functionName>getCookie</functionName> + <parameters> + <paramType>xs:string</paramType> + </parameters> + <className>GetCookie</className> + </functionDescription> + <functionDescription> + <functionName>removeCookie</functionName> + <parameters> + <paramType>xs:string</paramType> + </parameters> + <className>RemoveCookie</className> + </functionDescription> + <functionDescription> + <functionName>setCookie</functionName> + <parameters> + <paramType>xs:string</paramType> + <paramType>xs:string</paramType> + </parameters> + <className>SetCookie</className> + </functionDescription> + <functionDescription> + <functionName>setCookie</functionName> + <parameters> + <paramType>xs:string</paramType> + <paramType>xs:string</paramType> + <paramType>xs:dateTime</paramType> + </parameters> + <className>SetCookie</className> + </functionDescription> +<!-- TODO: setcookie and removeCookie with more arguments --> + + <functionDescription> <functionName>pageURI</functionName> <className>LocUri</className> - </functionDescription> + </functionDescription>/ <functionDescription> <functionName>getLocation</functionName> <className>GetLocation</className> @@ -1645,4 +1682,4 @@ </functionDescription> </functionGroup> -</functionGallery> \ No newline at end of file +</functionGallery> Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -198,10 +198,9 @@ Function function; int type; String classname; + + ctx.addNamespace("expathhttp", "http://expath.org/ns/http-client"); - ctx.addNamespace(XQStaticContext.NS_EXPATH, - XQStaticContext.URI_EXPATH); - qn = new QName( "http://expath.org/ns/http-client", "expathhttp", @@ -290,16 +289,16 @@ paramTypes = new TypeInfo[4]; paramTypes[0] = new TypeInfo(getType( - "QName",ctx),getOccur("QName"),null); + "element()?",ctx),getOccur("element()?"),null); paramTypes[1] = new TypeInfo(getType( - "element()?",ctx),getOccur("element()?"),null); + "string?",ctx),getOccur("string?"),null); paramTypes[2] = new TypeInfo(getType( - "string?",ctx),getOccur("string?"),null); + "item()*",ctx),getOccur("item()*"),null); paramTypes[3] = new TypeInfo(getType( - "item()*",ctx),getOccur("item()*"),null); + "QName",ctx),getOccur("QName"),null); signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false); @@ -325,13 +324,13 @@ paramTypes = new TypeInfo[3]; paramTypes[0] = new TypeInfo(getType( - "QName",ctx),getOccur("QName"),null); + "element()?",ctx),getOccur("element()?"),null); paramTypes[1] = new TypeInfo(getType( - "element()?",ctx),getOccur("element()?"),null); + "string?",ctx),getOccur("string?"),null); paramTypes[2] = new TypeInfo(getType( - "string?",ctx),getOccur("string?"),null); + "QName",ctx),getOccur("QName"),null); signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false); @@ -357,10 +356,10 @@ paramTypes = new TypeInfo[2]; paramTypes[0] = new TypeInfo(getType( - "QName",ctx),getOccur("QName"),null); + "element()?",ctx),getOccur("element()?"),null); paramTypes[1] = new TypeInfo(getType( - "element()?",ctx),getOccur("element()?"),null); + "QName",ctx),getOccur("QName"),null); signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false); @@ -412,10 +411,10 @@ paramTypes = new TypeInfo[2]; paramTypes[0] = new TypeInfo(getType( - "QName",ctx),getOccur("QName"),null); + "xs:string",ctx),getOccur("xs:string"),null); paramTypes[1] = new TypeInfo(getType( - "xs:string",ctx),getOccur("xs:string"),null); + "QName",ctx),getOccur("QName"),null); signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false); @@ -454,20 +453,89 @@ qn = new QName( "http://xqib.org", "b", - "timer"); + "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 = -1; + + 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(getType( + "xs:string",ctx),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 = -1; + + 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(getType( + "xs:string",ctx),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 = -1; + + 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(getType( - "numeric",ctx),getOccur("numeric"),null); + "xs:string",ctx),getOccur("xs:string"),null); paramTypes[1] = new TypeInfo(getType( - "QName",ctx),getOccur("QName"),null); + "xs:string",ctx),getOccur("xs:string"),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(); + ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie(); iter.setContext(context, false); type = -1; @@ -481,6 +549,36 @@ qn = new QName( "http://xqib.org", "b", + "setCookie"); + paramTypes = new TypeInfo[3]; + + paramTypes[0] = new TypeInfo(getType( + "xs:string",ctx),getOccur("xs:string"),null); + + paramTypes[1] = new TypeInfo(getType( + "xs:string",ctx),getOccur("xs:string"),null); + + paramTypes[2] = new TypeInfo(getType( + "xs:dateTime",ctx),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 = -1; + + function = new Function( + null,signature, + iter, null, type ); + fg.add(function); + } + + qn = new QName( + "http://xqib.org", + "b", "pageURI"); paramTypes = new TypeInfo[0]; Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookie.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookie.java (rev 0) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookie.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -0,0 +1,43 @@ +package ch.ethz.mxquery.functions.b; + +import java.util.Vector; + +import com.google.gwt.user.client.Cookies; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.xdm.Token; +import ch.ethz.mxquery.datamodel.xdm.TokenInterface; +import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken; +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 GetCookie extends TokenBasedIterator { + + @Override + protected void init() throws MXQueryException { + TokenInterface tok = subIters[0].next(); + String name = tok.getValueAsString(); + if (name == null){ + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Invalid argument type", loc); + } + + String value = Cookies.getCookie(name); + if (value != null) + this.currentToken = new UntypedAtomicToken(null, value); + else + this.currentToken = Token.END_SEQUENCE_TOKEN; + } + + @Override + protected XDMIterator copy(Context context, XDMIterator[] subIters, + Vector nestedPredCtxStack) throws MXQueryException { + GetCookie copy = new GetCookie(); + copy.setContext(context, true); + copy.setSubIters(subIters); + return copy; + } + +} Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookieNames.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookieNames.java (rev 0) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookieNames.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -0,0 +1,36 @@ +package ch.ethz.mxquery.functions.b; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.Vector; + +import com.google.gwt.user.client.Cookies; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.xdm.TokenInterface; +import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken; +import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.iterators.browser.ListBasedIterator; +import ch.ethz.mxquery.model.XDMIterator; + +public class GetCookieNames extends ListBasedIterator { + + @Override + protected void init() throws MXQueryException { + lst = new LinkedList<TokenInterface>(); + Collection<String> cookies = Cookies.getCookieNames(); + for (String cookie: cookies){ + lst.add(new UntypedAtomicToken(null, cookie)); + } + } + + @Override + protected XDMIterator copy(Context context, XDMIterator[] subIters, + Vector nestedPredCtxStack) throws MXQueryException { + GetCookieNames copy = new GetCookieNames(); + copy.setContext(context, true); + copy.setSubIters(subIters); + return copy; + } + +} Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveCookie.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveCookie.java (rev 0) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveCookie.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -0,0 +1,38 @@ +package ch.ethz.mxquery.functions.b; + +import java.util.Vector; + +import com.google.gwt.user.client.Cookies; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.xdm.TokenInterface; +import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken; +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 RemoveCookie extends TokenBasedIterator { + + @Override + protected void init() throws MXQueryException { + TokenInterface tok = subIters[0].next(); + String name = tok.getValueAsString(); + if (name == null){ + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Invalid argument type", loc); + } + + Cookies.removeCookie(name); + } + + @Override + protected XDMIterator copy(Context context, XDMIterator[] subIters, + Vector nestedPredCtxStack) throws MXQueryException { + RemoveCookie copy = new RemoveCookie(); + copy.setContext(context, true); + copy.setSubIters(subIters); + return copy; + } + +} Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetCookie.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetCookie.java (rev 0) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetCookie.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -0,0 +1,58 @@ +package ch.ethz.mxquery.functions.b; + +import java.util.Vector; + +import com.google.gwt.user.client.Cookies; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.MXQueryDateTime; +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 SetCookie extends TokenBasedIterator { + + @Override + protected void init() throws MXQueryException { + TokenInterface tok = subIters[0].next(); + String name = tok.getValueAsString(); + if (name == null) { + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, + "Invalid argument type", loc); + } + + tok = subIters[1].next(); + String value = tok.getValueAsString(); + if (value == null) { + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, + "Invalid argument type", loc); + } + + if (subIters.length == 2) { + Cookies.setCookie(name, value); + return; + } + MXQueryDateTime expires = tok.getDateTime(); + if (expires == null) { + throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, + "Invalid argument type", loc); + } + + Cookies.setCookie(name, value, expires.createCalendar().getTime()); + // TODO: more overloads + + } + + @Override + protected XDMIterator copy(Context context, XDMIterator[] subIters, + Vector nestedPredCtxStack) throws MXQueryException { + SetCookie copy = new SetCookie(); + copy.setContext(context, true); + copy.setSubIters(subIters); + return copy; + } + +} Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -177,7 +177,21 @@ public native Document createDocument() /*-{ return $doc.implementation.createDocument('http://www.w3.org/1999/xhtml', '', null); }-*/; + + public void nodeSetValue(Node node, String nodeValue) { + if (node.getNodeType() == Node.ATTRIBUTE_NODE){ + ((Attribute)node).getOwnerElement().setAttributeNS(node.getNameSpaceURI(), node.getLocalName(), nodeValue); + return; + } + native_nodeSetValue(node, nodeValue); + + } + public native void native_nodeSetValue(Node node, String nodeValue) /*-{ + node.nodeValue= nodeValue; + + }-*/; + // public native Document getIFrameDocument(IFrameElement iframe) /*-{ //// $wnd.ifr = iframe; // return iframe.contentDocument.document; Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -2,7 +2,13 @@ import java.util.List; +import org.eclipse.jdt.internal.compiler.ast.ThisReference; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.Namespace; + import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.Style; public class Element extends Node { @@ -25,6 +31,21 @@ }; public final void setAttributeNS (String namespace, String localName, String value) { + String thisNameSpaceURI = this.getNameSpaceURI(); + if ("http://www.w3.org/1999/xhtml".equals(thisNameSpaceURI)){ + if ("input".equals(this.getLocalName())) { + InputElement el = (InputElement) this.getAsGwtElement(); + if ("value".equals(localName)) { + el.setValue(value); + return; + } else if ("checked".equals(localName)) { + + el.setChecked("true".equals(value)); + return; + } + } + + } DOMImpl.impl.elementSetAttributeNS(this, namespace, localName, value); }; Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java 2011-05-09 02:20:28 UTC (rev 4326) @@ -366,7 +366,7 @@ * The value of this node, depending on its type; see the table above. When * it is defined to be null, setting it has no effect. */ - public final native void setNodeValue(String nodeValue) /*-{ - this.nodeValue = nodeValue; - }-*/; + public final void setNodeValue(String nodeValue) { + DOMImpl.impl.nodeSetValue(this, nodeValue); + } } Modified: trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml 2011-05-08 16:32:28 UTC (rev 4325) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml 2011-05-09 02:20:28 UTC (rev 4326) @@ -6,6 +6,4 @@ <source path="common"/> <source path="impl"/> <source path="gwt"/> - <entry-point class="nu.validator.htmlparser.gwt.HtmlParserModule"/> - <add-linker name="sso"/> </module> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <et...@us...> - 2011-05-08 16:32:37
|
Revision: 4325 http://mxquery.svn.sourceforge.net/mxquery/?rev=4325&view=rev Author: etterth Date: 2011-05-08 16:32:28 +0000 (Sun, 08 May 2011) Log Message: ----------- - Tidy support for XQIB Modified Paths: -------------- trunk/MXQuery/build.xml 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 trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Document.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java Added Paths: ----------- trunk/MXQuery/gwt-2.3.0/ trunk/MXQuery/gwt-2.3.0/gwt-dev.jar trunk/MXQuery/gwt-2.3.0/gwt-user.jar trunk/MXQuery/xqib_samples/data/ trunk/MXQuery/xqib_samples/data/test.html trunk/MXQuery/xqib_samples/tidy.html trunk/MXQuery/xqib_src/nu/ trunk/MXQuery/xqib_src/nu/validator/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Auto.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/CharacterName.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Const.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/IdType.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Inline.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Literal.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Local.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/NoLength.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/NsUri.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Prefix.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/QName.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Virtual.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/package.html trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/ByteReadable.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/CharacterHandler.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DoctypeExpectation.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DocumentMode.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DocumentModeHandler.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/EncodingDeclarationHandler.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/Heuristics.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/Interner.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/TokenHandler.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/TransitionHandler.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/XmlViolationPolicy.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/package.html trunk/MXQuery/xqib_src/nu/validator/htmlparser/gwt/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/gwt/BrowserTreeBuilder.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/gwt/HtmlParser.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/gwt/HtmlParserModule.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/gwt/ParseEndListener.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/AttributeName.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/CoalescingTreeBuilder.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/ElementName.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/ErrorReportingTokenizer.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/HotSpotWorkaround.txt trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/HtmlAttributes.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/LocatorImpl.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/MetaScanner.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/NCName.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/NamedCharacters.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/NamedCharactersAccel.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/Portability.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/PushedLocation.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/StackNode.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/StateSnapshot.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/TaintableLocatorImpl.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/Tokenizer.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/Tokenizer.java.orig trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/TreeBuilder.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/TreeBuilderState.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/UTF16Buffer.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/impl/package.html trunk/MXQuery/xqib_src/nu/validator/htmlparser/public/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/java/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/java/io/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/java/io/IOException.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/xml/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/xml/sax/ trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/xml/sax/Attributes.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/xml/sax/ErrorHandler.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/xml/sax/Locator.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/xml/sax/SAXException.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/xml/sax/SAXParseException.java trunk/MXQuery/xqib_src/nu/validator/htmlparser/translatable/org/xml/sax/package.html trunk/MXQuery/xqib_src/nu/validator/saxtree/ trunk/MXQuery/xqib_src/nu/validator/saxtree/CDATA.java trunk/MXQuery/xqib_src/nu/validator/saxtree/CharBufferNode.java trunk/MXQuery/xqib_src/nu/validator/saxtree/Characters.java trunk/MXQuery/xqib_src/nu/validator/saxtree/Comment.java trunk/MXQuery/xqib_src/nu/validator/saxtree/DTD.java trunk/MXQuery/xqib_src/nu/validator/saxtree/Document.java trunk/MXQuery/xqib_src/nu/validator/saxtree/DocumentFragment.java trunk/MXQuery/xqib_src/nu/validator/saxtree/Element.java trunk/MXQuery/xqib_src/nu/validator/saxtree/Entity.java trunk/MXQuery/xqib_src/nu/validator/saxtree/IgnorableWhitespace.java trunk/MXQuery/xqib_src/nu/validator/saxtree/LocatorImpl.java trunk/MXQuery/xqib_src/nu/validator/saxtree/Node.java trunk/MXQuery/xqib_src/nu/validator/saxtree/NodeType.java trunk/MXQuery/xqib_src/nu/validator/saxtree/NullLexicalHandler.java trunk/MXQuery/xqib_src/nu/validator/saxtree/ParentNode.java trunk/MXQuery/xqib_src/nu/validator/saxtree/PrefixMapping.java trunk/MXQuery/xqib_src/nu/validator/saxtree/ProcessingInstruction.java trunk/MXQuery/xqib_src/nu/validator/saxtree/SkippedEntity.java trunk/MXQuery/xqib_src/nu/validator/saxtree/TreeBuilder.java trunk/MXQuery/xqib_src/nu/validator/saxtree/TreeParser.java trunk/MXQuery/xqib_src/nu/validator/saxtree/package.html Removed Paths: ------------- trunk/MXQuery/gwt-2.1.0/ Modified: trunk/MXQuery/build.xml =================================================================== --- trunk/MXQuery/build.xml 2011-05-06 22:35:11 UTC (rev 4324) +++ trunk/MXQuery/build.xml 2011-05-08 16:32:28 UTC (rev 4325) @@ -522,14 +522,15 @@ <pathelement location="lib/junit.jar"/> <!--<pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>--> </path> - <path id="GWT SDK [GWT (1) - 2.1.0].libraryclasspath"> - <pathelement location="gwt-2.1.0/gwt-user.jar"/> - <pathelement location="gwt-2.1.0/gwt-dev.jar"/> + + <path id="GWT SDK.libraryclasspath"> + <pathelement location="gwt-2.3.0/gwt-user.jar"/> + <pathelement location="gwt-2.3.0/gwt-dev.jar"/> </path> <path id="MXQueryJS.classpath"> <pathelement location="${gwt_webclasses.dir}"/> <path refid="JUnit 4.libraryclasspath"/> - <path refid="GWT SDK [GWT (1) - 2.1.0].libraryclasspath"/> + <path refid="GWT SDK.libraryclasspath"/> </path> <path id="run.MXQueryJS.classpath"> <pathelement location="${xqibtmp.dir}"/> @@ -842,7 +843,7 @@ <path id="run.XQTS all.classpath"> <path refid="MXQueryJS.classpath"/> - <path refid="GWT SDK [GWT (1) - 2.1.0].libraryclasspath"/> + <path refid="GWT SDK.libraryclasspath"/> <pathelement location="${xqibjunit.dir}"/> <!--<pathelement location="xqib_test"/>--> <pathelement location="${xqibtmp.dir}"/> Added: trunk/MXQuery/gwt-2.3.0/gwt-dev.jar =================================================================== (Binary files differ) Property changes on: trunk/MXQuery/gwt-2.3.0/gwt-dev.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/MXQuery/gwt-2.3.0/gwt-user.jar =================================================================== (Binary files differ) Property changes on: trunk/MXQuery/gwt-2.3.0/gwt-user.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/MXQuery/xqib_NOTICE =================================================================== --- trunk/MXQuery/xqib_NOTICE 2011-05-06 22:35:11 UTC (rev 4324) +++ trunk/MXQuery/xqib_NOTICE 2011-05-08 16:32:28 UTC (rev 4325) @@ -13,4 +13,103 @@ - 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. Added: trunk/MXQuery/xqib_samples/data/test.html =================================================================== --- trunk/MXQuery/xqib_samples/data/test.html (rev 0) +++ trunk/MXQuery/xqib_samples/data/test.html 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset='utf-8'> +<title>Test doc</title> +</head> +<body> +<ul> +<li>B</li> +<li>A +<ul> +<li>3</li> +<li>1</li> +<li>2</li> +</ul> +</li> +<li>C</li> +</ul> +</body> +</html> Added: trunk/MXQuery/xqib_samples/tidy.html =================================================================== --- trunk/MXQuery/xqib_samples/tidy.html (rev 0) +++ trunk/MXQuery/xqib_samples/tidy.html 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>XQIB: Sample page</title> + <meta charset="UTF-8"/> + <link href="style.css" rel="stylesheet" type="text/css"> + <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script> + <script type="application/xquery"> + import module namespace http-client = "http://expath.org/ns/http-client"; + + declare updating function local:getWeather($loc, $evtObj) { + let $forecast := http-client:send-request( + <http-client:request href="data/test.html" method="get"/> + )[2] + return + + insert node + <div>{$forecast//li/ul}</div> + as last into b:dom()//body, + + delete node b:dom()//div + }; + + + b:addEventListener(b:dom()//input[@name="button"], "onclick", xs:QName("local:getWeather")) + + </script> + </head> + <body> + <a href="index.html"><< Index</a> + <h1>Weather forecast</h1> + <a href="WeatherREST.html">Page</a> | <a href="WeatherREST_source.html">Source</a> + <p/> + <input type="text" value="" style="font-size: 30pt; font-weight: bold" name="city"/> + <input type="button" value="Go!" style="font-size: 30pt; font-weight: bold" name="button"/> + <div><img src="JupiterZeus.gif"/></div> + </body> +</html> Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml 2011-05-06 22:35:11 UTC (rev 4324) +++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml 2011-05-08 16:32:28 UTC (rev 4325) @@ -14,7 +14,9 @@ <inherits name="ch.ethz.mxquery"/> <inherits name="java"/> -<inherits name="com.google.gwt.xml.XML" /> + <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" /> --> 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-06 22:35:11 UTC (rev 4324) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -15,31 +15,27 @@ package ch.ethz.mxquery.extensionsModules.expathhttp; -import java.io.BufferedInputStream; -import java.io.DataOutputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; +import java.util.Vector; +import org.xml.sax.SAXException; + +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.util.Hashtable; -import java.util.Vector; - import ch.ethz.mxquery.bindings.WindowFactory; import ch.ethz.mxquery.contextConfig.CompilerOptions; import ch.ethz.mxquery.contextConfig.Context; import ch.ethz.mxquery.datamodel.Identifier; import ch.ethz.mxquery.datamodel.IdentifierFactory; -import ch.ethz.mxquery.datamodel.MXQueryBinary; import ch.ethz.mxquery.datamodel.QName; import ch.ethz.mxquery.datamodel.Source; import ch.ethz.mxquery.datamodel.XQName; 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.ElementToken; import ch.ethz.mxquery.datamodel.xdm.NamedToken; import ch.ethz.mxquery.datamodel.xdm.TextToken; @@ -63,21 +59,18 @@ import ch.ethz.mxquery.query.PreparedStatement; import ch.ethz.mxquery.query.XQCompiler; import ch.ethz.mxquery.query.impl.CompilerImpl; -import ch.ethz.mxquery.update.store.domImpl.NodeStore; import ch.ethz.mxquery.util.Base64; -import ch.ethz.mxquery.util.LineReader; +import ch.ethz.mxquery.util.Hashtable; import ch.ethz.mxquery.util.LogLevel; import ch.ethz.mxquery.util.Logger; -import ch.ethz.mxquery.util.StringReader; -import ch.ethz.mxquery.util.browser.AsyncXmlHttpRequest; import ch.ethz.mxquery.util.browser.AsyncXmlHttpRequestWrapper; import ch.ethz.mxquery.util.browser.CachedDownloader; -import ch.ethz.mxquery.util.browser.SyncXmlHttpRequest; import ch.ethz.mxquery.util.browser.SyncXmlHttpRequestWrapper; -import ch.ethz.mxquery.util.browser.XmlHttpRequest; import ch.ethz.mxquery.util.browser.XmlHttpRequestWrappedHandler; import ch.ethz.mxquery.util.browser.XmlHttpRequestWrapper; -import ch.ethz.mxquery.xdmio.XDMInputFactory; +import ch.ethz.mxquery.util.browser.dom.DOMImpl; +import ch.ethz.mxquery.util.browser.dom.Document; +import ch.ethz.mxquery.util.browser.dom.Node; import ch.ethz.mxquery.xdmio.XDMSerializer; import ch.ethz.mxquery.xdmio.XDMSerializerSettings; @@ -761,19 +754,51 @@ // resIts[resIts.length - 1] = XDMInputFactory.createXMLInput( // context, new StringReader(result.toString()), false, // context.getInputValidationMode(), loc); - } else if (contentType.indexOf("html") >= 0) { - resIts[resIts.length - 1] = new TokenIterator(context, - new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, - createNextTokenId(3), conn.responseAsString(), - curNsScope), loc, false); + } else { + String responseString = conn.responseAsString(); + if (contentType.indexOf("html") >= 0) { +// resIts[resIts.length - 1] = new TokenIterator(context, +// new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, +// createNextTokenId(3), conn.responseAsString(), +// curNsScope), loc, false); // TODO tidy input + +// IFrameElement iframe = com.google.gwt.dom.client.Document.get().createIFrameElement(); +// iframe.setInnerHTML( ); + + + +// Document doc = DOMImpl.impl.getIFrameDocument(iframe); +// doc.write(conn.responseAsString()); + 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(); + } + + + resIts[resIts.length - 1] = new NodeStoreIterator( + doc); +// Element el = doc.getAsGwtDocument().getDocumentElement(); +// int crap =0; + +// Element el = com.google.gwt.dom.client.Document.get().createDivElement(); +// el.setInnerHTML(responseString); +// resIts[resIts.length - 1] = new NodeStoreIterator( +// Node.createFromGwtNode(el)); // resIts[resIts.length - 1] = XDMInputFactory.createTidyInput( // context, new StringReader(result.toString()), loc); - } else if (contentType.startsWith("text/") + } else if (contentType.startsWith("text/") || contentType.equalsIgnoreCase("application/xml-dtd")) { resIts[resIts.length - 1] = new TokenIterator(context, new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, - createNextTokenId(3), conn.responseAsString(), + createNextTokenId(3), responseString, curNsScope), loc, false); // TODO @@ -781,7 +806,7 @@ // new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, // createNextTokenId(3), result // .toString(), curNsScope), loc, false); - } else { // not identified => binary + } else { // not identified => binary // TODO // resIts[resIts.length - 1] = new TokenIterator(context, // new BinaryToken( @@ -789,6 +814,7 @@ // createNextTokenId(3), // new MXQueryBinary(data, Type.BASE64_BINARY), // curNsScope), loc, false); + } } } } Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java 2011-05-06 22:35:11 UTC (rev 4324) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -7,6 +7,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.IFrameElement; import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.TextAreaElement; @@ -173,4 +174,13 @@ return document.createElementNS(nameSpaceURI, localName); }-*/; + public native Document createDocument() /*-{ + return $doc.implementation.createDocument('http://www.w3.org/1999/xhtml', '', null); +}-*/; + +// public native Document getIFrameDocument(IFrameElement iframe) /*-{ +//// $wnd.ifr = iframe; +// return iframe.contentDocument.document; +//}-*/; + } Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Document.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Document.java 2011-05-06 22:35:11 UTC (rev 4324) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Document.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -1,5 +1,6 @@ package ch.ethz.mxquery.util.browser.dom; +import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.user.client.Window; public class Document extends Node{ @@ -25,4 +26,12 @@ public final native Node createComment(String value) /*-{ return this.createComment(value); }-*/; + + public static Document createDocument() { + return DOMImpl.impl.createDocument(); + } + + public final native void write(String str)/*-{ + this.write(str); + }-*/; } Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java 2011-05-06 22:35:11 UTC (rev 4324) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -10,6 +10,9 @@ } + public static Element createFromGwtNode(com.google.gwt.dom.client.Node n){ + return (Element)(Object)n; + } public final com.google.gwt.dom.client.Element getAsGwtElement() { return (com.google.gwt.dom.client.Element)(Object)this; Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,11 @@ +<module> + <inherits name="com.google.gwt.core.Core"/> + <inherits name="com.google.gwt.user.User"/> + <super-source path="translatable"/> + <source path="annotation"/> + <source path="common"/> + <source path="impl"/> + <source path="gwt"/> + <entry-point class="nu.validator.htmlparser.gwt.HtmlParserModule"/> + <add-linker name="sso"/> +</module> Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Auto.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Auto.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Auto.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2010 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +public @interface Auto { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/CharacterName.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/CharacterName.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/CharacterName.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2010 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +public @interface CharacterName { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Const.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Const.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Const.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2010 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * Marker for translating into the C++ const keyword on the declaration in + * question. + * + * @version $Id$ + * @author hsivonen + */ +public @interface Const { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/IdType.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/IdType.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/IdType.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * The type for attribute IDness. (In Java, an interned string + * <code>"CDATA"</code> or <code>"ID"</code>.) + * + * @version $Id$ + * @author hsivonen + */ +public @interface IdType { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Inline.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Inline.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Inline.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2009-2010 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * Translates into the C++ inline keyword. + * + * @version $Id$ + * @author hsivonen + */ +public @interface Inline { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Literal.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Literal.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Literal.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2009-2010 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * Marks a string type as being the literal string type (typically const char*) + * in C++. + * + * @version $Id$ + * @author hsivonen + */ +public @interface Literal { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Local.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Local.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Local.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * The local name of an element or attribute. Must be comparable with + * <code>==</code> (interned <code>String</code> in Java). + * + * @version $Id$ + * @author hsivonen + */ +public @interface Local { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/NoLength.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/NoLength.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/NoLength.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * The array type marked with this annotation won't have its + * <code>.length</code> read. + * + * @version $Id$ + * @author hsivonen + */ +public @interface NoLength { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/NsUri.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/NsUri.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/NsUri.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * The namespace URI type. (In Java, an interned <code>String</code>.) + * + * @version $Id$ + * @author hsivonen + */ +public @interface NsUri { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Prefix.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Prefix.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Prefix.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * The type for namespace prefixes. (In Java, an interned <code>String</code>.) + * + * @version $Id$ + * @author hsivonen + */ +public @interface Prefix { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/QName.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/QName.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/QName.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * The type for qualified names. (In Java, an interned <code>String</code>.) + * + * @version $Id$ + * @author hsivonen + */ +public @interface QName { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Virtual.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Virtual.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/Virtual.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.annotation; + +/** + * Marks a method as virtualy in C++. + * + * @version $Id$ + * @author hsivonen + */ +public @interface Virtual { + +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/package.html =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/package.html (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/annotation/package.html 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head><title>Package Overview</title> +<!-- + Copyright (c) 2008 Mozilla Foundation + + 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. +--> +</head> +<body bgcolor="white"> +<p>This package provides annotations for facilitating automated translation +of the source code into other programming languages.</p> +</body> +</html> \ No newline at end of file Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/ByteReadable.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/ByteReadable.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/ByteReadable.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007 Henri Sivonen + * Copyright (c) 2010 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.common; + +import java.io.IOException; + +/** + * An interface for providing a method for reading a stream of bytes one byte at + * a time. + * + * @version $Id$ + * @author hsivonen + */ +public interface ByteReadable { + /** + * Returns the value of the next byte as an integer from 0 to 0xFF or -1 if + * the stream has ended. + * + * @return integer from 0 to 0xFF or -1 on EOF + * @throws IOException + */ + public int readByte() throws IOException; +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/CharacterHandler.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/CharacterHandler.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/CharacterHandler.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2007-2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.common; + +import org.xml.sax.SAXException; + +/** + * An interface for receiving notifications of UTF-16 code units read from a character stream. + * + * @version $Id$ + * @author hsivonen + */ +public interface CharacterHandler { + + /** + * Receive notification of a run of UTF-16 code units. + * @param ch the buffer + * @param start start index in the buffer + * @param length the number of characters to process starting from <code>start</code> + * @throws SAXException if things go wrong + */ + public void characters(char[] ch, int start, int length) + throws SAXException; + + /** + * Signals the end of the stream. Can be used for cleanup. Doesn't mean that the stream ended successfully. + * + * @throws SAXException if things go wrong + */ + public void end() throws SAXException; + + /** + * Signals the start of the stream. Can be used for setup. + * + * @throws SAXException if things go wrong + */ + public void start() throws SAXException; + +} \ No newline at end of file Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DoctypeExpectation.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DoctypeExpectation.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DoctypeExpectation.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2007 Henri Sivonen + * + * 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. + */ + +package nu.validator.htmlparser.common; + +/** + * Used for indicating desired behavior with legacy doctypes. + * + * @version $Id$ + * @author hsivonen + */ +public enum DoctypeExpectation { + /** + * Be a pure HTML5 parser. + */ + HTML, + + /** + * Require the HTML 4.01 Transitional public id. Turn on HTML4-specific + * additional errors regardless of doctype. + */ + HTML401_TRANSITIONAL, + + /** + * Require the HTML 4.01 Transitional public id and a system id. Turn on + * HTML4-specific additional errors regardless of doctype. + */ + HTML401_STRICT, + + /** + * Treat the doctype required by HTML 5, doctypes with the HTML 4.01 Strict + * public id and doctypes with the HTML 4.01 Transitional public id and a + * system id as non-errors. Turn on HTML4-specific additional errors if the + * public id is the HTML 4.01 Strict or Transitional public id. + */ + AUTO, + + /** + * Never enable HTML4-specific error checks. Never report any doctype + * condition as an error. (Doctype tokens in wrong places will be + * reported as errors, though.) The application may decide what to log + * in response to calls to <code>DocumentModeHanler</code>. This mode + * in meant for doing surveys on existing content. + */ + NO_DOCTYPE_ERRORS +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DocumentMode.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DocumentMode.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DocumentMode.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2007 Henri Sivonen + * Copyright (c) 2008 Mozilla Foundation + * + * 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. + */ + +package nu.validator.htmlparser.common; + +/** + * Represents the HTML document compatibility mode. + * + * @version $Id$ + * @author hsivonen + */ +public enum DocumentMode { + /** + * The Standards Mode + */ + STANDARDS_MODE, + + /** + * The Limited Quirks Mode aka. The Almost Standards Mode + */ + ALMOST_STANDARDS_MODE, + + /** + * The Quirks Mode + */ + QUIRKS_MODE +} Added: trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DocumentModeHandler.java =================================================================== --- trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DocumentModeHandler.java (rev 0) +++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/common/DocumentModeHandler.java 2011-05-08 16:32:28 UTC (rev 4325) @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2007 Henri Sivonen + * + * 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, EXPR... [truncated message content] |
From: <et...@us...> - 2011-05-06 22:35:18
|
Revision: 4324 http://mxquery.svn.sourceforge.net/mxquery/?rev=4324&view=rev Author: etterth Date: 2011-05-06 22:35:11 +0000 (Fri, 06 May 2011) Log Message: ----------- - Added Timer - Fixed Timezone-related bug, which caused a wrong time to be returned in fn:currenttime() Modified Paths: -------------- trunk/MXQuery/xqib_src/ch/ethz/mxquery/datamodel/MXQueryDateTime.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/PlatformDependentUtils.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/util/Calendar.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/util/TimeZone.java Added Paths: ----------- trunk/MXQuery/xqib_samples/timer.html trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Timer.java Added: trunk/MXQuery/xqib_samples/timer.html =================================================================== --- trunk/MXQuery/xqib_samples/timer.html (rev 0) +++ trunk/MXQuery/xqib_samples/timer.html 2011-05-06 22:35:11 UTC (rev 4324) @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>XQIB: Sample page</title> + <meta charset="UTF-8"/> + <link href="style.css" rel="stylesheet" type="text/css"> + <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script> + <script type="application/xquery"> + declare updating function local:listener() { + insert node <div>{fn:current-time()}</div> as last into b:dom()//body +, b:timer(1000, xs:QName('local:listener')) + }; + + b:timer(1000, xs:QName('local:listener')) + + </script> + </head> + <body> + <h1>timer</h1> + + </body> +</html> Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/datamodel/MXQueryDateTime.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/datamodel/MXQueryDateTime.java 2011-05-06 10:18:30 UTC (rev 4323) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/datamodel/MXQueryDateTime.java 2011-05-06 22:35:11 UTC (rev 4324) @@ -897,7 +897,7 @@ // int offset = new GregorianCalendar().get(Calendar.ZONE_OFFSET); // int offset = Calendar.getInstance().get(Calendar.ZONE_OFFSET); // return getNewCalendar(offset); - return getNewCalendar(0); + return getNewCalendar(TimeZone.getDefault().getRawOffset()); } private static TimeZone getNewTimeZone(int zone_offset) { 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-06 10:18:30 UTC (rev 4323) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-06 22:35:11 UTC (rev 4324) @@ -211,6 +211,9 @@ } }; } + else { + throw new MXQueryException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "a qname has to be provided in an async expath function", getLoc()); + } XDMIterator[] oldsubiters = subIters; subIters = new XDMIterator[oldsubiters.length - 1]; for (int i = 1; i < oldsubiters.length; i++) { Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-06 10:18:30 UTC (rev 4323) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-06 22:35:11 UTC (rev 4324) @@ -454,6 +454,33 @@ qn = new QName( "http://xqib.org", "b", + "timer"); + paramTypes = new TypeInfo[2]; + + paramTypes[0] = new TypeInfo(getType( + "numeric",ctx),getOccur("numeric"),null); + + paramTypes[1] = new TypeInfo(getType( + "QName",ctx),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 = -1; + + function = new Function( + null,signature, + iter, null, type ); + fg.add(function); + } + + qn = new QName( + "http://xqib.org", + "b", "pageURI"); paramTypes = new TypeInfo[0]; Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Timer.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Timer.java (rev 0) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Timer.java 2011-05-06 22:35:11 UTC (rev 4324) @@ -0,0 +1,148 @@ +package ch.ethz.mxquery.functions.b; + +import java.util.Vector; + +import com.google.gwt.user.client.Window; + +import ch.ethz.mxqjs.client.Environment; +import ch.ethz.mxqjs.client.QnameAndArity; +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.MXQueryBigDecimal; +import ch.ethz.mxquery.datamodel.MXQueryDouble; +import ch.ethz.mxquery.datamodel.MXQueryFloat; +import ch.ethz.mxquery.datamodel.MXQueryNumber; +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.DecimalToken; +import ch.ethz.mxquery.datamodel.xdm.DoubleToken; +import ch.ethz.mxquery.datamodel.xdm.FloatToken; +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.exceptions.StaticException; +import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.extensionsModules.expathhttp.HttpIO; +import ch.ethz.mxquery.functions.fn.Abs; +import ch.ethz.mxquery.model.TokenBasedIterator; +import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.LogLevel; +import ch.ethz.mxquery.util.Logger; +import ch.ethz.mxquery.util.browser.XmlHttpRequestWrappedHandler; +import ch.ethz.mxquery.util.browser.XmlHttpRequestWrapper; + +public class Timer extends TokenBasedIterator { + + protected QName asynchandlername; + + @Override + protected void init() throws MXQueryException { + // TODO integer and timer + currentToken = Token.END_SEQUENCE_TOKEN; + if (subIters[0] == null) { + throw new IllegalArgumentException(); + } + XDMIterator handleriter = subIters[1]; + asynchandlername = handleriter.next().getQNameTokenValue(); + if (asynchandlername == null) { + throw new MXQueryException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "a qname has to be provided in b:timer", getLoc()); + } + XDMIterator timeiter = subIters[0]; + TokenInterface tok; + try { + tok = timeiter.next(); + } catch (TypeException de) { + if (de.getErrorCode().equals( + ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE)) + throw new DynamicException( + ErrorCodes.F0023_INVALID_VALUE_FOR_CAST_CONSTRUCTOR, + de.getMessage(), loc); + else + throw de; + } + + int type = Type.getEventTypeSubstituted(tok.getEventType(), + Context.getDictionary()); + + if (Type.isAttribute(type)) { + type = Type.getAttributeValueType(type); + } + + if (!Type.isNumericPrimitiveType(type)){ + throw new MXQueryException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "a numeric value has to be provided in b:timer", getLoc()); + } + + int time; + switch(type){ + case Type.INTEGER: + time = (int) tok.getLong(); + break; + case Type.DOUBLE: + case Type.FLOAT: + case Type.DECIMAL: + time = (int) tok.getNumber().getLongValue(); + break; + case Type.UNTYPED_ATOMIC: + case Type.UNTYPED: + time = new MXQueryDouble(tok.getValueAsString()).getIntValue(); + break; + default: + throw new TypeException(ErrorCodes.F0028_INVALID_ARGUMENT_TYPE, "Invalid argument type "+Type.getTypeQName(type, Context.getDictionary()), loc); +}//switch + if (this.getContext().getRootContext() + .getFunction(asynchandlername, 0) == null) { + throw new MXQueryException( + ErrorCodes.E0017_STATIC_DOESNT_MATCH_FUNCTION_SIGNATURE, + "the eventhandler with the name " + + asynchandlername.toString() + + " is not available in a timer call", + loc); + } + final Timer thisobj = this; + + com.google.gwt.user.client.Timer timerobj = new com.google.gwt.user.client.Timer() { + + @Override + public void run() { + + Logger log = Logger.getLogger(this.getClass().getName()); + log.log(LogLevel.FINER, "Invoking the TimerHandler " + thisobj.asynchandlername.toString()); + QnameAndArity qa = new QnameAndArity( + thisobj.asynchandlername, 0, thisobj.getContext() + .getRootContext()); + try { + Environment.invokeModule(qa, + new XDMIterator[] { }); + } catch (MXQueryException e) { + // TODO Auto-generated catch block + + Environment.displayErrorMessage(new StringBuffer(), null, e, + false); + e.printStackTrace(); + } + log.log(LogLevel.FINER, "TimerHandler " + thisobj.asynchandlername.toString() + " done"); + } + }; + timerobj.schedule(time); + + + } + + @Override + public TypeInfo getStaticType() { + return new TypeInfo(); + } + + @Override + protected XDMIterator copy(Context context, XDMIterator[] subIters, + Vector nestedPredCtxStack) throws MXQueryException { + XDMIterator copy = new Timer(); + copy.setContext(context, true); + copy.setSubIters(subIters); + return copy; + } + +} Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/PlatformDependentUtils.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/PlatformDependentUtils.java 2011-05-06 10:18:30 UTC (rev 4323) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/PlatformDependentUtils.java 2011-05-06 22:35:11 UTC (rev 4324) @@ -93,7 +93,7 @@ public static int getCurrentTimezoneOffset(){ Calendar cal = MXQueryDateTime.getNewCalendar(); TimeZone tz = cal.getTimeZone(); - return tz.getStandardOffset() / (1000 * 60); + return tz.getRawOffset() / (1000 * 60); } /** * Provide access to the current time @@ -105,7 +105,7 @@ TimeZone tz = cal.getTimeZone(); return new MXQueryDateTime(cal, - tz.getStandardOffset() , MXQueryDateTime.VALUE_TYPE_DATE_TIME); + tz.getRawOffset() / (1000 * 60) , MXQueryDateTime.VALUE_TYPE_DATE_TIME); } Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/util/Calendar.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/util/Calendar.java 2011-05-06 10:18:30 UTC (rev 4323) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/util/Calendar.java 2011-05-06 22:35:11 UTC (rev 4324) @@ -437,7 +437,7 @@ } else { - return timeZone.getStandardOffset(); + return timeZone.getRawOffset(); } // case DST_OFFSET: // //TODO, fix @@ -805,16 +805,29 @@ // } - Date date = new Date( - localDateTime.year, - localDateTime.month, - localDateTime.date, - localDateTime.hourOfDay, - localDateTime.minutes, - localDateTime.seconds); + Date datewithoutms = new Date( + localDateTime.year, + localDateTime.month, + localDateTime.date, + localDateTime.hourOfDay, + localDateTime.minutes, + localDateTime.seconds); - // Date class does not have milliseconds manipulation. - date.setTime(date.getTime() + localDateTime.milliseconds); + + // Date class does not have milliseconds manipulation. + Date datewithms = new Date(datewithoutms.getTime() + localDateTime.milliseconds); + localDateTime.year = datewithms.getYear(); + localDateTime.month = datewithms.getMonth(); + localDateTime.date = datewithms.getDate(); + localDateTime.hourOfDay = datewithms.getHours(); + localDateTime.minutes = datewithms.getMinutes(); + localDateTime.seconds = datewithms.getSeconds(); + localDateTime.milliseconds = (int) (datewithms.getTime() - datewithoutms.getTime()); + //milliseconds might have been negative + if (localDateTime.milliseconds < 0){ + localDateTime.milliseconds = - localDateTime.milliseconds; + } + localDateTime.milliseconds = localDateTime.milliseconds % 1000; // Store the rolled up fields back in the original LocalDateTime object. // setValuesFromDate(this.date); @@ -943,8 +956,8 @@ // Console.log("GWTDate createDate " + d); - int offsetConversion = d.getTimezoneOffset() - timeZone2.getStandardOffset(); - d.setMinutes(d.getMinutes() - offsetConversion); + int offsetConversion = -d.getTimezoneOffset()*60*1000 - timeZone2.getRawOffset(); + d.setTime(d.getTime() + offsetConversion); // d.setMinutes(d.getMinutes() - timeZone.timeZoneContainer.getTimeZone().getDaylightAdjustment(d)); return d; } @@ -954,7 +967,7 @@ return this.getTime().getTime(); } public static Calendar getInstance() { - return getInstance(new Date().getTimezoneOffset()); + return getInstance(TimeZone.getDefault().getRawOffset()); } public static Calendar getInstance(int zone_offset) { // TODO Auto-generated method stub @@ -968,8 +981,9 @@ } public void setTimeZone(TimeZone newTimeZone) { - this.localDateTime.minutes += this.timeZone.getStandardOffset()- newTimeZone.getStandardOffset() ; + this.localDateTime.milliseconds -= this.timeZone.getRawOffset()- newTimeZone.getRawOffset() ; this.timeZone = newTimeZone; + this.needsCalculation = true; } public TimeZone getTimeZone() { Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/util/TimeZone.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/util/TimeZone.java 2011-05-06 10:18:30 UTC (rev 4323) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/util/TimeZone.java 2011-05-06 22:35:11 UTC (rev 4324) @@ -5,19 +5,19 @@ public class TimeZone { - private int minutes_offset = 0; + private int milliseconds_offset = 0; public TimeZone(int zone_offset) { - minutes_offset = zone_offset; + milliseconds_offset = zone_offset; } public static TimeZone getDefault() { - return new TimeZone(new Date().getTimezoneOffset()); + return new TimeZone(-new Date().getTimezoneOffset()*1000*60); } /** - * @return the offset in minutes + * @return the offset in milliseconds */ - public int getStandardOffset() { - return minutes_offset; + public int getRawOffset() { + return milliseconds_offset; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-06 10:18:37
|
Revision: 4323 http://mxquery.svn.sourceforge.net/mxquery/?rev=4323&view=rev Author: maxspeicher Date: 2011-05-06 10:18:30 +0000 (Fri, 06 May 2011) Log Message: ----------- - minor fixes concerning Android testsuite - added dom-implementation-registry.jar to libs (not natively supported by Android) Modified Paths: -------------- trunk/MXQuery_Testing/build.xml Added Paths: ----------- trunk/MXQuery_Testing/lib/dom-implementation-registry.jar Modified: trunk/MXQuery_Testing/build.xml =================================================================== --- trunk/MXQuery_Testing/build.xml 2011-05-06 09:45:17 UTC (rev 4322) +++ trunk/MXQuery_Testing/build.xml 2011-05-06 10:18:30 UTC (rev 4323) @@ -29,6 +29,10 @@ <pathelement location="${build.dir}"/> <fileset dir="${resources.dir}"> <include name="*.jar"/> + <exclude name="j2meunit.jar"/> + <exclude name="xml-apis.jar"/> + <exclude name="serializer.jar"/> + <exclude name="xalan.jar"/> </fileset> <fileset dir="${sdk.dir}"> <include name="platforms/android-8/android.jar"/> @@ -197,7 +201,6 @@ <delete dir="${androidtmp.dir}/ch/ethz/mxquery/test/dmcq/"/> <delete> <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/test/"> - <include name="TypeTest.java"/> <include name="XQScriptingTest.java"/> <include name="XQUpdateTest.java"/> </fileset> @@ -205,14 +208,12 @@ <delete> <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/testsuite/"> <include name="TestSuiteGUI.java"/> - <include name="TestSuiteUpdate.java"/> </fileset> </delete> <delete> <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/testsuite/internal/"> <include name="CustomIcon.java"/> <include name="CustomListCellRenderer.java"/> - <include name="TestCaseUpdate.java"/> </fileset> </delete> </target> Added: trunk/MXQuery_Testing/lib/dom-implementation-registry.jar =================================================================== (Binary files differ) Property changes on: trunk/MXQuery_Testing/lib/dom-implementation-registry.jar ___________________________________________________________________ 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: <max...@us...> - 2011-05-06 09:45:23
|
Revision: 4322 http://mxquery.svn.sourceforge.net/mxquery/?rev=4322&view=rev Author: maxspeicher Date: 2011-05-06 09:45:17 +0000 (Fri, 06 May 2011) Log Message: ----------- minor fix concerning Android testsuite Modified Paths: -------------- trunk/MXQuery_Testing/build.xml Modified: trunk/MXQuery_Testing/build.xml =================================================================== --- trunk/MXQuery_Testing/build.xml 2011-05-06 09:39:47 UTC (rev 4321) +++ trunk/MXQuery_Testing/build.xml 2011-05-06 09:45:17 UTC (rev 4322) @@ -136,8 +136,9 @@ </fileset> </delete> - <mkdir dir="${build.dir}"/> - <mkdir dir="${dist.dir}"/> + <mkdir dir="${build.dir}"/> + <mkdir dir="${dist.dir}"/> + <mkdir dir="${androidtmp.dir}"/> </target> <target name="compile" depends="clean"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-06 09:39:53
|
Revision: 4321 http://mxquery.svn.sourceforge.net/mxquery/?rev=4321&view=rev Author: maxspeicher Date: 2011-05-06 09:39:47 +0000 (Fri, 06 May 2011) Log Message: ----------- added androidtmp directory for Android tests Added Paths: ----------- trunk/MXQuery_Testing/androidtmp/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-06 09:19:25
|
Revision: 4320 http://mxquery.svn.sourceforge.net/mxquery/?rev=4320&view=rev Author: maxspeicher Date: 2011-05-06 09:19:19 +0000 (Fri, 06 May 2011) Log Message: ----------- minor fix concerning Android testsuite Modified Paths: -------------- trunk/MXQuery_Testing/build.xml Modified: trunk/MXQuery_Testing/build.xml =================================================================== --- trunk/MXQuery_Testing/build.xml 2011-05-06 09:03:59 UTC (rev 4319) +++ trunk/MXQuery_Testing/build.xml 2011-05-06 09:19:19 UTC (rev 4320) @@ -45,7 +45,7 @@ <get dest="${resources.dir}/mxquery.jar" src="${buildhost}/MXQuery-14/lastSuccessfulBuild/artifact/MXQuery/dist/mxquery-14.jar"/> </target> <target name="getjar-android"> - <get dest="${resources.dir}/mxquery-android.jar" src="${buildhost}/MXQuery-Android/lastSuccessfulBuild/artifact/MXQuery/dist/mxquery-android.jar"/> + <get dest="${resources.dir}/mxquery-android.jar" src="${buildhost}/MXQuery-Android/lastSuccessfulBuild/artifact/dist/mxquery-android.jar"/> </target> <target name="clear-java14"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-06 09:04:06
|
Revision: 4319 http://mxquery.svn.sourceforge.net/mxquery/?rev=4319&view=rev Author: maxspeicher Date: 2011-05-06 09:03:59 +0000 (Fri, 06 May 2011) Log Message: ----------- added testsuite execution for Android Modified Paths: -------------- trunk/MXQuery_Testing/build.xml Modified: trunk/MXQuery_Testing/build.xml =================================================================== --- trunk/MXQuery_Testing/build.xml 2011-05-05 17:29:02 UTC (rev 4318) +++ trunk/MXQuery_Testing/build.xml 2011-05-06 09:03:59 UTC (rev 4319) @@ -10,6 +10,7 @@ <property name="build.dir" value="${root.dir}/build"/> <property name="dist.dir" value="${root.dir}/../MXQuery/dist"/> <property name="buildhost" value="http://fifthelement.inf.ethz.ch:8081/job"/> + <property name="androidtmp.dir" value="${root.dir}/androidtmp"/> <property name="midpsrc.dir" value="${root.dir}/midp_src"/> @@ -23,6 +24,16 @@ </fileset> <pathelement path="${java.class.path}"/> </path> + + <path id="android.class.path"> + <pathelement location="${build.dir}"/> + <fileset dir="${resources.dir}"> + <include name="*.jar"/> + </fileset> + <fileset dir="${sdk.dir}"> + <include name="platforms/android-8/android.jar"/> + </fileset> + </path> <target name="getjar"> <get dest="${resources.dir}/mxquery.jar" src="${buildhost}/MXQuery/lastSuccessfulBuild/artifact/MXQuery/dist/mxquery.jar"/> @@ -33,6 +44,9 @@ <target name="getjar-14"> <get dest="${resources.dir}/mxquery.jar" src="${buildhost}/MXQuery-14/lastSuccessfulBuild/artifact/MXQuery/dist/mxquery-14.jar"/> </target> + <target name="getjar-android"> + <get dest="${resources.dir}/mxquery-android.jar" src="${buildhost}/MXQuery-Android/lastSuccessfulBuild/artifact/MXQuery/dist/mxquery-android.jar"/> + </target> <target name="clear-java14"> <delete dir="${src.dir}/ch/ethz/mxquery/test/dmcq"/> @@ -40,12 +54,12 @@ <delete dir="${src.dir}/ch/ethz/mxquery/smstest"/> </target> - <target name="test" depends="compile" > + <target name="test" depends="compile" > <junit fork="yes" timeout="50000" showoutput="yes" printsummary="yes" dir="." > <formatter type="xml"/> <classpath refid="project.class.path"/> <batchtest todir="junit"> - <fileset dir="${src.dir}"> + <fileset dir="${src.dir}"> <include name="ch/ethz/mxquery/test/**/*.java"/> <include name="com/oracle/xqj/tck/testcases/*.java" /> <exclude name="**/BenchMark*.java"/> @@ -58,10 +72,10 @@ <exclude name="ch/ethz/mxquery/test/dmcq/experiments/OutputEvaluator.java"/> <exclude name="ch/ethz/mxquery/test/dmcq/experiments/RunInitializer.java"/> <exclude name="ch/ethz/mxquery/test/dmcq/LRexperiments/**/*.java"/> - <exclude name="**/XQJTestCase.java"/> + <exclude name="**/XQJTestCase.java"/> </fileset> </batchtest> - </junit> + </junit> </target> <target name="testsuite" depends="test"> <java classname="ch.ethz.mxquery.testsuite.TestSuiteNoGUI" @@ -69,7 +83,7 @@ fork="true"> <jvmarg value="-Xmx500m"/> </java> - </target> + </target> <target name="testsuite-dev" depends="testsuite"> <java classname="ch.ethz.mxquery.testsuite.TestSuiteNoGUI" @@ -96,6 +110,14 @@ <arg value="-ft"/> </java> </target> + + <target name="testsuite-android" depends="compile-android"> + <java classname="ch.ethz.mxquery.testsuite.TestSuiteNoGUI" + classpathref="android.class.path" + fork="true"> + <jvmarg value="-Xmx500m"/> + </java> + </target> <target name="clean"> <echo message="Cleaning directories..."/> @@ -108,7 +130,10 @@ </fileset> <fileset dir="${root.dir}/junit"> <include name="**/*"/> - </fileset> + </fileset> + <fileset dir="${androidtmp.dir}"> + <include name="**/*"/> + </fileset> </delete> <mkdir dir="${build.dir}"/> @@ -133,4 +158,62 @@ extdirs="" /> </target> -</project> + + <target name="compile-android" depends="clean,android-prepare"> + <echo message="Compiling..."/> + + <depend srcdir="${androidtmp.dir}" + destdir="${build.dir}" + cache="depcache" + closure="yes" + /> + + <javac source="${src.version}" + srcdir="${androidtmp.dir}" + destdir="${build.dir}" + classpathref="android.class.path" + debug="${debug}" + optimize="${optimize}" + extdirs="" + /> + </target> + + <target name="android-prepare"> + <!-- merge branches --> + <echo message="Merging source trees"/> + <delete> + <fileset dir="${androidtmp.dir}/"> + <include name="**/*"/> + </fileset> + </delete> + <copy todir="${androidtmp.dir}"> + <fileset dir="${src.dir}"/> + </copy> + + <!-- remove unsupported classes --> + <echo message="Removing unsupported classes"/> + <delete dir="${androidtmp.dir}/ch/ethz/mxquery/smstest/"/> + <delete dir="${androidtmp.dir}/ch/ethz/mxquery/test/dmcq/"/> + <delete> + <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/test/"> + <include name="TypeTest.java"/> + <include name="XQScriptingTest.java"/> + <include name="XQUpdateTest.java"/> + </fileset> + </delete> + <delete> + <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/testsuite/"> + <include name="TestSuiteGUI.java"/> + <include name="TestSuiteUpdate.java"/> + </fileset> + </delete> + <delete> + <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/testsuite/internal/"> + <include name="CustomIcon.java"/> + <include name="CustomListCellRenderer.java"/> + <include name="TestCaseUpdate.java"/> + </fileset> + </delete> + </target> + +</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-05 17:29:08
|
Revision: 4318 http://mxquery.svn.sourceforge.net/mxquery/?rev=4318&view=rev Author: maxspeicher Date: 2011-05-05 17:29:02 +0000 (Thu, 05 May 2011) Log Message: ----------- minor adjustments Modified Paths: -------------- 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/src/ch/ethz/mxquery/android/MXQueryService.java =================================================================== --- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java 2011-05-05 17:28:00 UTC (rev 4317) +++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java 2011-05-05 17:29:02 UTC (rev 4318) @@ -7,11 +7,11 @@ import android.os.Binder; import android.os.IBinder; import ch.ethz.mxquery.xqj.MXQueryXQDataSource; -import ch.ethz.xquery.XQConnection; -import ch.ethz.xquery.XQDataSource; -import ch.ethz.xquery.XQException; -import ch.ethz.xquery.XQExpression; -import ch.ethz.xquery.XQSequence; +import ch.ethz.repackaged.xquery.XQConnection; +import ch.ethz.repackaged.xquery.XQDataSource; +import ch.ethz.repackaged.xquery.XQException; +import ch.ethz.repackaged.xquery.XQExpression; +import ch.ethz.repackaged.xquery.XQSequence; public class MXQueryService extends Service { private XQDataSource xqjd = new MXQueryXQDataSource(); 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-05 17:28:00 UTC (rev 4317) +++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-05 17:29:02 UTC (rev 4318) @@ -22,277 +22,253 @@ import ch.ethz.mxquery.android.MXQueryService.MXQueryServiceBinder; public class Start extends Activity { - - protected final Activity mActivity = this; - protected Button mButton; - protected Spinner mSpinner; - protected EditText mInputView; - protected TextView mResultView; - //private XQueryAsyncTask mTask; - protected MXQueryService mService; - protected boolean mIsBound = false; - - public static final String STATE_CHANGE_SETTINGS = "STATE_CHANGE_SETTINGS"; - public static final int QUERY_RUNNING_DIALOG = 1; - - protected Dialog onCreateDialog(int id) { - ProgressDialog dialog = new ProgressDialog(mActivity); - dialog.setMessage("Query running..."); - dialog.setCancelable(true); - return dialog; - } - /* - protected class XQueryAsyncTask extends AsyncTask<String, Integer, String> { - - @Override - protected void onPreExecute() { - //clear results - mResultView.setText(""); - mActivity.showDialog(1); + protected final Activity mActivity = this; + protected Button mButton; + protected Spinner mSpinner; + protected EditText mInputView; + protected TextView mResultView; + // private XQueryAsyncTask mTask; + protected MXQueryService mService; + protected boolean mIsBound = false; + + public static final String STATE_CHANGE_SETTINGS = "STATE_CHANGE_SETTINGS"; + public static final int QUERY_RUNNING_DIALOG = 1; + + protected Dialog onCreateDialog(int id) { + ProgressDialog dialog = new ProgressDialog(mActivity); + dialog.setMessage("Query running..."); + dialog.setCancelable(true); + return dialog; } - + + /* + * protected class XQueryAsyncTask extends AsyncTask<String, Integer, + * String> { + * + * @Override protected void onPreExecute() { //clear results + * mResultView.setText(""); mActivity.showDialog(1); } + * + * @Override protected void onPostExecute(String result) { + * mResultView.setText(result); mActivity.removeDialog(1); //Note: don't use + * dismissDialog or progress spinner will not spin on subsequent runs } + * + * protected String doInBackground(String... query) { String output = new + * String(); try { output = runQuery(query[0]); } catch (MXQueryException e) + * { e.printStackTrace(); output = "Error: " + e.toString(); } return + * output; } + * + * private String runQuery(String query) throws MXQueryException { + * StringWriter result = new StringWriter(); + * + * try { XQDataSource xqjd = new MXQueryXQDataSource(); 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(); } } + */ + + /** Called when the activity is first created. */ @Override - protected void onPostExecute(String result) { - mResultView.setText(result); - mActivity.removeDialog(1); - //Note: don't use dismissDialog or progress spinner will not spin on subsequent runs + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.main); + mButton = (Button) findViewById(R.id.button); + mSpinner = (Spinner) findViewById(R.id.sample_query_spinner); + mInputView = (EditText) findViewById(R.id.inputEditText); + mResultView = (TextView) findViewById(R.id.resultsTextView); + + @SuppressWarnings("rawtypes") + ArrayAdapter adapter = ArrayAdapter.createFromResource(this, + R.array.queries, android.R.layout.simple_spinner_item); + + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + + mSpinner.setAdapter(adapter); + mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { + public void onItemSelected(AdapterView<?> parent, View view, + int pos, long id) { + String item = parent.getItemAtPosition(pos).toString(); + + if (item.equals(getString(R.string.hello_world))) { + mInputView.setText(getString(R.string.hello_world_xquery)); + } else if (item.equals(getString(R.string.addition))) { + mInputView.setText(getString(R.string.addition_xquery)); + } else if (item.equals(getString(R.string.flwor))) { + mInputView.setText(getString(R.string.flwor_xquery)); + } else if (item.equals(getString(R.string.function))) { + mInputView.setText(getString(R.string.function_xquery)); + } else if (item.equals(getString(R.string.namespace))) { + mInputView.setText(getString(R.string.namespace_xquery)); + } else if (item.equals(getString(R.string.fibonacci))) { + mInputView.setText(getString(R.string.fibonacci_xquery)); + } + } + + public void onNothingSelected(AdapterView<?> parent) { + // NOOP + } + }); + + // start service + if (!mIsBound) { + doBindService(); + } else { + // update UI with latest result + System.out.println("ALREADY BOUND, UPDATING UI"); + if (MXQueryService.lastResult != null) { + updateUI(MXQueryService.lastResult); + } + } + + mButton.setOnClickListener(new OnClickListener() { + public void onClick(View view) { + // run query with ASyncTask + // new + // XQueryAsyncTask().execute(mInputView.getText().toString()); + + // run query with Service + runQueryOnService(mInputView.getText().toString()); + } + }); + + /* + * The following is a code to test reading a query from a static file. + */ + /* + * BufferedReader in = new BufferedReader( new InputStreamReader( + * getResources().openRawResource(R.raw.test) ) ); + * + * String externalQuery = "", line; + * + * try { while ((line = in.readLine()) != null) { externalQuery += line; + * } + * + * XQueryAsyncTask task = new XQueryAsyncTask(); String output = + * task.execute(externalQuery).get(); + * + * mResultView.setText(output); } catch (Exception e) { + * e.printStackTrace(); }/* + */ } - - protected String doInBackground(String... query) { - String output = new String(); - try { - output = runQuery(query[0]); - } catch (MXQueryException e) { - e.printStackTrace(); - output = "Error: " + e.toString(); - } - return output; + + protected void runQueryOnService(String query) { + mResultView.setText(""); + mActivity.showDialog(QUERY_RUNNING_DIALOG); + + // ensure service is bound (should always be bound in onCreate...) + if (!mIsBound) { + doBindService(); + } + + mService.runQuery(query, queryListener); } - - private String runQuery(String query) throws MXQueryException { - StringWriter result = new StringWriter(); - try { - XQDataSource xqjd = new MXQueryXQDataSource(); - XQConnection xqjc = xqjd.getConnection(); - XQExpression xqje = xqjc.createExpression(); - XQSequence xqjs = xqje.executeQuery(query); + void doBindService() { + // Establish a connection with the service. We use an explicit + // class name because we want a specific service implementation that + // we know will be running in our own process (and thus won't be + // supporting component replacement by other applications). + bindService(new Intent(Start.this, MXQueryService.class), mConnection, + Context.BIND_AUTO_CREATE); + mIsBound = true; + } - xqjs.writeSequence(result, null); - xqjc.close(); - } catch (XQException xqe) { - xqe.printStackTrace(); - } + protected void onStart() { + super.onStart(); - return result.toString(); + // Bind to MXQueryService + Intent intent = new Intent(this, MXQueryService.class); + bindService(intent, mConnection, Context.BIND_AUTO_CREATE); } - } - */ - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.main); - mButton = (Button) findViewById(R.id.button); - mSpinner = (Spinner) findViewById(R.id.sample_query_spinner); - mInputView = (EditText) findViewById(R.id.inputEditText); - mResultView = (TextView) findViewById(R.id.resultsTextView); - - @SuppressWarnings("rawtypes") - ArrayAdapter adapter = ArrayAdapter.createFromResource( - this, R.array.queries, android.R.layout.simple_spinner_item - ); - - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - - mSpinner.setAdapter(adapter); - mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { - String item = parent.getItemAtPosition(pos).toString(); - - if (item.equals(getString(R.string.hello_world))) { - mInputView.setText(getString(R.string.hello_world_xquery)); - } else if (item.equals(getString(R.string.addition))) { - mInputView.setText(getString(R.string.addition_xquery)); - } else if (item.equals(getString(R.string.flwor))) { - mInputView.setText(getString(R.string.flwor_xquery)); - } else if (item.equals(getString(R.string.function))) { - mInputView.setText(getString(R.string.function_xquery)); - } else if (item.equals(getString(R.string.namespace))) { - mInputView.setText(getString(R.string.namespace_xquery)); - } else if (item.equals(getString(R.string.fibonacci))) { - mInputView.setText(getString(R.string.fibonacci_xquery)); + + @Override + protected void onStop() { + super.onStop(); + + // Unbind from the service + if (mIsBound) { + unbindService(mConnection); + mIsBound = false; } - } + } - @Override - public void onNothingSelected(AdapterView<?> parent) { - // NOOP - } - }); - - //start service - if(!mIsBound) { - doBindService(); - } else { - //update UI with latest result - System.out.println("ALREADY BOUND, UPDATING UI"); - if(mService.lastResult != null) { - updateUI(mService.lastResult); - } - } - - mButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - //run query with ASyncTask - //new XQueryAsyncTask().execute(mInputView.getText().toString()); - - //run query with Service - runQueryOnService(mInputView.getText().toString()); - } - }); - - /* - * The following is a code to test reading a query from a static file. - */ - /*BufferedReader in = new BufferedReader( - new InputStreamReader( - getResources().openRawResource(R.raw.test) - ) - ); - - String externalQuery = "", line; - - try { - while ((line = in.readLine()) != null) { - externalQuery += line; - } - - XQueryAsyncTask task = new XQueryAsyncTask(); - String output = task.execute(externalQuery).get(); - - mResultView.setText(output); - } catch (Exception e) { - e.printStackTrace(); - }/**/ - } - - protected void runQueryOnService(String query) { - mResultView.setText(""); - mActivity.showDialog(QUERY_RUNNING_DIALOG); - - //ensure service is bound (should always be bound in onCreate...) - if(!mIsBound) { - doBindService(); + @Override + public void onPause() { + super.onPause(); + + SharedPreferences settings = getSharedPreferences( + STATE_CHANGE_SETTINGS, 0); + SharedPreferences.Editor editor = settings.edit(); + editor.putString("input", mInputView.getText().toString()); + editor.putString("results", mResultView.getText().toString()); + editor.commit(); } - - mService.runQuery(query, queryListener); - } - - void doBindService() { - // Establish a connection with the service. We use an explicit - // class name because we want a specific service implementation that - // we know will be running in our own process (and thus won't be - // supporting component replacement by other applications). - bindService(new Intent(Start.this, MXQueryService.class), mConnection, Context.BIND_AUTO_CREATE); - mIsBound = true; - } - - protected void onStart() { - super.onStart(); - - // Bind to MXQueryService - Intent intent = new Intent(this, MXQueryService.class); - bindService(intent, mConnection, Context.BIND_AUTO_CREATE); - } + @Override + public void onResume() { + super.onResume(); - @Override - protected void onStop() { - super.onStop(); - - // Unbind from the service - if (mIsBound) { - unbindService(mConnection); - mIsBound = false; - } - } + SharedPreferences settings = getSharedPreferences( + STATE_CHANGE_SETTINGS, 0); + if (settings.contains("input")) { + mInputView.setText(settings.getString("input", "\"Hello World\"")); + } + if (settings.contains("results")) { + mResultView.setText(settings.getString("results", "")); + } + } - @Override - public void onPause() { - super.onPause(); - - SharedPreferences settings = getSharedPreferences(STATE_CHANGE_SETTINGS, 0); - SharedPreferences.Editor editor = settings.edit(); - editor.putString("input", mInputView.getText().toString()); - editor.putString("results", mResultView.getText().toString()); - editor.commit(); - } - - @Override - public void onResume() { - super.onResume(); - - SharedPreferences settings = getSharedPreferences(STATE_CHANGE_SETTINGS, 0); - if(settings.contains("input")) { - mInputView.setText(settings.getString("input", "\"Hello World\"")); - } - if(settings.contains("results")) { - mResultView.setText(settings.getString("results", "")); - } - } - - @Override - public void onDestroy() { - SharedPreferences settings = getSharedPreferences(STATE_CHANGE_SETTINGS, 0); - SharedPreferences.Editor editor = settings.edit(); - editor.clear(); - editor.commit(); - - super.onDestroy(); - } - - /** Defines callbacks for service binding, passed to bindService() */ - private ServiceConnection mConnection = new ServiceConnection() { + @Override + public void onDestroy() { + SharedPreferences settings = getSharedPreferences( + STATE_CHANGE_SETTINGS, 0); + SharedPreferences.Editor editor = settings.edit(); + editor.clear(); + editor.commit(); - @Override - public void onServiceConnected(ComponentName className, IBinder service) { - // We've bound to MXQueryService, cast the IBinder and get MXQueryService instance - MXQueryServiceBinder binder = (MXQueryServiceBinder) service; - mService = binder.getService(); - mIsBound = true; - - //update UI with latest result - System.out.println("onServiceConnected:" + mService.lastResult); - if(mService.lastResult != null) { - updateUI(mService.lastResult); - } - } + super.onDestroy(); + } - @Override - public void onServiceDisconnected(ComponentName arg0) { - mIsBound = false; - } - }; + /** Defines callbacks for service binding, passed to bindService() */ + private ServiceConnection mConnection = new ServiceConnection() { - protected XQueryListener queryListener = new XQueryListener() { - public void queryResult(final String result) { - runOnUiThread(new Runnable() { - public void run() { - updateUI(result); + public void onServiceConnected(ComponentName className, IBinder service) { + // We've bound to MXQueryService, cast the IBinder and get + // MXQueryService instance + MXQueryServiceBinder binder = (MXQueryServiceBinder) service; + mService = binder.getService(); + mIsBound = true; + + // update UI with latest result + System.out.println("onServiceConnected:" + MXQueryService.lastResult); + if (MXQueryService.lastResult != null) { + updateUI(MXQueryService.lastResult); + } } - }); + + public void onServiceDisconnected(ComponentName arg0) { + mIsBound = false; + } + }; + + protected XQueryListener queryListener = new XQueryListener() { + public void queryResult(final String result) { + runOnUiThread(new Runnable() { + public void run() { + updateUI(result); + } + }); + } + }; + + protected void updateUI(String result) { + System.out.println("Updating UI now..."); + mResultView.setText(result); + mActivity.removeDialog(QUERY_RUNNING_DIALOG); } - }; - - protected void updateUI(String result) { - System.out.println("Updating UI now..."); - mResultView.setText(result); - mActivity.removeDialog(QUERY_RUNNING_DIALOG); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-05 17:28:06
|
Revision: 4317 http://mxquery.svn.sourceforge.net/mxquery/?rev=4317&view=rev Author: maxspeicher Date: 2011-05-05 17:28:00 +0000 (Thu, 05 May 2011) Log Message: ----------- removed unnecessary lib imports from Android jar build target Modified Paths: -------------- trunk/MXQuery/build.xml Modified: trunk/MXQuery/build.xml =================================================================== --- trunk/MXQuery/build.xml 2011-05-05 17:21:27 UTC (rev 4316) +++ trunk/MXQuery/build.xml 2011-05-05 17:28:00 UTC (rev 4317) @@ -1169,8 +1169,6 @@ <target name="jar-android" depends="compile-android"> <echo message="Creating jar archive..."/> <unjar src="${resources.dir}/kxml2-min-2.3.0.jar" dest="${build.dir}"></unjar> - <unjar src="${resources.dir}/xmlpull_1_1_3_4c.jar" dest="${build.dir}"></unjar> - <unjar src="${resources.dir}/jax-1_1-fr-qname-class.jar" dest="${build.dir}"></unjar> <unjar src="${resources.dir}/xercesImpl.jar" dest="${build.dir}"></unjar> <unjar src="${android.dir}/lib/jsr173_1.0_api-repackaged.jar" dest="${build.dir}"></unjar> <unjar src="${resources.dir}/tagsoup-1.2.jar" dest="${build.dir}"></unjar> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <max...@us...> - 2011-05-05 17:21:33
|
Revision: 4316 http://mxquery.svn.sourceforge.net/mxquery/?rev=4316&view=rev Author: maxspeicher Date: 2011-05-05 17:21:27 +0000 (Thu, 05 May 2011) Log Message: ----------- removed util package from Android branch Removed Paths: ------------- trunk/MXQuery/android/src/ch/ethz/mxquery/util/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2011-05-05 15:41:40
|
Revision: 4315 http://mxquery.svn.sourceforge.net/mxquery/?rev=4315&view=rev Author: timchurch Date: 2011-05-05 15:41:33 +0000 (Thu, 05 May 2011) Log Message: ----------- Initial commit to the new Android App repo Added Paths: ----------- trunk/MXQuery_Android_App/AndroidManifest.xml trunk/MXQuery_Android_App/default.properties trunk/MXQuery_Android_App/proguard.cfg trunk/MXQuery_Android_App/res/ trunk/MXQuery_Android_App/res/drawable-hdpi/ trunk/MXQuery_Android_App/res/drawable-hdpi/icon.png trunk/MXQuery_Android_App/res/drawable-ldpi/ trunk/MXQuery_Android_App/res/drawable-ldpi/icon.png trunk/MXQuery_Android_App/res/drawable-mdpi/ trunk/MXQuery_Android_App/res/drawable-mdpi/icon.png trunk/MXQuery_Android_App/res/layout/ trunk/MXQuery_Android_App/res/layout/main.xml trunk/MXQuery_Android_App/res/raw/ trunk/MXQuery_Android_App/res/raw/test.xq trunk/MXQuery_Android_App/res/values/ trunk/MXQuery_Android_App/res/values/strings.xml trunk/MXQuery_Android_App/src/ trunk/MXQuery_Android_App/src/ch/ trunk/MXQuery_Android_App/src/ch/ethz/ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/XQueryListener.java Property Changed: ---------------- trunk/MXQuery_Android_App/ Property changes on: trunk/MXQuery_Android_App ___________________________________________________________________ Added: svn:ignore + bin Added: trunk/MXQuery_Android_App/AndroidManifest.xml =================================================================== --- trunk/MXQuery_Android_App/AndroidManifest.xml (rev 0) +++ trunk/MXQuery_Android_App/AndroidManifest.xml 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="ch.ethz.mxquery.android" + android:versionCode="1" + android:versionName="1.0"> + + <application android:icon="@drawable/icon" android:label="@string/app_name"> + <activity android:name="Start"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + + <service android:name="MXQueryService"/> + </application> +</manifest> \ No newline at end of file Added: trunk/MXQuery_Android_App/default.properties =================================================================== --- trunk/MXQuery_Android_App/default.properties (rev 0) +++ trunk/MXQuery_Android_App/default.properties 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-8 Added: trunk/MXQuery_Android_App/proguard.cfg =================================================================== --- trunk/MXQuery_Android_App/proguard.cfg (rev 0) +++ trunk/MXQuery_Android_App/proguard.cfg 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1,36 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native <methods>; +} + +-keepclasseswithmembernames class * { + public <init>(android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembernames class * { + public <init>(android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} Added: trunk/MXQuery_Android_App/res/drawable-hdpi/icon.png =================================================================== (Binary files differ) Property changes on: trunk/MXQuery_Android_App/res/drawable-hdpi/icon.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/MXQuery_Android_App/res/drawable-ldpi/icon.png =================================================================== (Binary files differ) Property changes on: trunk/MXQuery_Android_App/res/drawable-ldpi/icon.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/MXQuery_Android_App/res/drawable-mdpi/icon.png =================================================================== (Binary files differ) Property changes on: trunk/MXQuery_Android_App/res/drawable-mdpi/icon.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/MXQuery_Android_App/res/layout/main.xml =================================================================== --- trunk/MXQuery_Android_App/res/layout/main.xml (rev 0) +++ trunk/MXQuery_Android_App/res/layout/main.xml 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:fillViewport="true"> + <LinearLayout android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical"> + <TextView android:id="@+id/sampleQueryLabel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center" + android:text="@string/queries_prompt" /> + <Spinner android:id="@+id/sample_query_spinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + <TextView android:id="@+id/inputLabel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center" + android:text="@string/queries_prompt2" /> + <EditText android:id="@+id/inputEditText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="textMultiLine" + android:text="" /> + <Button android:id="@+id/button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/button_text" /> + <TextView android:id="@+id/resultsLabel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="left" + android:text="@string/results_label" /> + <TextView android:id="@+id/resultsTextView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="textMultiLine" + android:text=""/> + </LinearLayout> +</ScrollView> Added: trunk/MXQuery_Android_App/res/raw/test.xq =================================================================== --- trunk/MXQuery_Android_App/res/raw/test.xq (rev 0) +++ trunk/MXQuery_Android_App/res/raw/test.xq 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1 @@ +"Hello World, from a separate file!" \ No newline at end of file Added: trunk/MXQuery_Android_App/res/values/strings.xml =================================================================== --- trunk/MXQuery_Android_App/res/values/strings.xml (rev 0) +++ trunk/MXQuery_Android_App/res/values/strings.xml 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">MXQuery</string> + + <!-- UI Strings --> + <string name="queries_prompt">Choose a sample query...</string> + <string name="queries_prompt2">...or enter your query here:</string> + <string name="button_text">Run Query</string> + <string name="results_label">Results:</string> + <!-- End UI Strings --> + + <string-array name="queries"> + <item>@string/hello_world</item> + <item>@string/addition</item> + <item>@string/flwor</item> + <item>@string/function</item> + <item>@string/namespace</item> + <item>@string/fibonacci</item> + </string-array> + + <string name="hello_world">Hello World</string> + <string name="addition">Addition</string> + <string name="flwor">FLWOR Expression</string> + <string name="function">Function</string> + <string name="namespace">Namespace</string> + <string name="fibonacci">Fibonacci</string> + + <string name="hello_world_xquery">\"Hello World\"</string> + <string name="addition_xquery">5+5</string> + <string name="flwor_xquery"> + let $y := <a><b>1</b><b>2</b><b>3</b></a> \n + for $x in $y//b \n + where ($x cast as xs:integer) ge 2 \n + return $x + </string> + <string name="function_xquery"> + declare function local:doubler($x) { $x * 2 }; \n + local:doubler(42) + </string> + <string name="namespace_xquery"> + declare namespace c = \"http://c.com\";\n\n + let $x := <a><b id=\"1\" /><b c:id=\"1\" /></a>\n + return $x//b[@c:id eq \"1\"] + </string> + <string name="fibonacci_xquery"> + declare function local:fib-recur($n as xs:integer) as xs:integer? {\n + if ($n < 0) then ()\n + else if ($n=0) then 0\n + else if ($n=1) then 1\n + else local:fib-recur($n - 1) + local:fib-recur($n - 2)\n + };\n\n + local:fib-recur(10) + </string> + +</resources> Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java =================================================================== --- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java (rev 0) +++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/MXQueryService.java 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1,81 @@ +package ch.ethz.mxquery.android; + +import java.io.StringWriter; + +import android.app.Service; +import android.content.Intent; +import android.os.Binder; +import android.os.IBinder; +import ch.ethz.mxquery.xqj.MXQueryXQDataSource; +import ch.ethz.xquery.XQConnection; +import ch.ethz.xquery.XQDataSource; +import ch.ethz.xquery.XQException; +import ch.ethz.xquery.XQExpression; +import ch.ethz.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(); + + /** + * 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; + } + + /** 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 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); + + xqjs.writeSequence(result, null); + xqjc.close(); + } catch (XQException xqe) { + xqe.printStackTrace(); + } + + return result.toString(); + } + +} Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java =================================================================== --- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java (rev 0) +++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1,298 @@ +package ch.ethz.mxquery.android; + +import android.app.Activity; +import android.app.Dialog; +import android.app.ProgressDialog; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.os.IBinder; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.TextView; +import ch.ethz.mxquery.android.MXQueryService.MXQueryServiceBinder; + +public class Start extends Activity { + + protected final Activity mActivity = this; + protected Button mButton; + protected Spinner mSpinner; + protected EditText mInputView; + protected TextView mResultView; + //private XQueryAsyncTask mTask; + protected MXQueryService mService; + protected boolean mIsBound = false; + + + public static final String STATE_CHANGE_SETTINGS = "STATE_CHANGE_SETTINGS"; + public static final int QUERY_RUNNING_DIALOG = 1; + + protected Dialog onCreateDialog(int id) { + ProgressDialog dialog = new ProgressDialog(mActivity); + dialog.setMessage("Query running..."); + dialog.setCancelable(true); + return dialog; + } + /* + protected class XQueryAsyncTask extends AsyncTask<String, Integer, String> { + + @Override + protected void onPreExecute() { + //clear results + mResultView.setText(""); + mActivity.showDialog(1); + } + + @Override + protected void onPostExecute(String result) { + mResultView.setText(result); + mActivity.removeDialog(1); + //Note: don't use dismissDialog or progress spinner will not spin on subsequent runs + } + + protected String doInBackground(String... query) { + String output = new String(); + try { + output = runQuery(query[0]); + } catch (MXQueryException e) { + e.printStackTrace(); + output = "Error: " + e.toString(); + } + return output; + } + + private String runQuery(String query) throws MXQueryException { + StringWriter result = new StringWriter(); + + try { + XQDataSource xqjd = new MXQueryXQDataSource(); + 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(); + } + } + */ + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.main); + mButton = (Button) findViewById(R.id.button); + mSpinner = (Spinner) findViewById(R.id.sample_query_spinner); + mInputView = (EditText) findViewById(R.id.inputEditText); + mResultView = (TextView) findViewById(R.id.resultsTextView); + + @SuppressWarnings("rawtypes") + ArrayAdapter adapter = ArrayAdapter.createFromResource( + this, R.array.queries, android.R.layout.simple_spinner_item + ); + + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + + mSpinner.setAdapter(adapter); + mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { + String item = parent.getItemAtPosition(pos).toString(); + + if (item.equals(getString(R.string.hello_world))) { + mInputView.setText(getString(R.string.hello_world_xquery)); + } else if (item.equals(getString(R.string.addition))) { + mInputView.setText(getString(R.string.addition_xquery)); + } else if (item.equals(getString(R.string.flwor))) { + mInputView.setText(getString(R.string.flwor_xquery)); + } else if (item.equals(getString(R.string.function))) { + mInputView.setText(getString(R.string.function_xquery)); + } else if (item.equals(getString(R.string.namespace))) { + mInputView.setText(getString(R.string.namespace_xquery)); + } else if (item.equals(getString(R.string.fibonacci))) { + mInputView.setText(getString(R.string.fibonacci_xquery)); + } + } + + @Override + public void onNothingSelected(AdapterView<?> parent) { + // NOOP + } + }); + + //start service + if(!mIsBound) { + doBindService(); + } else { + //update UI with latest result + System.out.println("ALREADY BOUND, UPDATING UI"); + if(mService.lastResult != null) { + updateUI(mService.lastResult); + } + } + + mButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + //run query with ASyncTask + //new XQueryAsyncTask().execute(mInputView.getText().toString()); + + //run query with Service + runQueryOnService(mInputView.getText().toString()); + } + }); + + /* + * The following is a code to test reading a query from a static file. + */ + /*BufferedReader in = new BufferedReader( + new InputStreamReader( + getResources().openRawResource(R.raw.test) + ) + ); + + String externalQuery = "", line; + + try { + while ((line = in.readLine()) != null) { + externalQuery += line; + } + + XQueryAsyncTask task = new XQueryAsyncTask(); + String output = task.execute(externalQuery).get(); + + mResultView.setText(output); + } catch (Exception e) { + e.printStackTrace(); + }/**/ + } + + protected void runQueryOnService(String query) { + mResultView.setText(""); + mActivity.showDialog(QUERY_RUNNING_DIALOG); + + //ensure service is bound (should always be bound in onCreate...) + if(!mIsBound) { + doBindService(); + } + + mService.runQuery(query, queryListener); + } + + void doBindService() { + // Establish a connection with the service. We use an explicit + // class name because we want a specific service implementation that + // we know will be running in our own process (and thus won't be + // supporting component replacement by other applications). + bindService(new Intent(Start.this, MXQueryService.class), mConnection, Context.BIND_AUTO_CREATE); + mIsBound = true; + } + + + protected void onStart() { + super.onStart(); + + // Bind to MXQueryService + Intent intent = new Intent(this, MXQueryService.class); + bindService(intent, mConnection, Context.BIND_AUTO_CREATE); + } + + @Override + protected void onStop() { + super.onStop(); + + // Unbind from the service + if (mIsBound) { + unbindService(mConnection); + mIsBound = false; + } + } + + @Override + public void onPause() { + super.onPause(); + + SharedPreferences settings = getSharedPreferences(STATE_CHANGE_SETTINGS, 0); + SharedPreferences.Editor editor = settings.edit(); + editor.putString("input", mInputView.getText().toString()); + editor.putString("results", mResultView.getText().toString()); + editor.commit(); + } + + @Override + public void onResume() { + super.onResume(); + + SharedPreferences settings = getSharedPreferences(STATE_CHANGE_SETTINGS, 0); + if(settings.contains("input")) { + mInputView.setText(settings.getString("input", "\"Hello World\"")); + } + if(settings.contains("results")) { + mResultView.setText(settings.getString("results", "")); + } + } + + @Override + public void onDestroy() { + SharedPreferences settings = getSharedPreferences(STATE_CHANGE_SETTINGS, 0); + SharedPreferences.Editor editor = settings.edit(); + editor.clear(); + editor.commit(); + + super.onDestroy(); + } + + /** Defines callbacks for service binding, passed to bindService() */ + private ServiceConnection mConnection = new ServiceConnection() { + + @Override + public void onServiceConnected(ComponentName className, IBinder service) { + // We've bound to MXQueryService, cast the IBinder and get MXQueryService instance + MXQueryServiceBinder binder = (MXQueryServiceBinder) service; + mService = binder.getService(); + mIsBound = true; + + //update UI with latest result + System.out.println("onServiceConnected:" + mService.lastResult); + if(mService.lastResult != null) { + updateUI(mService.lastResult); + } + } + + @Override + public void onServiceDisconnected(ComponentName arg0) { + mIsBound = false; + } + }; + + protected XQueryListener queryListener = new XQueryListener() { + public void queryResult(final String result) { + runOnUiThread(new Runnable() { + public void run() { + updateUI(result); + } + }); + } + }; + + protected void updateUI(String result) { + System.out.println("Updating UI now..."); + mResultView.setText(result); + mActivity.removeDialog(QUERY_RUNNING_DIALOG); + } +} Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/XQueryListener.java =================================================================== --- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/XQueryListener.java (rev 0) +++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/XQueryListener.java 2011-05-05 15:41:33 UTC (rev 4315) @@ -0,0 +1,5 @@ +package ch.ethz.mxquery.android; + +public interface XQueryListener { + public void queryResult(final String result); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |