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-06-20 16:06:46
|
Revision: 4414
http://mxquery.svn.sourceforge.net/mxquery/?rev=4414&view=rev
Author: pm_fischer
Date: 2011-06-20 16:06:40 +0000 (Mon, 20 Jun 2011)
Log Message:
-----------
- Fix reusability of PreparedExpressions in XQJ
- TokenSequenceIterator now takes a Context in its constructor
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java
trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/AvailEnvVars.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Fold.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/ft/ScoreSequence.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/ft/FTContainsIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/model/TokenSequenceIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/xqj/FlatItem.java
trunk/MXQuery/src/ch/ethz/mxquery/xqj/Item.java
trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java
trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java
trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQPreparedExpression.java
trunk/MXQuery/src/ch/ethz/mxquery/xqj/TreeItem.java
trunk/MXQuery/src/examples/XQJExample.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -236,13 +236,15 @@
if (value.isClosed())
throw new XQException("Item is closed, cannot bind it");
+ Context ctx = this.getRuntime();
+
if (value instanceof MXQueryXQItem) {
MXQueryXQItem mxqItem = (MXQueryXQItem) value;
try {
if(this instanceof MXQueryXQPreparedExpression)
- this.getRuntime().setVariableValue(qn, mxqItem.curIt.getAsIterator(), true);
+ ctx.setVariableValue(qn, mxqItem.curIt.getAsIterator(ctx), true);
else
- this.getRuntime().bindVariableValue(qn, mxqItem.curIt.getAsIterator());
+ ctx.bindVariableValue(qn, mxqItem.curIt.getAsIterator(ctx));
} catch (MXQueryException e) {
throw new XQQueryException(e.toString(),PlatformDependentUtils.getJavaxQName(e.getErrorCode()));
}
@@ -429,19 +431,22 @@
while (value.next()) {
items.add( value.getItem());
}
+
+ Context ctx = this.getRuntime();
+
XDMIterator [] seqIters = new XDMIterator[items.size()];
for (int i=0;i<seqIters.length;i++) {
- seqIters[i] = ((MXQueryXQItem)items.get(i)).curIt.getAsIterator();
+ seqIters[i] = ((MXQueryXQItem)items.get(i)).curIt.getAsIterator(ctx);
}
- SequenceIterator seq = new SequenceIterator(new Context(),seqIters,QueryLocation.OUTSIDE_QUERY_LOC);
+ SequenceIterator seq = new SequenceIterator(ctx,seqIters,QueryLocation.OUTSIDE_QUERY_LOC);
try {
if(this instanceof MXQueryXQPreparedExpression)
- this.getRuntime().setVariableValue(new ch.ethz.mxquery.datamodel.QName(varName.toString()), seq, true);
+ ctx.setVariableValue(new ch.ethz.mxquery.datamodel.QName(varName.toString()), seq, true);
else
- this.getRuntime().bindVariableValue(new ch.ethz.mxquery.datamodel.QName(varName.toString()), seq);
+ ctx.bindVariableValue(new ch.ethz.mxquery.datamodel.QName(varName.toString()), seq);
} catch (MXQueryException e) {
throw new XQQueryException(e.toString(),PlatformDependentUtils.getJavaxQName(e.getErrorCode()));
}
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -171,7 +171,7 @@
throw new XQException("Cannot write to null handler");
Token2SaxAdapter toS;
try {
- toS = new Token2SaxAdapter(curIt.getAsIterator(),saxHandler);
+ toS = new Token2SaxAdapter(curIt.getAsIterator(new Context()),saxHandler);
toS.convertItemToSax();
} catch (MXQueryException e) {
throw new XQException(e.toString());
Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -276,7 +276,7 @@
sendPayloadValues
.addElement(ser
.eventsToXML(new TokenSequenceIterator(
- item)));
+ context,item)));
}
}
curPlToken = subIters[1].next();// closing
@@ -298,7 +298,7 @@
sendPayloadValues
.addElement(ser
.eventsToXML(new TokenSequenceIterator(
- item)));
+ context,item)));
sendPayloadTypes.addElement("text/xml");
if (contentType.equals(""))
contentType = "text/xml";
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/AvailEnvVars.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/AvailEnvVars.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/AvailEnvVars.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -22,7 +22,7 @@
TokenInterface tok = new TextToken(null,(String)envVars.next());
vars.add(tok);
}
- current = new TokenSequenceIterator(vars);
+ current = new TokenSequenceIterator(context,vars);
}
return current.next();
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -160,7 +160,7 @@
lines.addElement(new TextToken(null, line));
line = lr.readLine();
}
- cur = new TokenSequenceIterator(lines);
+ cur = new TokenSequenceIterator(context,lines);
break;
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Fold.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Fold.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Fold.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -94,7 +94,7 @@
acc.addElement(tok);
tok = reduceFunc.next();
}
- current = WindowFactory.getNewWindow(context, new TokenSequenceIterator(acc));
+ current = WindowFactory.getNewWindow(context, new TokenSequenceIterator(context,acc));
reduceFunc.reset();
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/ft/ScoreSequence.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/ft/ScoreSequence.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/ft/ScoreSequence.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -76,7 +76,7 @@
compScores.addElement(score);
}
adaptScoreToExpectedRange(compScores);
- TokenSequenceIterator ts = new TokenSequenceIterator(compScores);
+ TokenSequenceIterator ts = new TokenSequenceIterator(context,compScores);
current = WindowFactory.getNewWindow(context, ts);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ft/FTContainsIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ft/FTContainsIterator.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ft/FTContainsIterator.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -128,7 +128,7 @@
VariableHolder ignHolder = context.getVariable(Parser.FT_IGNORE_SCOPES);
if (ignIds.size() > 0) {
- ignHolder.setIter(new TokenSequenceIterator(ignIds));
+ ignHolder.setIter(new TokenSequenceIterator(context,ignIds));
}
else
ignHolder.setIter(new EmptySequenceIterator(context,loc));
Modified: trunk/MXQuery/src/ch/ethz/mxquery/model/TokenSequenceIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/model/TokenSequenceIterator.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/model/TokenSequenceIterator.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -24,6 +24,14 @@
public class TokenSequenceIterator extends Iterator {
protected TokenInterface [] tokens;
+
+ public TokenSequenceIterator(Context ctx, Vector inp) {
+ super(ctx,null);
+ tokens = new TokenInterface[inp.size()];
+ for (int i=0;i<tokens.length;i++) {
+ tokens[i] = (TokenInterface)inp.elementAt(i);
+ }
+ }
public TokenSequenceIterator(Vector inp) {
super(null,null);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xqj/FlatItem.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xqj/FlatItem.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xqj/FlatItem.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -149,9 +149,9 @@
return new TypeInfo(tk.getEventType(),Type.OCCURRENCE_IND_EXACTLY_ONE);
}
- public XDMIterator getAsIterator() throws XQException{
+ public XDMIterator getAsIterator(Context ctx) throws XQException{
try {
- return new TokenIterator(null,tk,null, false);
+ return new TokenIterator(ctx,tk,null, false);
} catch (MXQueryException me) {
throw new XQException(me.toString());
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xqj/Item.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xqj/Item.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xqj/Item.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -22,6 +22,7 @@
import org.w3c.dom.Node;
+import ch.ethz.mxquery.contextConfig.Context;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.model.XDMIterator;
@@ -43,7 +44,7 @@
String getItemAsString(Properties props) throws XQException;
- XDMIterator getAsIterator() throws XQException;
+ XDMIterator getAsIterator(Context ctx) throws XQException;
long getLong() throws XQException;
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -239,13 +239,15 @@
if (value.isClosed())
throw new XQException("Item is closed, cannot bind it");
+ Context ctx = this.getRuntime();
+
if (value instanceof MXQueryXQItem) {
MXQueryXQItem mxqItem = (MXQueryXQItem) value;
try {
if(this instanceof MXQueryXQPreparedExpression)
- this.getRuntime().setVariableValue(qn, mxqItem.curIt.getAsIterator(), true);
+ ctx.setVariableValue(qn, mxqItem.curIt.getAsIterator(ctx), true);
else
- this.getRuntime().bindVariableValue(qn, mxqItem.curIt.getAsIterator());
+ ctx.bindVariableValue(qn, mxqItem.curIt.getAsIterator(ctx));
} catch (MXQueryException e) {
throw new XQQueryException(e.toString(),PlatformDependentUtils.getJavaxQName(e.getErrorCode()));
}
@@ -432,19 +434,24 @@
while (value.next()) {
items.add( value.getItem());
}
+
+ Context ctx = this.getRuntime();
+
XDMIterator [] seqIters = new XDMIterator[items.size()];
for (int i=0;i<seqIters.length;i++) {
- seqIters[i] = ((MXQueryXQItem)items.get(i)).curIt.getAsIterator();
+ seqIters[i] = ((MXQueryXQItem)items.get(i)).curIt.getAsIterator(ctx);
}
+
- SequenceIterator seq = new SequenceIterator(new Context(),seqIters,QueryLocation.OUTSIDE_QUERY_LOC);
+
+ SequenceIterator seq = new SequenceIterator(ctx,seqIters,QueryLocation.OUTSIDE_QUERY_LOC);
try {
if(this instanceof MXQueryXQPreparedExpression)
- this.getRuntime().setVariableValue(new ch.ethz.mxquery.datamodel.QName(varName.toString()), seq, true);
+ ctx.setVariableValue(new ch.ethz.mxquery.datamodel.QName(varName.toString()), seq, true);
else
- this.getRuntime().bindVariableValue(new ch.ethz.mxquery.datamodel.QName(varName.toString()), seq);
+ ctx.bindVariableValue(new ch.ethz.mxquery.datamodel.QName(varName.toString()), seq);
} catch (MXQueryException e) {
throw new XQQueryException(e.toString(),PlatformDependentUtils.getJavaxQName(e.getErrorCode()));
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -172,7 +172,7 @@
throw new XQException("Cannot write to null handler");
Token2SaxAdapter toS;
try {
- toS = new Token2SaxAdapter(curIt.getAsIterator(),saxHandler);
+ toS = new Token2SaxAdapter(curIt.getAsIterator(new Context()),saxHandler);
toS.convertItemToSax();
} catch (MXQueryException e) {
throw new XQException(e.toString());
@@ -188,7 +188,8 @@
}
public XMLStreamReader getItemAsStream() throws XQException {
- return new Token2StaxAdapter(new Context(), curIt.getAsIterator(), true);
+ Context ctx = new Context();
+ return new Token2StaxAdapter(ctx, curIt.getAsIterator(ctx), true);
}
public String getItemAsString(Properties props) throws XQException {
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQPreparedExpression.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQPreparedExpression.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQPreparedExpression.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -31,7 +31,6 @@
import javax.xml.xquery.XQStaticContext;
//import javax.xml.xquery.XQWarning;
import ch.ethz.mxquery.model.VariableHolder;
-import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.query.PreparedStatement;
import ch.ethz.mxquery.query.impl.PreparedStatementImpl;
import ch.ethz.mxquery.util.PlatformDependentUtils;
@@ -85,23 +84,23 @@
}
public XQResultSequence executeQuery() throws XQException {
- checkNotClosed();
- //try {
- //XDMIterator iter = exp.evaluate();
- //exp = pristineCopy.copy();
- if(connection.getStaticContext().getScrollability() == XQConstants.SCROLLTYPE_FORWARD_ONLY)
- return new MXQueryXQForwardSequence(exp, connection,this);
- Vector store = new Vector();
- int i = 0;
- MXQueryXQForwardSequence mSeq = new MXQueryXQForwardSequence(exp, connection,this);
- while(mSeq.next()){
- store.add(i++,mSeq.getItem());
- }
- this.seq = new MXQueryXQSequence(store, connection);
- return seq;
-// } catch (MXQueryException de) {
-// throw new XQQueryException(de.toString(),PlatformDependentUtils.getJavaxQName(de.getErrorCode()));
-// }
+ checkNotClosed();
+ try {
+ //XDMIterator iter = exp.evaluate();
+ exp = pristineCopy.copy();
+ if(connection.getStaticContext().getScrollability() == XQConstants.SCROLLTYPE_FORWARD_ONLY)
+ return new MXQueryXQForwardSequence(exp, connection,this);
+ Vector store = new Vector();
+ int i = 0;
+ MXQueryXQForwardSequence mSeq = new MXQueryXQForwardSequence(exp, connection,this);
+ while(mSeq.next()){
+ store.add(i++,mSeq.getItem());
+ }
+ this.seq = new MXQueryXQSequence(store, connection);
+ return seq;
+ } catch (MXQueryException de) {
+ throw new XQQueryException(de.toString(),PlatformDependentUtils.getJavaxQName(de.getErrorCode()));
+ }
}
public QName[] getAllExternalVariables() throws XQException {
@@ -169,14 +168,14 @@
//@Override
protected Context getRuntime() {
if(exp instanceof PreparedStatementImpl){
- return (Context)((PreparedStatementImpl)this.exp).getContext();
+ return (Context)((PreparedStatementImpl)this.pristineCopy).getContext();
}
return null;
}
public QName[] getAllUnboundExternalVariables() throws XQException {
checkNotClosed();
- Vector vec = exp.getUnresolvedExternalVariables();
+ Vector vec = pristineCopy.getUnresolvedExternalVariables();
QName [] ret = new QName[vec.size()];
for (int i=0;i<vec.size();i++) {
ch.ethz.mxquery.datamodel.QName qn = (ch.ethz.mxquery.datamodel.QName)vec.elementAt(i);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xqj/TreeItem.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xqj/TreeItem.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xqj/TreeItem.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -21,6 +21,7 @@
import java.util.Properties;
import java.util.Vector;
+import ch.ethz.mxquery.contextConfig.Context;
import ch.ethz.mxquery.datamodel.types.Type;
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
@@ -93,7 +94,7 @@
}
ser.setOmitXMLDeclaration(true);
XDMSerializer ip = new XDMSerializer(ser);
- TokenSequenceIterator to = new TokenSequenceIterator(v);
+ TokenSequenceIterator to = new TokenSequenceIterator(null,v);
String sb;
try {
sb = ip.eventsToXML(to);
@@ -104,8 +105,8 @@
return result;
}
- public XDMIterator getAsIterator() {
- return new TokenSequenceIterator(v);
+ public XDMIterator getAsIterator(Context ctx) {
+ return new TokenSequenceIterator(ctx,v);
}
public long getLong() throws XQException {
Modified: trunk/MXQuery/src/examples/XQJExample.java
===================================================================
--- trunk/MXQuery/src/examples/XQJExample.java 2011-06-20 14:07:49 UTC (rev 4413)
+++ trunk/MXQuery/src/examples/XQJExample.java 2011-06-20 16:06:40 UTC (rev 4414)
@@ -34,15 +34,15 @@
public class XQJExample {
public static void main(String[] args) throws XQException {
- //String query = "declare variable $ext external; (14 + $ext, $ext * $ext)";
- String query = "<tag><tag1>text</tag1></tag>";
+ String query = "declare variable $ext external; (14 + $ext, $ext * $ext)";
+ //String query = "<tag><tag1>text</tag1></tag>";
XQDataSource ds = new MXQueryXQDataSource();
XQConnection conn = ds.getConnection();
System.out.println("Running query: " + query);
XQPreparedExpression exp = conn.prepareExpression(query);
-// exp.bindInt(new QName("ext"), 7, null);
+ exp.bindInt(new QName("ext"), 7, null);
XQResultSequence result = exp.executeQuery();
XQSequence sequence = conn.createSequence(result);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-06-20 14:07:59
|
Revision: 4413
http://mxquery.svn.sourceforge.net/mxquery/?rev=4413&view=rev
Author: pm_fischer
Date: 2011-06-20 14:07:49 +0000 (Mon, 20 Jun 2011)
Log Message:
-----------
fix a context-scoping problem affecting the invocation of UDFs in XQIB
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/functions/Function.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/Function.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/Function.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/Function.java 2011-06-20 08:27:16 UTC (rev 4412)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/Function.java 2011-06-20 14:07:49 UTC (rev 4413)
@@ -43,7 +43,7 @@
FunctionSignature signature;
protected XDMIterator iter;
-
+
TypeInfo returnType = null;
String operation = null;
@@ -99,8 +99,9 @@
//iter.setContext(targetContext, true);
Context contextToUse = targetContext;
// external functions reside in their original context
- if (signature.type == FunctionSignature.EXTERNAL_FUNCTION && iter.getContext() != null)
+ if (signature.type != FunctionSignature.SYSTEM_FUNCTION && iter.getContext() != null && iter.getContext().getParent() != null) {
contextToUse = iter.getContext().getParent();
+ }
if (iter instanceof UserdefFuncCall) {
return ((UserdefFuncCall)iter).copyInstance(contextToUse);
} else
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java 2011-06-20 08:27:16 UTC (rev 4412)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/UserdefFuncCallLateBinding.java 2011-06-20 14:07:49 UTC (rev 4413)
@@ -111,7 +111,7 @@
f = context.getFunction(funcName, arity);
if (f==null)
- throw new StaticException(ErrorCodes.E0017_STATIC_DOESNT_MATCH_FUNCTION_SIGNATURE,"Function "+funcName+" with arity"+arity+" not available",loc);
+ throw new StaticException(ErrorCodes.E0017_STATIC_DOESNT_MATCH_FUNCTION_SIGNATURE,"Function "+funcName+" with arity "+arity+" not available",loc);
}
XDMIterator func = f.getFunctionImplementation(context);
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/Function.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/Function.java 2011-06-20 08:27:16 UTC (rev 4412)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/Function.java 2011-06-20 14:07:49 UTC (rev 4413)
@@ -29,6 +29,7 @@
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.Hashtable;
+
/**
* Holds information on the function metadata and methods to retrieve the
* implementation, either by an explicit iterator or by the name of a class to
@@ -44,7 +45,7 @@
FunctionSignature signature;
protected XDMIterator iter;
-
+
TypeInfo returnType = null;
String operation = null;
@@ -100,8 +101,9 @@
//iter.setContext(targetContext, true);
Context contextToUse = targetContext;
// external functions reside in their original context
- if (signature.type == FunctionSignature.EXTERNAL_FUNCTION && iter.getContext() != null)
+ if (signature.type != FunctionSignature.SYSTEM_FUNCTION && iter.getContext() != null && iter.getContext().getParent() != null) {
contextToUse = iter.getContext().getParent();
+ }
if (iter instanceof UserdefFuncCall) {
return ((UserdefFuncCall)iter).copyInstance(contextToUse);
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tim...@us...> - 2011-06-20 08:27:23
|
Revision: 4412
http://mxquery.svn.sourceforge.net/mxquery/?rev=4412&view=rev
Author: timchurch
Date: 2011-06-20 08:27:16 +0000 (Mon, 20 Jun 2011)
Log Message:
-----------
Updated Web Service sample query to use tidy parser
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java 2011-06-20 03:07:47 UTC (rev 4411)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java 2011-06-20 08:27:16 UTC (rev 4412)
@@ -94,7 +94,7 @@
* Android SAXParserFactory.newInstance() does not check system properties.
* http://developer.android.com/reference/javax/xml/parsers/SAXParserFactory.html#newInstance%28%29
*/
- SAXParser parser;
+ SAXParser parser = null;
if (tidyInput) {
parser = org.ccil.cowan.tagsoup.jaxp.SAXParserImpl.newInstance(new HashMap());
} else {
@@ -106,8 +106,8 @@
} else if (validationMode == Context.IGNORE_DTD){
spf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar",false);
spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
- parser = spf.newSAXParser();
}
+ parser = spf.newSAXParser();
}
//if (!tidyInput) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <et...@us...> - 2011-06-20 03:07:53
|
Revision: 4411
http://mxquery.svn.sourceforge.net/mxquery/?rev=4411&view=rev
Author: etterth
Date: 2011-06-20 03:07:47 +0000 (Mon, 20 Jun 2011)
Log Message:
-----------
- Fix for document order (using native browser function)
Modified Paths:
--------------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java 2011-06-20 02:34:37 UTC (rev 4410)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java 2011-06-20 03:07:47 UTC (rev 4411)
@@ -84,38 +84,48 @@
return -1;
if (other.node == this.node)
return 0;
- Node tmpnode = node;
- LinkedList<Node> thislistfromtopparent = new LinkedList<Node>();
- while (tmpnode != null){
- thislistfromtopparent.add(0, tmpnode);
- tmpnode = tmpnode.getParentNode();
- }
- tmpnode = other.node;
- LinkedList<Node> otherlistfromtopparent = new LinkedList<Node>();
- while (tmpnode != null){
- otherlistfromtopparent.add(0, tmpnode);
- tmpnode = tmpnode.getParentNode();
- }
- int smallest = Math.min(thislistfromtopparent.size(), otherlistfromtopparent.size());
- int i;
- for (i=0;i<smallest;i++){
- if (thislistfromtopparent.get(i) != otherlistfromtopparent.get(i)){
- break;
- }
- }
+ short comp = this.node.compareDocumentPosition(other.node);
+ if ((comp | Node.DOCUMENT_POSITION_PRECEDING) != 0 ||
+ (comp | Node.DOCUMENT_POSITION_CONTAINS) != 0)//the other is parent
+ return -1;
- if (i==smallest){//there was no difference
- return 0;
- }
- //TODO this seems wrong
- Node first = thislistfromtopparent.get(i);
- Node second = otherlistfromtopparent.get(i);
- while (first != null && first!= second ){
- first = first.getNextSibling();
- }
- if (first == null)//first was after second
- return -1;
- return 1;
+ if ((comp | Node.DOCUMENT_POSITION_FOLLOWING) != 0 ||
+ (comp | Node.DOCUMENT_POSITION_CONTAINED_BY) != 0)//the other is child
+ return 1;
+ return -2;
+
+// Node tmpnode = node;
+// LinkedList<Node> thislistfromtopparent = new LinkedList<Node>();
+// while (tmpnode != null){
+// thislistfromtopparent.add(0, tmpnode);
+// tmpnode = tmpnode.getParentNode();
+// }
+// tmpnode = other.node;
+// LinkedList<Node> otherlistfromtopparent = new LinkedList<Node>();
+// while (tmpnode != null){
+// otherlistfromtopparent.add(0, tmpnode);
+// tmpnode = tmpnode.getParentNode();
+// }
+// int smallest = Math.min(thislistfromtopparent.size(), otherlistfromtopparent.size());
+// int i;
+// for (i=0;i<smallest;i++){
+// if (thislistfromtopparent.get(i) != otherlistfromtopparent.get(i)){
+// break;
+// }
+// }
+//
+// if (i==smallest){//there was no difference
+// return 0;
+// }
+// //TODO this seems wrong
+// Node first = thislistfromtopparent.get(i);
+// Node second = otherlistfromtopparent.get(i);
+// while (first != null && first!= second ){
+// first = first.getNextSibling();
+// }
+// if (first == null)//first was after second
+// return -1;
+// return 1;
}
public Node getNode(){
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-06-20 02:34:37 UTC (rev 4410)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java 2011-06-20 03:07:47 UTC (rev 4411)
@@ -5,9 +5,14 @@
import ch.ethz.mxquery.datamodel.types.Type;
public class Node extends JavaScriptObject {
+
+ public final static short DOCUMENT_POSITION_DISCONNECTED = 0;
+ public final static short DOCUMENT_POSITION_PRECEDING = 2;
+ public final static short DOCUMENT_POSITION_FOLLOWING = 4;
+ public final static short DOCUMENT_POSITION_CONTAINS = 8;
+ public final static short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
+ public final static short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
-
-
protected Node() {
}
@@ -377,4 +382,12 @@
public final void setNodeValue(String nodeValue) {
DOMImpl.impl.nodeSetValue(this, nodeValue);
}
+
+ /**
+ * 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 short compareDocumentPosition(Node other) /*-{
+ return this.compareDocumentPosition(other);
+ }-*/;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <et...@us...> - 2011-06-20 02:34:43
|
Revision: 4410
http://mxquery.svn.sourceforge.net/mxquery/?rev=4410&view=rev
Author: etterth
Date: 2011-06-20 02:34:37 +0000 (Mon, 20 Jun 2011)
Log Message:
-----------
- First version of testing API for JS
Modified Paths:
--------------
trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml
trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/JsApi.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsEval.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/EndElementNodeToken.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Document.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java
Added Paths:
-----------
trunk/MXQuery/xqib_src/ch/ethz/mxqjs/test/
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml 2011-06-19 15:01:20 UTC (rev 4409)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/MXQueryJS.gwt.xml 2011-06-20 02:34:37 UTC (rev 4410)
@@ -25,6 +25,7 @@
<!-- Specify the paths for translatable code -->
<source path='client'/>
+ <source path='test'/>
</module>
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/JsApi.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/JsApi.java 2011-06-19 15:01:20 UTC (rev 4409)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/JsApi.java 2011-06-20 02:34:37 UTC (rev 4410)
@@ -27,8 +27,9 @@
if ($wnd.xqib == undefined){
$wnd.xqib = {};
}
- $wnd.xqib.__executeWithArray = @ch.ethz.mxqjs.client.JsApi::n_ExecuteFunction(Lcom/google/gwt/core/client/JsArray;);
+ $wnd.xqib.__executeWithArray = @ch.ethz.mxqjs.client.JsApi::call(Lcom/google/gwt/core/client/JsArray;);
$wnd.eval ('xqib.call = function () {return xqib.__executeWithArray(arguments);}');
+ $wnd.xqib.generatetest = @ch.ethz.mxqjs.test.JsXQueryTestCase::create(Ljava/lang/String;);
}-*/;
public static JsArray<JavaScriptObject> call(JsArray<JavaScriptObject> args){
@@ -100,10 +101,6 @@
}
- private static native JsArray<JavaScriptObject> n_ExecuteFunction(JsArray<JavaScriptObject> arguments)/*-{
-
- return @ch.ethz.mxqjs.client.JsApi::call(Lcom/google/gwt/core/client/JsArray;)(arguments);
- }-*/;
private static native String asString(JsArray<JavaScriptObject> arr, int i)/*-{
return arr[i];
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsEval.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsEval.java 2011-06-19 15:01:20 UTC (rev 4409)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsEval.java 2011-06-20 02:34:37 UTC (rev 4410)
@@ -2,29 +2,48 @@
import java.util.Vector;
+import com.google.gwt.core.client.JavaScriptObject;
+
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.QueryLocation;
import ch.ethz.mxquery.exceptions.TypeException;
+import ch.ethz.mxquery.model.Iterator;
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.util.browser.JsToMxQuery;
-public class JsEval extends TokenBasedIterator {
+public class JsEval extends Iterator {
- @Override
+ public JsEval() {
+ super(null, null);
+ }
+
+ private XDMIterator iter;
+
+
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;
+ JavaScriptObject ret =eval(script);
+ this.iter = JsToMxQuery.getIterator(ret);
}
@Override
+ public TokenInterface next() throws MXQueryException {
+ if (iter == null) {
+ init();
+ }
+ return iter.next();
+ }
+
+ @Override
protected XDMIterator copy(Context context, XDMIterator[] subIters,
Vector nestedPredCtxStack) throws MXQueryException {
JsEval copy = new JsEval();
@@ -33,8 +52,8 @@
return copy;
}
- protected native void eval(String script)/*-{
- eval(script);
+ protected native JavaScriptObject eval(String script)/*-{
+ return eval(script);
}-*/;
}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/EndElementNodeToken.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/EndElementNodeToken.java 2011-06-19 15:01:20 UTC (rev 4409)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/EndElementNodeToken.java 2011-06-20 02:34:37 UTC (rev 4410)
@@ -7,7 +7,7 @@
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.util.browser.dom.Node;
-public class EndElementNodeToken extends NodeToken {
+public class EndElementNodeToken extends ElementNodeToken{
protected EndElementNodeToken(Node node) {
super(node);
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java 2011-06-19 15:01:20 UTC (rev 4409)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java 2011-06-20 02:34:37 UTC (rev 4410)
@@ -15,18 +15,21 @@
import ch.ethz.mxquery.datamodel.MXQueryNumber;
import ch.ethz.mxquery.datamodel.MXQueryTime;
import ch.ethz.mxquery.datamodel.MXQueryYearMonthDuration;
+import ch.ethz.mxquery.datamodel.Namespace;
import ch.ethz.mxquery.datamodel.QName;
import ch.ethz.mxquery.datamodel.StructuralIdentifier;
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.datamodel.xdm.XDMScope;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.util.browser.dom.Document;
+import ch.ethz.mxquery.util.browser.dom.Element;
import ch.ethz.mxquery.util.browser.dom.Node;
public abstract class NodeToken implements StructuralIdentifier, TokenInterface{
protected Node node;
+ private XDMScope dynamicScope;
public static NodeToken createToken(Node node){
if (node == null)
@@ -271,14 +274,29 @@
@Override
public void setDynamicScope(XDMScope ns) {
- // TODO Auto-generated method stub
+ dynamicScope = ns;
}
@Override
public XDMScope getDynamicScope() {
- XDMScope scope = new XDMScope();
- return scope;
+ if (dynamicScope == null) {
+ dynamicScope = new XDMScope(new XDMScope());
+ final Element parentElement = node.getParentElement();
+ if (parentElement != null ) {
+ //TODO: parent handling
+ }
+ final String uri = node.getNameSpaceURI();
+ if(uri!= null) {
+ try {
+ dynamicScope.addNamespace(new Namespace(node.lookupPrefix(uri),uri));
+ } catch (MXQueryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ return dynamicScope;
}
@Override
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-06-19 15:01:20 UTC (rev 4409)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Document.java 2011-06-20 02:34:37 UTC (rev 4410)
@@ -34,4 +34,8 @@
public final native void write(String str)/*-{
this.write(str);
}-*/;
+
+ public final Element getDocumentElement() {
+ return Element.createFromGwtNode(((com.google.gwt.dom.client.Document)(JavaScriptObject)this).getDocumentElement());
+ }
}
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-06-19 15:01:20 UTC (rev 4409)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java 2011-06-20 02:34:37 UTC (rev 4410)
@@ -325,6 +325,14 @@
// return ((com.google.gwt.dom.client.Node)(Object)this).isOrHasChild(child);
// return DOMImpl.impl.isOrHasChild(this, child);
}
+
+ public final native String lookupPrefix(String uri)/*-{
+ return this.lookupPrefix(uri);
+ }-*/;
+
+ public final native String lookupNamespaceURI(String prefix)/*-{
+ return this.lookupNamespaceURI(prefix);
+ }-*/;
/**
* Removes the child node indicated by oldChild from the list of children,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tim...@us...> - 2011-06-19 15:01:26
|
Revision: 4409
http://mxquery.svn.sourceforge.net/mxquery/?rev=4409&view=rev
Author: timchurch
Date: 2011-06-19 15:01:20 +0000 (Sun, 19 Jun 2011)
Log Message:
-----------
Updated Web Service sample query to use tidy parser
Modified Paths:
--------------
trunk/MXQuery_Android_App/res/values/strings.xml
Modified: trunk/MXQuery_Android_App/res/values/strings.xml
===================================================================
--- trunk/MXQuery_Android_App/res/values/strings.xml 2011-06-19 15:00:47 UTC (rev 4408)
+++ trunk/MXQuery_Android_App/res/values/strings.xml 2011-06-19 15:01:20 UTC (rev 4409)
@@ -101,7 +101,7 @@
<string name="put_xquery">
fn:put(<test><put/></test>, \"test2.xml\")
</string>
- <string name="webservice_xquery">
+ <string name="webservice_xquery_ORIGINAL">
import module namespace http = \"http://expath.org/ns/http-client\";\n
\n
let $req := <http:request method=\"GET\"\n
@@ -109,6 +109,14 @@
let $res := http:send-request($req, ())\n
return $res[2]
</string>
+ <string name="webservice_xquery">
+ import module namespace http = \"http://expath.org/ns/http-client\";\n
+ \n
+ let $req := <http:request method=\"GET\"\n
+ \thref=\"http://www.google.com/\"/>\n
+ let $res := http:send-request($req, ())\n
+ return $res[2]
+ </string>
<string name="android_location_xquery">
declare namespace m = \"java:ch.ethz.mxquery.android.MXQuery\";\n
declare namespace l = \"java:android.location.Location\";\n
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tim...@us...> - 2011-06-19 15:00:53
|
Revision: 4408
http://mxquery.svn.sourceforge.net/mxquery/?rev=4408&view=rev
Author: timchurch
Date: 2011-06-19 15:00:47 +0000 (Sun, 19 Jun 2011)
Log Message:
-----------
Fixed tidy parser (TagSoup) for Android
Added Paths:
-----------
trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/
trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java
Added: trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java (rev 0)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java 2011-06-19 15:00:47 UTC (rev 4408)
@@ -0,0 +1,546 @@
+/* Copyright 2006 - 2009 ETH Zurich
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.ethz.mxquery.xdmio.xmlAdapters;
+
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.HashMap;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.DeclHandler;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.Namespace;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.XQName;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.xdm.CommentToken;
+import ch.ethz.mxquery.datamodel.xdm.ElementToken;
+import ch.ethz.mxquery.datamodel.xdm.NamedToken;
+import ch.ethz.mxquery.datamodel.xdm.ProcessingInstrToken;
+import ch.ethz.mxquery.datamodel.xdm.TextToken;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.datamodel.xdm.XDMScope;
+import ch.ethz.mxquery.exceptions.DynamicException;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.util.Utils;
+
+public class NonSchemaValidatingSaxImportAdapter extends XDMImportAdapter {
+
+
+ SaxAdapter adapter;
+ ParseWorker worker;
+ MXQueryException parseException = null;
+ protected InputSource tobeParsed;
+
+ Vector tokens;
+ TokenInterface [] currBulk;
+ int bulkPos = 0;
+ private static final int TOKENBLOCKSIZE = 100;
+ private static final int PARSED_BLOCKS_WAITING = 10;
+ int validationMode;
+ boolean tidyInput;
+ private boolean done = false;
+
+
+ class SaxAdapter extends DefaultHandler implements LexicalHandler, DeclHandler{
+
+ private boolean startCData;
+
+ private XMLReader reader;
+
+ private boolean inDTD = false;
+
+ private StringBuffer pendingTextContent = new StringBuffer();
+ TokenInterface [] currToPush = new TokenInterface[TOKENBLOCKSIZE];
+ int blockPos = 0;
+
+ public SaxAdapter(XMLReader source) {
+ reader = source;
+ }
+
+ public void parse() throws SAXException, IOException,MXQueryException {
+ try {
+ if (reader == null) {
+ /*
+ * Android SAXParserFactory.newInstance() does not check system properties.
+ * http://developer.android.com/reference/javax/xml/parsers/SAXParserFactory.html#newInstance%28%29
+ */
+ SAXParser parser;
+ if (tidyInput) {
+ parser = org.ccil.cowan.tagsoup.jaxp.SAXParserImpl.newInstance(new HashMap());
+ } else {
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ if (validationMode == Context.DTD_VALIDATION) {
+ spf.setFeature("http://xml.org/sax/features/validation", true);
+ spf.setFeature("http://apache.org/xml/features/validation/dynamic", true);
+ } else if (validationMode == Context.IGNORE_DTD){
+ spf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar",false);
+ spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
+ parser = spf.newSAXParser();
+ }
+ }
+
+ //if (!tidyInput) {
+
+ //spf.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+ //} else {
+ // spf.setFeature("http://xml.org/sax/features/namespaces",false);
+ //}
+
+
+ reader = parser.getXMLReader();
+ }
+ reader.setErrorHandler(this);
+ reader.setProperty("http://xml.org/sax/properties/lexical-handler", this);
+ if (validationMode == Context.DTD_VALIDATION) {
+ reader.setProperty("http://xml.org/sax/properties/declaration-handler", this);
+ }
+ // reader.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", context.initDictionary().getSchemaLocations());
+ reader.setContentHandler(this);
+ if (tobeParsed != null)
+ reader.parse(tobeParsed);
+ else
+ reader.parse((String)null);
+ } catch (SAXException e) {
+ throw new DynamicException(ErrorCodes.A0007_EC_IO,"Error creating validating input: "+e.toString(),loc);
+ } catch (ParserConfigurationException e) {
+ throw new MXQueryException(ErrorCodes.A0002_EC_NOT_SUPPORTED,"Error creating validating input - parser configuration error",loc);
+ }
+ }
+
+ private void addToken(TokenInterface tok) throws SAXException{
+ currToPush[blockPos++] = tok;
+ if (blockPos == currToPush.length || tok == Token.END_SEQUENCE_TOKEN) {
+ synchronized(tokens) {
+ while (tokens.size() > PARSED_BLOCKS_WAITING)
+ try {
+ tokens.wait();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ throw new SAXException("Stop worker thread");
+ }
+ tokens.add(currToPush);
+ tokens.notify();
+ }
+ currToPush = new TokenInterface[TOKENBLOCKSIZE];
+ blockPos = 0;
+ }
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException {
+ emitPendingTextContent();
+ try {
+ addToken(new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION,null), data, target,curNsScope));
+ } catch (MXQueryException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void startDocument() throws SAXException {
+ emitPendingTextContent();
+ addToken(new Token(Type.START_DOCUMENT, createNextTokenId(Type.START_DOCUMENT,null),curNsScope));
+ if (getURI() != null)
+ curNsScope.setBaseURI(getURI());
+ //level++;
+ }
+
+ public void endDocument() throws SAXException {
+ emitPendingTextContent();
+ addToken(new Token(Type.END_DOCUMENT, null,curNsScope));
+ addToken(Token.END_SEQUENCE_TOKEN);
+ level--;
+ }
+
+ /** Start element. */
+ public void startElement(String uri, String localName, String qname, Attributes attributes) throws SAXException {
+ emitPendingTextContent();
+ level++;
+ Vector myToks = new Vector();
+ boolean foundId = false;
+ boolean foundIdREFS = false;
+
+ String xmlId = null;
+ String [] xmlIdREFS = null;
+
+ String prefix = null;
+ String localPart;
+ boolean createdNSScope = false;
+ int splitPos = qname.indexOf(':');
+ if (splitPos > 0) {
+ prefix = qname.substring(0,splitPos);
+ localPart = qname.substring(splitPos+1);
+ } else
+ localPart = qname;
+ XQName qName = new QName(uri, prefix, localPart);
+ NamedToken token = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG,qName.toString()), qName, curNsScope);
+ myToks.add(token);
+
+ for (int i = 0; i < attributes.getLength(); i++) {
+ int type;
+ boolean setID = false;
+ type = Type.UNTYPED_ATOMIC; //TODO: DTD types annotation, e.g. ID?
+
+ try {
+ QName attQname = new QName(attributes.getQName(i));
+ String attVal = attributes.getValue(i);
+
+ if (!foundId && (type == Type.ID || isXMLId(attQname,qName))) {
+ foundId = true;
+ xmlId = attVal;
+ }
+ if (!foundIdREFS && (type == Type.IDREF || isIDREF(attQname,qName))) {
+ foundIdREFS = true;
+ xmlIdREFS = new String[]{attVal};
+ }
+
+ if (!foundIdREFS && (type == Type.IDREFS || isIDREFS(attQname,qName))) {
+ foundIdREFS = true;
+ xmlIdREFS = Utils.split(attVal," ", false);
+ }
+
+
+ boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, attQname, attVal);
+ //boolean newOpened = false;
+ if (newOpened && !createdNSScope)
+ myToks.setElementAt(new ElementToken(Type.START_TAG, token.getNodeId(), qName, curNsScope), 0);
+
+ if (attQname.getNamespacePrefix() == null || attQname.getNamespacePrefix().equals("")) {
+ if (attQname.getLocalPart().equals("xmlns"))
+ continue;
+ } else if (attQname.getNamespacePrefix().equals("xmlns"))
+ continue;
+
+ attQname.setNamespaceURI(attributes.getURI(i));
+ NamedToken attToken = createAttributeToken(type, attributes.getValue(i), attQname, curNsScope);
+ if (foundId && !setID){
+ attToken.setID(xmlId);
+ setID = true;
+ }
+ if (foundIdREFS){
+ attToken.setIDREFS(xmlIdREFS);
+ foundIdREFS = false;
+ }
+ myToks.add(attToken);
+ } catch (MXQueryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+// if (level < 2 && uri != null && localName.equals(qname)&& !createdNSScope) {
+// try {
+// //checkOpenNsScopeAddNs(createdNSScope, new QName(Context.NS_XMLNS), uri);
+// //myToks.setElementAt(new ElementToken(Type.START_TAG, token.getNodeId(), qName, curNsScope), 0);
+// } catch (MXQueryException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+
+
+ if (foundId) {
+ NamedToken nmToken = (NamedToken)myToks.elementAt(0);
+ nmToken.setID(xmlId);
+ }
+ for (int i=0;i<myToks.size();i++) {
+ addToken((TokenInterface)myToks.elementAt(i));
+ }
+ } // startElement(String,String,String,Attributes)
+
+
+ /** End element. */
+ public void endElement(String uri, String localName, String qname) throws SAXException {
+ emitPendingTextContent();
+ String prefix = null;
+ String localPart;
+ //String[] qNameParts = qname.split(":");
+ int splitPos = qname.indexOf(':');
+ if (splitPos > 0) {
+ prefix = qname.substring(0,splitPos);
+ localPart = qname.substring(splitPos+1);
+ } else
+ localPart = qname;
+
+ XQName qName = new QName(uri, prefix, localPart);
+ NamedToken token = new ElementToken(Type.END_TAG, null, qName, curNsScope);
+ addToken(token);
+ checkCloseNsScope();
+ level--;
+ } // endElement(String,String,String)
+
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException {
+ characters(ch, start, length);
+ }
+
+ private void emitPendingTextContent() throws SAXException{
+ if (pendingTextContent.length() > 0) {
+ int type = Type.TEXT_NODE_UNTYPED_ATOMIC;
+ try {
+ addToken(new TextToken(type,createNextTokenId(type,null), pendingTextContent.toString(), curNsScope));
+ } catch (MXQueryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ pendingTextContent = new StringBuffer();
+ }
+
+ }
+ public void characters(char[] ch, int start, int length) throws SAXException {
+
+// for (int i = start; i < start + length; i++) {
+// text.append(ch[i]);
+// }
+ int type = Type.TEXT_NODE_UNTYPED_ATOMIC;
+ if (startCData) {
+ emitPendingTextContent();
+ try {
+ addToken(new TextToken(type,createNextTokenId(type,null), new String(ch,start,length), curNsScope));
+ }catch (MXQueryException e) {
+ throw new SAXException(e.toString());
+ }
+
+ } else {
+ pendingTextContent.append(ch,start,length);
+ }
+ }
+
+ public void error(SAXParseException e) throws SAXException {
+ throw e;
+ }
+
+ public void fatalError(SAXParseException e) throws SAXException {
+ throw e;
+ }
+
+ public void warning(SAXParseException e) throws SAXException {
+ System.out.println("Warning: " + e.getMessage());
+ }
+
+ public void comment(char[] ch, int start, int end) throws SAXException {
+ emitPendingTextContent();
+ if (!inDTD) {
+ // only take comments from the main file, not from the DTD
+ String text = new String(ch, start, end);
+ try {
+ addToken(new CommentToken(createNextTokenId(Type.COMMENT,null), text,curNsScope));
+ } catch (DynamicException e) {
+ throw new SAXException(e);
+ }
+ }
+ }
+
+ public void endCDATA() throws SAXException {
+ startCData = false;
+ }
+
+ public void endDTD() throws SAXException {
+ inDTD = false;
+ }
+
+ public void endEntity(String arg0) throws SAXException {
+ //System.out.println("Entity ended");
+ }
+
+ public void startCDATA() throws SAXException {
+ startCData = true;
+ }
+
+ public void startDTD(String name, String publicID, String systemID) throws SAXException {
+ systemid = systemID;
+ publicid = publicID;
+ dtdRootElem = name;
+ inDTD = true;
+ }
+
+ public void startEntity(String arg0) throws SAXException {
+ //System.out.println("Entitiy started "+arg0);
+ }
+
+ public void attributeDecl(String name, String name2, String type,String mode, String value) throws SAXException {
+ if (type.equals("ID"))idsVector.add(name+"#"+name2);
+ if (type.equals("IDREF")) idRefVector.add(name+"#"+name2);
+ if (type.equals("IDREFS")) idRefsVector.add(name+"#"+name2);
+ }
+
+ public void elementDecl(String name, String model) throws SAXException {
+ //System.out.println("element decl"+model);
+ }
+
+ public void externalEntityDecl(String name, String publicId,
+ String systemId) throws SAXException {
+// System.out.println("external decl");
+
+ }
+
+ public void internalEntityDecl(String name, String value)
+ throws SAXException {
+ // System.out.println("internal decl");
+
+ }
+
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException {
+ if (scopeDepth.peek() != level+1) {
+ curNsScope = new XDMScope(curNsScope);
+ scopeDepth.push(level+1);
+ }
+ Namespace nm = new Namespace(prefix, uri);
+ try {
+ curNsScope.addNamespace(nm);
+ } catch (MXQueryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ // TODO Auto-generated method stub
+ if (scopeDepth.peek() == level+1) {
+ curNsScope = curNsScope.getParent();
+ scopeDepth.pop();
+ }
+ }
+ }
+
+
+ class ParseWorker extends Thread {
+ Vector tokens;
+ SaxAdapter adapter;
+
+ public ParseWorker(Vector tokens, SaxAdapter adapter) {
+ super();
+ this.tokens = tokens;
+ this.adapter = adapter;
+ }
+
+ public void run() {
+ try {
+ adapter.parse();
+ }
+ catch (SAXException e) {
+ String message = e.getMessage();
+ parseException = new DynamicException(ErrorCodes.E0027_DYNAMIC_VALIDATE_UNEXPECTED_VALIDITY, message, loc);
+ synchronized(tokens) {
+ tokens.notify();
+ }
+
+ } catch (IOException e) {
+ parseException = new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing: "+e.toString(),loc);
+ synchronized(tokens) {
+ tokens.notify();
+ }
+ } catch (MXQueryException e) {
+ parseException = e;
+ synchronized(tokens) {
+ tokens.notify();
+ }
+ }
+ }
+ }
+
+ public NonSchemaValidatingSaxImportAdapter(Context ctx, QueryLocation loc,InputSource xml, int validationMode, boolean tidyInput) {
+ super(ctx,loc);
+ adapter= new SaxAdapter(null);
+ this.tokens = new Vector();
+ tobeParsed = xml;
+ this.tidyInput = tidyInput;
+ this.validationMode= validationMode;
+ }
+
+ public NonSchemaValidatingSaxImportAdapter(Context ctx, QueryLocation loc,XMLReader source) {
+ super(ctx,loc);
+ adapter= new SaxAdapter(source);
+ this.tokens = new Vector();
+ }
+
+ protected void init() throws MXQueryException {
+ worker = new ParseWorker(tokens, adapter);
+ worker.start();
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException {
+ XDMImportAdapter res = new NonSchemaValidatingSaxImportAdapter(this.context, loc,tobeParsed, validationMode, false);
+ res.uri = uri;
+ return res;
+ }
+ public TokenInterface next() throws MXQueryException {
+ if (called == 0) {
+ init();
+ called++;
+ getBulkFromQueue();
+ }
+ if (done)
+ return Token.END_SEQUENCE_TOKEN;
+ if (bulkPos == currBulk.length)
+ getBulkFromQueue();
+ TokenInterface tok = currBulk[bulkPos++];
+ if (tok == Token.END_SEQUENCE_TOKEN)
+ done = true;
+ return tok;
+ }
+
+ private void getBulkFromQueue() throws MXQueryException {
+ synchronized(tokens) {
+ while (tokens.isEmpty() && parseException == null) {
+ try {
+ tokens.wait();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ if (parseException != null)
+ throw parseException;
+ currBulk = (TokenInterface[])tokens.remove(0);
+ bulkPos = 0;
+ tokens.notify();
+ }
+ }
+
+
+ protected void resetImpl() throws MXQueryException {
+ super.resetImpl();
+ done = false;
+ worker.interrupt();
+ }
+
+ protected void freeResources(boolean restartable)
+ throws MXQueryException {
+ // TODO Auto-generated method stub
+ super.freeResources(restartable);
+ if (worker != null)
+ worker.interrupt();
+ }
+
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tim...@us...> - 2011-06-17 22:12:49
|
Revision: 4407
http://mxquery.svn.sourceforge.net/mxquery/?rev=4407&view=rev
Author: timchurch
Date: 2011-06-17 22:12:43 +0000 (Fri, 17 Jun 2011)
Log Message:
-----------
- Updated packages in XQuery files
- Fixed leaked ServiceConnection in MyMap
Modified Paths:
--------------
trunk/MXQuery_Android_App/res/raw/mashup.xq
trunk/MXQuery_Android_App/res/raw/mashup_without_helpers.xq
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MyMap.java
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Start.java
Modified: trunk/MXQuery_Android_App/res/raw/mashup.xq
===================================================================
--- trunk/MXQuery_Android_App/res/raw/mashup.xq 2011-06-16 01:37:09 UTC (rev 4406)
+++ trunk/MXQuery_Android_App/res/raw/mashup.xq 2011-06-17 22:12:43 UTC (rev 4407)
@@ -1,5 +1,5 @@
declare namespace m = "java:ch.ethz.mxquery.android.MXQuery";
-declare namespace map = "java:ch.ethz.mxquery.android.MyMap";
+declare namespace map = "java:ch.ethz.mxquery.androidApp.MyMap";
declare namespace l = "java:android.location.Location";
import module namespace http = "http://expath.org/ns/http-client";
declare variable $activity := m:getActivity();
Modified: trunk/MXQuery_Android_App/res/raw/mashup_without_helpers.xq
===================================================================
--- trunk/MXQuery_Android_App/res/raw/mashup_without_helpers.xq 2011-06-16 01:37:09 UTC (rev 4406)
+++ trunk/MXQuery_Android_App/res/raw/mashup_without_helpers.xq 2011-06-17 22:12:43 UTC (rev 4407)
@@ -1,10 +1,10 @@
declare namespace m = "java:ch.ethz.mxquery.android.MXQuery";
-declare namespace map = "java:ch.ethz.mxquery.android.MyMap";
+declare namespace map = "java:ch.ethz.mxquery.androidApp.MyMap";
declare namespace l = "java:android.location.Location";
declare namespace g = "java:com.google.android.maps.GeoPoint";
declare namespace oi = "java:com.google.android.maps.OverlayItem";
-declare namespace ulo = "java:ch.ethz.mxquery.android.UserLocationOverlay";
-declare namespace po = "java:ch.ethz.mxquery.android.PizzaOverlay";
+declare namespace ulo = "java:ch.ethz.mxquery.androidApp.UserLocationOverlay";
+declare namespace po = "java:ch.ethz.mxquery.androidApp.PizzaOverlay";
declare namespace mv = "java:com.google.android.maps.MapView";
declare namespace mc = "java:com.google.android.maps.MapController";
@@ -24,11 +24,14 @@
};
+(: Add user location to map :)
ulo:addOverlay(map:userLocationOverlay($activity), local:createOverlayItemFromLoc($loc)),
+(: Animate map to user location :)
let $geopoint := g:new((l:getLatitude($loc) * 1e6) cast as xs:integer, (l:getLongitude($loc) * 1e6) cast as xs:integer)
return mc:animateTo(mv:getController(map:mapView($activity)), $geopoint),
+(: Find pizza places near user location :)
let $baseUrl := "https://maps.googleapis.com/maps/api/place/search/xml?radius=50&types=food&name=pizza&sensor=false&key=AIzaSyAtNn71gfANF9KWPp0W_pEd1LHaxIux92g&location="
let $url := fn:concat($baseUrl, l:getLatitude($loc), ",", l:getLongitude($loc))
let $req := <http:request method="GET" href="{$url}" />
@@ -39,5 +42,6 @@
let $lng := $pizza/geometry/location/lng cast as xs:double
return po:addOverlay(map:pizzaOverlay($activity), local:createOverlayItem($lat, $lng, $name)),
+(: Draw pizza locations on map :)
mv:postInvalidate(map:mapView($activity))
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MyMap.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MyMap.java 2011-06-16 01:37:09 UTC (rev 4406)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MyMap.java 2011-06-17 22:12:43 UTC (rev 4407)
@@ -9,6 +9,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.IBinder;
@@ -30,7 +31,7 @@
protected MXQueryService mService;
protected boolean mIsBound = false;
- private static final String LOG_TAG = "MXQuery.MyMap";
+ private static final String LOG_TAG = "MXQuery.androidApp.MyMap";
@Override
@@ -72,6 +73,13 @@
mIsBound = true;
}
+ @Override
+ public void onDestroy() {
+ if(mIsBound) {
+ unbindService(mConnection);
+ }
+ super.onDestroy();
+ }
/** Defines callbacks for service binding, passed to bindService() */
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Start.java 2011-06-16 01:37:09 UTC (rev 4406)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Start.java 2011-06-17 22:12:43 UTC (rev 4407)
@@ -42,7 +42,6 @@
import android.widget.Spinner;
import android.widget.TextView;
import ch.ethz.mxquery.android.MXQuery;
-import ch.ethz.mxquery.androidApp.R;
import ch.ethz.mxquery.androidApp.MXQueryService.MXQueryServiceBinder;
import ch.ethz.mxquery.xqj.MXQueryXQDataSource;
import ch.ethz.repackaged.xquery.XQConnection;
@@ -68,7 +67,7 @@
public static final int QUERY_RUNNING_DIALOG = 1;
public static final int GENERATING_CONTACTS_XML_DIALOG = 2;
public static final String UNDEFINED_LABEL = "Undefined";
- private static final String LOG_TAG = "MXQuery.Start";
+ private static final String LOG_TAG = "MXQuery.androidApp.Start";
protected Dialog onCreateDialog(int id) {
switch(id) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <et...@us...> - 2011-06-16 01:37:16
|
Revision: 4406
http://mxquery.svn.sourceforge.net/mxquery/?rev=4406&view=rev
Author: etterth
Date: 2011-06-16 01:37:09 +0000 (Thu, 16 Jun 2011)
Log Message:
-----------
- Window events added
- Diverse bug fixes
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/FGPopulator.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetLocation.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/WindowInfo.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/iterators/browser/EventIterator.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/iterators/browser/SingleNodeIterator.java
Added Paths:
-----------
trunk/MXQuery/xqib_samples/lateresolve-behavior.html
trunk/MXQuery/xqib_samples/window-event.html
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/AddWindowListener.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveWindowListener.java
Added: trunk/MXQuery/xqib_samples/lateresolve-behavior.html
===================================================================
--- trunk/MXQuery/xqib_samples/lateresolve-behavior.html (rev 0)
+++ trunk/MXQuery/xqib_samples/lateresolve-behavior.html 2011-06-16 01:37:09 UTC (rev 4406)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>XQIB: Sample page</title>
+ <meta charset="UTF-8"/>
+ <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script>
+ <script type="application/xquery">
+ declare updating function local:update() {
+ replace node b:dom()//div with <div>{concat('The window height is ', b:windowInfo()/b:client-height/text())}<br/>{concat('The window width is ', b:windowInfo()/b:client-width/text())}</div>
+ };
+ declare updating function local:listener($loc, $evtObj) {
+ local:update()
+ };
+local:update(),
+ b:addWindowListener("resize", local:listener#2)
+ </script>
+ </head>
+ <body>
+ <h1 id='a'>Window event</h1>
+<div/>
+ </body>
+</html>
Added: trunk/MXQuery/xqib_samples/window-event.html
===================================================================
--- trunk/MXQuery/xqib_samples/window-event.html (rev 0)
+++ trunk/MXQuery/xqib_samples/window-event.html 2011-06-16 01:37:09 UTC (rev 4406)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>XQIB: Sample page</title>
+ <meta charset="UTF-8"/>
+ <script type="application/xquery">
+module namespace up = "update";
+ declare updating function up:update() {
+ replace node b:dom()//div with <div>{concat('The window height is ', b:windowInfo()/b:client-height/text())}<br/>{concat('The window width is ', b:windowInfo()/b:client-width/text())}</div>
+ };
+ </script>
+ <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script>
+ <script type="application/xquery">
+import module namespace up = "update";
+ declare updating function local:listener($loc, $evtObj) {
+ up:update()
+ };
+up:update(),
+ b:addWindowListener("resize", local:listener#2)
+ </script>
+ </head>
+ <body>
+ <h1 id='a'>Window event</h1>
+<div/>
+ </body>
+</html>
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-06-15 17:51:06 UTC (rev 4405)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-06-16 01:37:09 UTC (rev 4406)
@@ -17,6 +17,7 @@
import ch.ethz.mxquery.iterators.browser.EventIterator;
import ch.ethz.mxquery.iterators.browser.ListBasedIterator;
import ch.ethz.mxquery.iterators.browser.SingleNodeIterator;
+import ch.ethz.mxquery.model.EmptySequenceIterator;
import ch.ethz.mxquery.model.Iterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.query.PreparedStatement;
@@ -34,6 +35,7 @@
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.dom.client.Text;
@@ -47,6 +49,7 @@
static Context modCtx = new Context();
static CompilerOptions co;
static int contextcounter = 0;
+ private static Hashtable<String, List<FunctionItemToken>> windowhandlers;
public static CompilerOptions getCompilerOptions() {
if (co != null)
@@ -102,18 +105,17 @@
// modCtx = null;
co = null;
handlers = null;
+ windowhandlers = null;
}
- public static void addEventListener(JavaScriptObject obj, String eventName,
+ public static void addEventListener(Element el, String eventName,
FunctionItemToken fi, Context ctx) {
if (eventName.startsWith("on"))
eventName = eventName.substring(2);
- if (handlers == null)
+ if (handlers == null)
handlers = new Hashtable<NodeAndEventName, List<FunctionItemToken>>();
+
- if (JsToMxQuery.isNode(obj)) {
- //node
- Element el = (Element) obj;
NodeAndEventName test = new NodeAndEventName(el, eventName);
List<FunctionItemToken> lst = handlers.get(test);
if (lst == null) {
@@ -121,17 +123,37 @@
handlers.put(test, lst);
}
lst.add(fi);
+
+
+
+ nativeAddEventListener(el, eventName);
+ }
+
+ public static void addWindowListener(String eventName,
+ FunctionItemToken fi, Context ctx) {
+ if (eventName.startsWith("on"))
+ eventName = eventName.substring(2);
+ if (windowhandlers == null) {
+ windowhandlers = new Hashtable<String, List<FunctionItemToken>>();
}
- else {
- //window
- //TODO
-
- }
- nativeAddEventListener(obj, eventName);
+ List<FunctionItemToken> lst = windowhandlers.get(eventName);
+ if (lst == null) {
+ lst = new ArrayList<FunctionItemToken>();
+ windowhandlers.put(eventName, lst);
+ }
+ lst.add(fi);
+
+
+
+ nativeAddWindowListener(eventName);
}
- public static void removeEventListener(JavaScriptObject obj, String eventName,
+ private static native JavaScriptObject getWindowObject() /*-{
+ return $wnd;
+ }-*/;
+
+ public static void removeEventListener(Element el, String eventName,
FunctionItemToken fi, Context ctx) throws MXQueryException {
if (eventName.startsWith("on"))
eventName = eventName.substring(2);
@@ -140,8 +162,6 @@
"handler to remove cannot be found", null);
- if (JsToMxQuery.isNode(obj)) {
- Element el = (Element) obj;
NodeAndEventName test = new NodeAndEventName(el, eventName);
List<FunctionItemToken> lst = handlers.get(test);
if (lst == null) {
@@ -165,13 +185,46 @@
handlers.put(test, null);
nativeRemoveEventListener(el, eventName);
}
- } else {
- //window
- //TODO
- }
+
}
+
+ public static void removeWindowListener(String eventName,
+ FunctionItemToken fi, Context ctx) throws MXQueryException {
+ if (eventName.startsWith("on"))
+ eventName = eventName.substring(2);
+ if (windowhandlers == null)
+ throw new MXQueryException("Eventlistener cannot be removed",
+ "handler to remove cannot be found", null);
+
+ String test = eventName;
+ List<FunctionItemToken> lst = windowhandlers.get(test);
+ if (lst == null) {
+ throw new MXQueryException("Eventlistener cannot be removed",
+ "handler to remove cannot be found", null);
+ }
+ List<FunctionItemToken> lstnew = new ArrayList<FunctionItemToken>();
+ ListIterator<FunctionItemToken> it = lst.listIterator();
+
+ while (it.hasNext()) {
+ FunctionItemToken ft = it.next();
+ FunctionSignature fts = ft.getFunction().getFunctionSignature();
+ FunctionSignature fis = fi.getFunction().getFunctionSignature();
+ if (!fis.getName().equals(fts.getName())
+ || fts.getArity() != fis.getArity())
+ lstnew.add(ft);
+ }
+ windowhandlers.remove(test);
+ windowhandlers.put(test, lstnew);
+ if (lst.isEmpty()) {
+ windowhandlers.put(test, null);
+ nativeRemoveWindowListener(eventName);
+ }
+
+
+ }
+
public static void removeAnonymousEventListeners(Element el,
String eventName, Context ctx) throws MXQueryException {
if (eventName.startsWith("on"))
@@ -217,7 +270,15 @@
test.node = test.node.getParentElement();
}
for (FunctionItemToken fi : handlers.get(test)) {
- SingleNodeIterator nodeiter = new SingleNodeIterator(test.node);
+ Iterator nodeiter;
+ final EventTarget eventTarget = event.getEventTarget();
+ if (JsToMxQuery.isNode(eventTarget)) {
+
+ nodeiter = new SingleNodeIterator((Node) (Object)eventTarget);
+ }
+ else {
+ nodeiter = new EmptySequenceIterator(null, null);
+ }
try {
// TODO: remove name reference - inline functions don't have a
// name
@@ -244,7 +305,53 @@
event.stopPropagation();
event.preventDefault();
}
+ /**
+ * the callback called by any listened window event
+ *
+ * @param event
+ */
+ public static void windowEventCallback(NativeEvent event) {
+ // TODO add arity
+ Logger log = Logger.getLogger(Environment.class.toString());
+ log.log(LogLevel.FINER, "Got a window event: " + event.getString());
+ for (FunctionItemToken fi : windowhandlers.get(event.getType())) {
+ Iterator nodeiter;
+ final EventTarget eventTarget = event.getEventTarget();
+ if (JsToMxQuery.isNode(eventTarget)) {
+
+ nodeiter = new SingleNodeIterator((Node) (Object)eventTarget);
+ }
+ else {
+ nodeiter = new EmptySequenceIterator(null, null);
+ }
+ try {
+ // TODO: remove name reference - inline functions don't have a
+ // name
+ // log.log(LogLevel.FINER, "Calling eventcallback " +
+ // fi.getFunction().getFunctionSignature().getName().toString());
+ ListBasedIterator eventiter = new EventIterator(event);
+ eventiter.setContext(new Context(), true);
+ Iterator[] subiterators = { nodeiter, eventiter };
+
+ Environment.invokeModule(fi, subiterators);
+ // log.log(LogLevel.FINER, "Eventcallback " +
+ // fi.getFunction().getFunctionSignature().getName().toString()
+ // + " done");
+ eventiter = null;
+ subiterators = null;
+ nodeiter = null;
+ } catch (MXQueryException e) {
+ Environment.displayErrorMessage(new StringBuffer(), null, e,
+ true);
+ e.printStackTrace();
+ }
+ }
+ // TODO decide this dynamically
+ event.stopPropagation();
+ event.preventDefault();
+ }
+
public static void invokeModule(FunctionItemToken ft,
XDMIterator[] subiterators) throws MXQueryException {
preProcessDocument();
@@ -340,24 +447,32 @@
// }
// }
private static final native void nativeAddEventListener(
- JavaScriptObject obj, String eventName)/*-{
- // el.addEventListener('click', function (ev) {$wnd.alert('test');}, false);
- if (el.addEventListener){//good browser
- el.addEventListener(eventName, @ch.ethz.mxqjs.client.Environment::eventCallback(Lcom/google/gwt/dom/client/NativeEvent;), false);
- }
- else {//bad browser
- el.attachEvent('on' + eventName, @ch.ethz.mxqjs.client.Environment::eventCallback(Lcom/google/gwt/dom/client/NativeEvent;));
-
- }
-
- }-*/;
+ Element el, String eventName)/*-{
+ // el.addEventListener('click', function (ev) {$wnd.alert('test');}, false);
+ el.addEventListener(eventName, @ch.ethz.mxqjs.client.Environment::eventCallback(Lcom/google/gwt/dom/client/NativeEvent;), false);
+
+ }-*/;
+ private static final native void nativeAddWindowListener(String eventName)/*-{
+
+ $wnd.addEventListener(eventName, @ch.ethz.mxqjs.client.Environment::windowEventCallback(Lcom/google/gwt/dom/client/NativeEvent;), false);
+
+
+ }-*/;
+
private static final native void nativeRemoveEventListener(Element el,
String eventName)/*-{
// el.addEventListener('click', function (ev) {$wnd.alert('test');}, false);
el.removeEventListener(eventName, @ch.ethz.mxqjs.client.Environment::eventCallback(Lcom/google/gwt/dom/client/NativeEvent;), false);
}-*/;
+
+ private static final native void nativeRemoveWindowListener(String eventName)/*-{
+ // el.addEventListener('click', function (ev) {$wnd.alert('test');}, false);
+ $wnd.removeEventListener(eventName, @ch.ethz.mxqjs.client.Environment::windowEventCallback(Lcom/google/gwt/dom/client/NativeEvent;), false);
+ }-*/;
+
+
public static void displayErrorMessage(StringBuffer queryResult,
String query, MXQueryException err, boolean compiled) {
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-06-15 17:51:06 UTC (rev 4405)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-06-16 01:37:09 UTC (rev 4406)
@@ -154,35 +154,33 @@
<paramType>xs:string</paramType>
</parameters>
<className>AddClassName</className>
- </functionDescription><functionDescription>
- <functionName>addEventListener</functionName>
+ </functionDescription>
+ <functionDescription>
+ <functionName>addWindowListener</functionName>
<parameters>
- <paramType>node()+</paramType>
+
<paramType>xs:string</paramType>
- <paramType>QName</paramType>
- <paramType>xs:integer</paramType>
+ <paramType>function()</paramType>
</parameters>
- <className>AddEventListener</className>
+ <className>AddWindowListener</className>
</functionDescription>
<functionDescription>
- <functionName>addEventListener</functionName>
+ <functionName>removeWindowListener</functionName>
<parameters>
- <paramType>node()+</paramType>
<paramType>xs:string</paramType>
<paramType>function()</paramType>
</parameters>
- <className>AddEventListener</className>
+ <className>RemoveWindowListener</className>
</functionDescription>
<functionDescription>
- <functionName>removeEventListener</functionName>
+ <functionName>addEventListener</functionName>
<parameters>
<paramType>node()+</paramType>
<paramType>xs:string</paramType>
- <paramType>QName</paramType>
- <paramType>xs:integer</paramType>
+ <paramType>function()</paramType>
</parameters>
- <className>RemoveEventListener</className>
- </functionDescription>
+ <className>AddEventListener</className>
+ </functionDescription>
<functionDescription>
<functionName>removeEventListener</functionName>
<parameters>
@@ -192,7 +190,16 @@
</parameters>
<className>RemoveEventListener</className>
</functionDescription>
+
<functionDescription>
+ <functionName>removeAnonymousEventListeners</functionName>
+ <parameters>
+ <paramType>node()</paramType>
+ <paramType>xs:string</paramType>
+ </parameters>
+ <className>RemoveAnonymousEventListener</className>
+ </functionDescription>
+ <functionDescription>
<functionName>dom</functionName>
<className>Dom</className>
</functionDescription>
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-15 17:51:06 UTC (rev 4405)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-16 01:37:09 UTC (rev 4406)
@@ -42,7 +42,6 @@
TypeInfo function__ = new TypeInfo(FunctionGallery.getType("function()",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
TypeInfo xs_dateTime = new TypeInfo(FunctionGallery.getType("xs:dateTime",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
TypeInfo node___plus = new TypeInfo(FunctionGallery.getType("node()+",ctx), Type.OCCURRENCE_IND_ONE_OR_MORE,null);
- TypeInfo QName = new TypeInfo(FunctionGallery.getType("QName",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
TypeInfo node__ = new TypeInfo(FunctionGallery.getType("node()",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
TypeInfo xs_string_quest = new TypeInfo(FunctionGallery.getType("xs:string?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
TypeInfo numeric_quest = new TypeInfo(FunctionGallery.getType("numeric?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
@@ -540,17 +539,15 @@
qn = new QName(
"http://xqib.org",
"b",
- "addEventListener");
- paramTypes = new TypeInfo[4];
+ "addWindowListener");
+ paramTypes = new TypeInfo[2];
- paramTypes[0] = node___plus;
- paramTypes[1] = xs_string;
- paramTypes[2] = QName;
- paramTypes[3] = xs_integer;
+ paramTypes[0] = xs_string;
+ paramTypes[1] = function__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
{
- ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
+ ch.ethz.mxquery.functions.b.AddWindowListener iter = new ch.ethz.mxquery.functions.b.AddWindowListener();
iter.setContext(context, false);
type = null;
@@ -564,6 +561,28 @@
qn = new QName(
"http://xqib.org",
"b",
+ "removeWindowListener");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = xs_string;
+ paramTypes[1] = function__;
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+ {
+ ch.ethz.mxquery.functions.b.RemoveWindowListener iter = new ch.ethz.mxquery.functions.b.RemoveWindowListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
"addEventListener");
paramTypes = new TypeInfo[3];
@@ -588,12 +607,11 @@
"http://xqib.org",
"b",
"removeEventListener");
- paramTypes = new TypeInfo[4];
+ paramTypes = new TypeInfo[3];
- paramTypes[0] = node___plus;
+ paramTypes[0] = node__;
paramTypes[1] = xs_string;
- paramTypes[2] = QName;
- paramTypes[3] = xs_integer;
+ paramTypes[2] = function__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
{
@@ -611,16 +629,15 @@
qn = new QName(
"http://xqib.org",
"b",
- "removeEventListener");
- paramTypes = new TypeInfo[3];
+ "removeAnonymousEventListeners");
+ paramTypes = new TypeInfo[2];
paramTypes[0] = node__;
paramTypes[1] = xs_string;
- paramTypes[2] = function__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
{
- ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
+ ch.ethz.mxquery.functions.b.RemoveAnonymousEventListener iter = new ch.ethz.mxquery.functions.b.RemoveAnonymousEventListener();
iter.setContext(context, false);
type = null;
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/AddWindowListener.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/AddWindowListener.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/AddWindowListener.java 2011-06-16 01:37:09 UTC (rev 4406)
@@ -0,0 +1,51 @@
+package ch.ethz.mxquery.functions.b;
+
+import java.util.Vector;
+
+import ch.ethz.mxqjs.client.Environment;
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.types.Type;
+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.TypeException;
+import ch.ethz.mxquery.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class AddWindowListener extends TokenBasedIterator {
+
+ @Override
+ protected void init() throws MXQueryException {
+ currentToken = Token.END_SEQUENCE_TOKEN;
+ String eventname;
+
+ eventname = getStringValue(subIters[0]);
+ XDMIterator functioniter = subIters[1];
+ TokenInterface functiontoken = functioniter.next();
+
+ if (functiontoken.getEventType() != Type.FUNCTION_ITEM || functioniter.next().getEventType() != Type.END_SEQUENCE)
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Function Item expected", loc);
+
+ addWindowHandler(eventname, (FunctionItemToken)functiontoken);
+ }
+
+ private void addWindowHandler( String eventname,
+ FunctionItemToken fi) throws MXQueryException {
+
+ Context ctx = this.getContext().getRootContext();
+ Environment.addWindowListener(eventname, fi,ctx);
+
+ }
+
+ @Override
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ XDMIterator copy = new AddWindowListener();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetLocation.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetLocation.java 2011-06-15 17:51:06 UTC (rev 4405)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetLocation.java 2011-06-16 01:37:09 UTC (rev 4406)
@@ -32,7 +32,10 @@
protected void init() throws MXQueryException {
lst = new LinkedList<TokenInterface>();
- this.addTextElement("hash", Location.getHash());
+
+ QName qn = new QName(namespace.getURI(),namespace.getNamespacePrefix(),"location");
+ lst.add(new ElementToken(Type.START_TAG, null, qn,scope));
+ this.addTextElement("hash", Location.getHash());
this.addTextElement("host", Location.getHost());
this.addTextElement("hostname", Location.getHostName());
this.addTextElement("href", Location.getHref());
@@ -41,7 +44,8 @@
this.addTextElement("protocol", Location.getProtocol());
// this.addTextElement("search", Location.getSearch());
appendParameters();
-
+
+ lst.add(new ElementToken(Type.END_TAG, null, qn,scope));
// addTextElement(tagname, content);
// TODO Auto-generated method stub
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveWindowListener.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveWindowListener.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveWindowListener.java 2011-06-16 01:37:09 UTC (rev 4406)
@@ -0,0 +1,50 @@
+package ch.ethz.mxquery.functions.b;
+
+import java.util.Vector;
+
+import ch.ethz.mxqjs.client.Environment;
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.types.Type;
+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.TypeException;
+import ch.ethz.mxquery.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class RemoveWindowListener extends TokenBasedIterator {
+
+ @Override
+ protected void init() throws MXQueryException {
+ currentToken = Token.END_SEQUENCE_TOKEN;
+ String eventname;
+
+ eventname = getStringValue(subIters[0]);
+ XDMIterator functioniter = subIters[1];
+ TokenInterface functiontoken = functioniter.next();
+
+ if (functiontoken.getEventType() != Type.FUNCTION_ITEM || functioniter.next().getEventType() != Type.END_SEQUENCE)
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Function Item expected", loc);
+
+ addWindowHandler(eventname, (FunctionItemToken)functiontoken);
+ }
+
+ private void addWindowHandler( String eventname,
+ FunctionItemToken fi) throws MXQueryException {
+
+ Context ctx = this.getContext().getRootContext();
+ Environment.removeWindowListener(eventname, fi,ctx);
+
+ }
+ @Override
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ XDMIterator copy = new RemoveWindowListener();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/WindowInfo.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/WindowInfo.java 2011-06-15 17:51:06 UTC (rev 4405)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/WindowInfo.java 2011-06-16 01:37:09 UTC (rev 4406)
@@ -1,28 +1,46 @@
package ch.ethz.mxquery.functions.b;
+import java.util.LinkedList;
import java.util.Vector;
import com.google.gwt.user.client.Window;
import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.Namespace;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.xdm.ElementToken;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.iterators.browser.ListBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
public class WindowInfo extends ListBasedIterator {
+ public WindowInfo() {
+ this.namespace = new Namespace(Context.NS_BROWSER, Context.URI_BROWSER);
+ }
+
@Override
protected void init() throws MXQueryException {
+ lst = new LinkedList<TokenInterface>();
+
+ QName qn = new QName(namespace.getURI(),namespace.getNamespacePrefix(),"window-info");
+
+ lst.add(new ElementToken(Type.START_TAG, null, qn,scope));
addIntegerElement("client-height", Window.getClientHeight());
- addIntegerElement("client-height", Window.getClientWidth());
+ addIntegerElement("client-width", Window.getClientWidth());
addIntegerElement("scroll-left", Window.getScrollLeft());
addIntegerElement("scroll-top", Window.getScrollTop());
+ lst.add(new ElementToken(Type.END_TAG, null, qn,scope));
}
@Override
- protected XDMIterator copy(Context context, XDMIterator[] subIters,
- Vector nestedPredCtxStack) throws MXQueryException {
- return new WindowInfo();
- }
-
+ protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack)
+ throws MXQueryException {
+ XDMIterator ret = new WindowInfo();
+ ret.setSubIters(subIters);
+ ret.setContext(context, false);
+ return ret;
+ }
}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/iterators/browser/EventIterator.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/iterators/browser/EventIterator.java 2011-06-15 17:51:06 UTC (rev 4405)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/iterators/browser/EventIterator.java 2011-06-16 01:37:09 UTC (rev 4406)
@@ -30,8 +30,8 @@
@Override
protected void init() throws MXQueryException {
lst = new LinkedList<TokenInterface>();
- QName qn = new QName("event");
- lst.add(new ElementToken(Type.START_TAG, null, qn,null));
+ QName qn = new QName(namespace.getURI(),namespace.getNamespacePrefix(),"event");
+ lst.add(new ElementToken(Type.START_TAG, null, qn,scope));
String type = event.getType();
if (isMouseEvent(type)){
addIntegerElement("screenX", event.getScreenX());
@@ -44,8 +44,7 @@
addElementIfTrue("metaKey", event.getMetaKey());
addTextElement("button", buttonToString(event.getButton()));
}
- lst.add(new ElementToken(Type.END_TAG, null, qn,null));
- lst.add(Token.END_SEQUENCE_TOKEN);
+ lst.add(new ElementToken(Type.END_TAG, null, qn,scope));
}
protected boolean isMouseEvent(String type) {
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/iterators/browser/SingleNodeIterator.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/iterators/browser/SingleNodeIterator.java 2011-06-15 17:51:06 UTC (rev 4405)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/iterators/browser/SingleNodeIterator.java 2011-06-16 01:37:09 UTC (rev 4406)
@@ -20,16 +20,18 @@
boolean multipletokens;
public SingleNodeIterator(Node store) {
super(store);
+ if (store != null) {
short nt = store.getNodeType();
multipletokens = nt == Node.ELEMENT_NODE
|| nt == Node.DOCUMENT_NODE;
+ }
}
@Override
public TokenInterface next() throws MXQueryException {
- if (finished)
+ if (this.store == null || finished)
return Token.END_SEQUENCE_TOKEN;
-
+
if (!multipletokens && called >= 1)
return Token.END_SEQUENCE_TOKEN;
TokenInterface tok = super.next();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-06-15 17:51:11
|
Revision: 4405
http://mxquery.svn.sourceforge.net/mxquery/?rev=4405&view=rev
Author: maxspeicher
Date: 2011-06-15 17:51:06 +0000 (Wed, 15 Jun 2011)
Log Message:
-----------
(see previous commit)
Removed Paths:
-------------
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-06-15 17:50:30
|
Revision: 4404
http://mxquery.svn.sourceforge.net/mxquery/?rev=4404&view=rev
Author: maxspeicher
Date: 2011-06-15 17:50:23 +0000 (Wed, 15 Jun 2011)
Log Message:
-----------
changed namespace of app to avoid conflicts with library (b/c copies of MXQueryService and XQueryListener have been moved there)
Modified Paths:
--------------
trunk/MXQuery_Android_App/AndroidManifest.xml
Added Paths:
-----------
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MXQueryService.java
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MyMap.java
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/PizzaOverlay.java
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Place.java
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Start.java
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/UserLocationOverlay.java
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/XQueryListener.java
Modified: trunk/MXQuery_Android_App/AndroidManifest.xml
===================================================================
--- trunk/MXQuery_Android_App/AndroidManifest.xml 2011-06-15 17:45:00 UTC (rev 4403)
+++ trunk/MXQuery_Android_App/AndroidManifest.xml 2011-06-15 17:50:23 UTC (rev 4404)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<manifest package="ch.ethz.mxquery.android"
+<manifest package="ch.ethz.mxquery.androidApp"
android:versionCode="1"
android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"></uses-sdk>
Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MXQueryService.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MXQueryService.java (rev 0)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MXQueryService.java 2011-06-15 17:50:23 UTC (rev 4404)
@@ -0,0 +1,85 @@
+package ch.ethz.mxquery.androidApp;
+
+import java.io.StringWriter;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+import android.util.Log;
+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 MXQueryService extends Service {
+ private XQDataSource xqjd = new MXQueryXQDataSource(MXQueryXQDataSource.XQJ_SCRIPTING_MODE);
+ public static String lastResult = null;
+ private static final String LOG_TAG = "MXQuery.MXQueryService";
+
+ // 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();
+ Log.e(LOG_TAG, xqe.getMessage(), xqe);
+ return xqe.getMessage();
+ }
+ return result.toString();
+ }
+
+}
Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MyMap.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MyMap.java (rev 0)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/MyMap.java 2011-06-15 17:50:23 UTC (rev 4404)
@@ -0,0 +1,124 @@
+package ch.ethz.mxquery.androidApp;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.util.Log;
+import ch.ethz.mxquery.android.MXQuery;
+import ch.ethz.mxquery.androidApp.MXQueryService.MXQueryServiceBinder;
+
+import com.google.android.maps.MapActivity;
+import com.google.android.maps.MapView;
+import com.google.android.maps.Overlay;
+
+public class MyMap extends MapActivity {
+
+ public MapView mapView;
+ public UserLocationOverlay userLocationOverlay;
+ public PizzaOverlay pizzaOverlay;
+ private List<Overlay> mapOverlays;
+ private Drawable pizzaDrawable;
+ protected MXQueryService mService;
+ protected boolean mIsBound = false;
+
+ private static final String LOG_TAG = "MXQuery.MyMap";
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.map);
+
+ MXQuery.init(this);
+
+ mapView = (MapView) findViewById(R.id.mapview);
+ mapView.setBuiltInZoomControls(true);
+ mapOverlays = mapView.getOverlays();
+
+ pizzaDrawable = this.getResources().getDrawable(R.drawable.pizza);
+ pizzaOverlay = new PizzaOverlay(pizzaDrawable, this);
+ mapOverlays.add(pizzaOverlay);
+
+ userLocationOverlay = new UserLocationOverlay(this.getResources().getDrawable(R.drawable.marker));
+ mapOverlays.add(userLocationOverlay);
+
+ // start service
+ if (!mIsBound) {
+ doBindService();
+ }
+ }
+
+ @Override
+ protected boolean isRouteDisplayed() {
+ return false;
+ }
+
+ 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(MyMap.this, MXQueryService.class), mConnection,
+ Context.BIND_AUTO_CREATE);
+ mIsBound = true;
+ }
+
+
+
+ /** Defines callbacks for service binding, passed to bindService() */
+ private ServiceConnection mConnection = new ServiceConnection() {
+
+ 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;
+
+ Log.i(LOG_TAG, "MXQueryService Connected. Running queries...");
+
+ // show user location and nearby pizza places on map
+ String showPizzasQuery = readXQueryFile(R.raw.mashup_without_helpers);
+ mService.runQuery(showPizzasQuery, queryListener);
+ }
+
+ public void onServiceDisconnected(ComponentName arg0) {
+ mIsBound = false;
+ }
+ };
+
+ protected XQueryListener queryListener = new XQueryListener() {
+ public void queryResult(final String result) {
+ runOnUiThread(new Runnable() {
+ public void run() {
+ Log.i(LOG_TAG, "QUERY RESULT: " + result);
+ }
+ });
+ }
+ };
+
+ public String readXQueryFile(int rawResourceId) {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader( getResources().openRawResource(rawResourceId) ) );
+ String query = "";
+ String line;
+
+ try {
+ while ((line = in.readLine()) != null) {
+ query += line;
+ }
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ }
+ return query;
+ }
+
+}
Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/PizzaOverlay.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/PizzaOverlay.java (rev 0)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/PizzaOverlay.java 2011-06-15 17:50:23 UTC (rev 4404)
@@ -0,0 +1,58 @@
+package ch.ethz.mxquery.androidApp;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.app.Activity;
+import android.graphics.drawable.Drawable;
+import android.widget.Toast;
+
+import com.google.android.maps.GeoPoint;
+import com.google.android.maps.ItemizedOverlay;
+import com.google.android.maps.OverlayItem;
+
+public class PizzaOverlay extends ItemizedOverlay<OverlayItem> {
+
+ private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
+ private Activity mActivity;
+
+ public PizzaOverlay(Drawable defaultMarker, Activity activity) {
+ super(boundCenterBottom(defaultMarker));
+ this.mActivity = activity;
+ populate(); // needed to prevent null pointer exception with empty list
+ }
+
+ @Override
+ protected OverlayItem createItem(int i) {
+ return mOverlays.get(i);
+ }
+
+ @Override
+ public int size() {
+ return mOverlays.size();
+ }
+
+ public void addOverlay(OverlayItem overlay) {
+ mOverlays.add(overlay);
+ //setLastFocusedIndex(-1);
+ populate();
+ }
+
+ public void setPizzas(List<Place> places) {
+ mOverlays.clear();
+ for(Place place: places){
+ GeoPoint geoPoint = new GeoPoint((int) (place.getLatitude()*1e6), (int) (place.getLongitude()*1e6));
+ OverlayItem overlayitem = new OverlayItem(geoPoint, place.getName(), "");
+ addOverlay(overlayitem);
+ }
+ }
+
+ @Override
+ protected boolean onTap(int index) {
+ OverlayItem overlayItem = mOverlays.get(index);
+
+ Toast.makeText(this.mActivity, overlayItem.getTitle(), Toast.LENGTH_SHORT).show();
+
+ return true;
+ }
+}
Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Place.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Place.java (rev 0)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Place.java 2011-06-15 17:50:23 UTC (rev 4404)
@@ -0,0 +1,36 @@
+package ch.ethz.mxquery.androidApp;
+
+public class Place {
+ private Double latitude;
+ private Double longitude;
+ private String name;
+
+ public Place() {}
+
+ public Place(Double latitude, Double longitude, String name) {
+ this.latitude = latitude;
+ this.longitude = longitude;
+ this.name = name;
+ }
+
+ public Double getLatitude() {
+ return latitude;
+ }
+ public void setLatitude(Double latitude) {
+ this.latitude = latitude;
+ }
+ public Double getLongitude() {
+ return longitude;
+ }
+ public void setLongitude(Double longitude) {
+ this.longitude = longitude;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+}
Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Start.java (rev 0)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/Start.java 2011-06-15 17:50:23 UTC (rev 4404)
@@ -0,0 +1,709 @@
+package ch.ethz.mxquery.androidApp;
+
+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;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.provider.ContactsContract;
+import android.util.Log;
+import android.util.Xml;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+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.MXQuery;
+import ch.ethz.mxquery.androidApp.R;
+import ch.ethz.mxquery.androidApp.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 {
+
+ protected final Activity mActivity = this;
+ protected Button mButton;
+ protected Spinner mSpinner;
+ protected EditText mInputView;
+ protected TextView mResultView;
+ protected MXQueryService mService;
+ protected boolean mIsBound = false;
+ protected ProgressDialog mDialog;
+
+ protected XQDataSource xqjd = new MXQueryXQDataSource();
+
+ public static final String STATE_CHANGE_SETTINGS = "STATE_CHANGE_SETTINGS";
+ public static final int QUERY_RUNNING_DIALOG = 1;
+ public static final int GENERATING_CONTACTS_XML_DIALOG = 2;
+ public static final String UNDEFINED_LABEL = "Undefined";
+ private static final String LOG_TAG = "MXQuery.Start";
+
+ protected Dialog onCreateDialog(int id) {
+ switch(id) {
+ case QUERY_RUNNING_DIALOG:
+ mDialog = new ProgressDialog(mActivity);
+ mDialog.setMessage("Query running...");
+ mDialog.setCancelable(true);
+ return mDialog;
+ case GENERATING_CONTACTS_XML_DIALOG:
+ mDialog = new ProgressDialog(mActivity);
+ mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ mDialog.setMessage("Generating Contacts XML...");
+ mDialog.setCancelable(true);
+ return mDialog;
+ default:
+ return null;
+ }
+ }
+
+ protected void onPrepareDialog(int id, Dialog dialog) {
+ switch(id) {
+ case QUERY_RUNNING_DIALOG:
+ return;
+ case GENERATING_CONTACTS_XML_DIALOG:
+ int numContacts = getContactsCount();
+ mDialog.setMax(numContacts);
+ mDialog.setProgress(0);
+ }
+ }
+
+ /** Called when the activity is first created. */
+ @Override
+ 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><default/></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);
+ 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));
+ } 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.fn_doc))) {
+ mInputView.setText(getString(R.string.fn_doc_xquery));
+ } else if (item.equals(getString(R.string.fn_doc2))) {
+ mInputView.setText(getString(R.string.fn_doc2_xquery));
+ } else if (item.equals(getString(R.string.updating))) {
+ mInputView.setText(getString(R.string.updating_xquery));
+ } else if (item.equals(getString(R.string.updating2))) {
+ mInputView.setText(getString(R.string.updating2_xquery));
+ } else if (item.equals(getString(R.string.put))) {
+ mInputView.setText(getString(R.string.put_xquery));
+ } else if (item.equals(getString(R.string.webservice))) {
+ mInputView.setText(getString(R.string.webservice_xquery));
+ } else if (item.equals(getString(R.string.android_location))) {
+ mInputView.setText(getString(R.string.android_location_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) {
+ runQueryOnService(mInputView.getText().toString());
+ }
+ });
+
+ //TESTING contacts XML generation
+ //generateContactsXML();
+ //printContactsXML();
+
+ /*
+ * This throws a NullPointerException at NativeFuncCall:175
+ * Because of return type void of Button.setText(...) ??
+ */
+// mResultView.setText(
+// runQuery(
+// "declare namespace r = \"java:ch.ethz.mxquery.android.R$id\";" +
+// "declare namespace helper = \"java:ch.ethz.mxquery.android.MXQuery\";" +
+// "declare namespace b = \"java:android.widget.Button\";" +
+// "let $id := r:button()" +
+// "let $button := helper:getButton($id)" +
+// "return b:setText($button, \"Hello XQuery!\")"
+// )
+// );
+ }
+
+ 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);
+
+ // 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() {
+
+ 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);
+ }
+
+ public void updateUiFromXquery(final String text) {
+ runOnUiThread(new Runnable() {
+ public void run() {
+ mButton.setText(text);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.generate_contacts_XML:
+ new GenerateContactsXMLAsyncTask().execute();
+ return true;
+ case R.id.location:
+ Intent i = new Intent(this, MyMap.class);
+ startActivity(i);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+
+
+
+
+
+
+ /**
+ * Serializes all Android contacts to an XML file
+ */
+ protected class GenerateContactsXMLAsyncTask extends AsyncTask<Void, Integer, String> {
+ Integer numContacts = 100;
+ final String[] phoneProjection = new String[] {
+ ContactsContract.CommonDataKinds.Phone.NUMBER,
+ ContactsContract.CommonDataKinds.Phone.TYPE
+ };
+
+ final String[] emailProjection = new String[] {
+ ContactsContract.CommonDataKinds.Email.DATA,
+ ContactsContract.CommonDataKinds.Email.TYPE
+ };
+
+ @Override
+ protected void onPreExecute() {
+ mActivity.showDialog(GENERATING_CONTACTS_XML_DIALOG);
+ }
+
+ @Override
+ protected void onPostExecute(String s) {
+ mActivity.removeDialog(GENERATING_CONTACTS_XML_DIALOG);
+
+ //printContactsXML();
+ mResultView.setText(s);
+ }
+
+ @Override
+ protected void onCancelled() {
+ if(mDialog.isShowing())
+ mDialog.dismiss();
+ }
+
+ @Override
+ protected void onProgressUpdate(Integer... progress) {
+ mDialog.incrementProgressBy(1);
+
+ if(progress[0] >= numContacts) {
+ mDialog.setMessage("Saving...");
+ }
+ }
+
+ @Override
+ protected String doInBackground(Void... v) {
+ //generateContactsXML();
+ //return null;
+ return generateContactsXML();
+ }
+
+ /**
+ * Generates XML file for all contact info
+ * Should be moved to a better location after testing
+ */
+ private String generateContactsXML() {
+ System.out.println("generating contacts XML...");
+ ContentResolver cr = getContentResolver();
+ Cursor contactsCursor = getContacts();
+ numContacts = contactsCursor.getCount();
+
+ //FileOutputStream fileOutputStream = null;
+ XmlSerializer serializer = null;
+ StringWriter stringWriter = new StringWriter();
+ String xmlString = null;
+ try {
+ //fileOutputStream = openFileOutput("contacts.xml", MODE_PRIVATE);
+ serializer = Xml.newSerializer();
+ //serializer.setOutput(fileOutputStream, "UTF-8");
+ serializer.setOutput(stringWriter);
+ serializer.startDocument(null, Boolean.valueOf(true));
+ serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
+ serializer.startTag(null, "ANDROID_CONTACTS");
+
+ //iterate through contacts
+ Integer total = 0;
+ while(contactsCursor.moveToNext()) {
+ if(isCancelled()) {
+ return "";
+ }
+
+ String id = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts._ID));
+ String customRingtone = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.CUSTOM_RINGTONE));
+ String name = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
+ Integer hasPhoneNumber = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
+ Long lastTimeContacted = contactsCursor.getLong(contactsCursor.getColumnIndex(ContactsContract.Contacts.LAST_TIME_CONTACTED));
+ String lookupKey = contactsCursor.getString(contactsCursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
+ Long photoId = contactsCursor.getLong(contactsCursor.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
+ Integer sendToVoicemail = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.SEND_TO_VOICEMAIL));
+ Integer starred = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.STARRED));
+ Integer timesContaced = contactsCursor.getInt(contactsCursor.getColumnIndex(ContactsContract.Contacts.TIMES_CONTACTED));
+
+ serializer.startTag(null, "CONTACT");
+ serializer.startTag(null, "_ID");
+ serializer.text(id);
+ serializer.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 = cr.query(
+ ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
+ phoneProjection,
+ ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
+ new String[]{id}, null);
+
+ while (phoneCursor.moveToNext()) {
+ String phoneNumber = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
+ String phoneType = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
+ String phoneTypeLabel = (String) ContactsContract.CommonDataKinds.Phone.getTypeLabel(
+ mActivity.getResources(),
+ Integer.parseInt(phoneType),
+ UNDEFINED_LABEL);
+
+ serializer.startTag(null, "PHONE");
+ serializer.startTag(null, "PHONE_NUMBER");
+ serializer.text(phoneNumber);
+ serializer.endTag(null, "PHONE_NUMBER");
+ serializer.startTag(null, "PHONE_TYPE");
+ serializer.text(phoneTypeLabel);
+ serializer.endTag(null, "PHONE_TYPE");
+ serializer.endTag(null, "PHONE");
+ }
+ phoneCursor.close();
+ serializer.endTag(null, "PHONES");
+ }
+
+ //emails
+ Cursor emailCursor = cr.query(
+ ContactsContract.CommonDataKinds.Email.CONTENT_URI,
+ emailProjection,
+ ContactsContract.CommonDataKinds.Email.CONTACT_ID +" = ?",
+ new String[]{id}, null);
+
+ if(emailCursor.getCount() > 0) {
+ serializer.startTag(null, "EMAILS");
+ while (emailCursor.moveToNext()) {
+ String emailAddress = emailCursor.getString(emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
+ String emailType = emailCursor.getString(emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
+ String emailTypeLabel = (String) ContactsContract.CommonDataKinds.Email.getTypeLabel(
+ mActivity.getResources(),
+ Integer.parseInt(emailType),
+ UNDEFINED_LABEL);
+
+ serializer.startTag(null, "EMAIL");
+ serializer.startTag(null, "EMAIL_ADDRESS");
+ serializer.text(emailAddress);
+ serializer.endTag(null, "EMAIL_ADDRESS");
+ serializer.startTag(null, "EMAIL_TYPE");
+ serializer.text(emailTypeLabel);
+ serializer.endTag(null, "EMAIL_TYPE");
+ serializer.endTag(null, "EMAIL");
+ }
+ emailCursor.close();
+ serializer.endTag(null, "EMAILS");
+ }
+
+ //TODO - addresses, organizations, notes, websites, nickname, etc
+ serializer.endTag(null, "CONTACT");
+
+ // finished one contact, update progress bar
+ total++;
+ publishProgress(total);
+
+ // for testing
+ /*if(total.equals(300)) {
+ break;
+ }*/
+ }
+
+ serializer.endTag(null, "ANDROID_CONTACTS");
+ Log.d(LOG_TAG, "XMLSerializer.endDocument()");
+ serializer.endDocument();
+ Log.d(LOG_TAG, "writing xml to string...");
+ xmlString = stringWriter.toString();
+ Log.d(LOG_TAG, "xml written to string.");
+ writeContactsXMLFile(xmlString);
+
+ } catch (FileNotFoundException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ } finally {
+ contactsCursor.close();
+ try {
+ //fileOutputStream.close();
+ stringWriter.close();
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ }
+ }
+
+ return xmlString;
+ }
+
+ /**
+ * Obtains the contact list for the currently selected account.
+ *
+ * @return A cursor for for accessing the contact list.
+ */
+ private Cursor getContacts() {
+ Uri uri = ContactsContract.Contacts.CONTENT_URI;
+ String[] projection = new String[] {
+ ContactsContract.Contacts._ID,
+ ContactsContract.Contacts.DISPLAY_NAME,
+ ContactsContract.Contacts.HAS_PHONE_NUMBER,
+ ContactsContract.Contacts.LAST_TIME_CONTACTED,
+ ContactsContract.Contacts.LOOKUP_KEY,
+ ContactsContract.Contacts.PHOTO_ID,
+ ContactsContract.Contacts.SEND_TO_VOICEMAIL,
+ ContactsContract.Contacts.STARRED,
+ ContactsContract.Contacts.TIMES_CONTACTED,
+ ContactsContract.Contacts.CUSTOM_RINGTONE
+ };
+ String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'";
+
+ return managedQuery(uri, projection, selection, null, null);
+ }
+
+
+
+ /** Test function to read in Contacts XML file and print to screen
+ *
+ */
+ private void printContactsXML() {
+ System.out.println("printing contacts XML...");
+ try {
+ FileInputStream fileInputStream = openFileInput("contacts.xml");
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
+ BufferedReader bReader = new BufferedReader(inputStreamReader);
+
+ String line = new String();
+ String xml = new String();
+ while((line = bReader.readLine()) != null) {
+ xml = xml + "\n" + line;
+ }
+ mResultView.setText(xml);
+
+ } catch (FileNotFoundException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ }
+ }
+
+ // Write XML to file
+ public void writeContactsXMLFile(String xml){
+ Log.d(LOG_TAG, "starting writeContactsXMLFile");
+ FileOutputStream fileOutputStream = null;
+ OutputStreamWriter outputStreamWriter = null;
+
+ try {
+ fileOutputStream = openFileOutput("contacts.xml", MODE_PRIVATE);
+ outputStreamWriter = new OutputStreamWriter(fileOutputStream);
+ Log.d(LOG_TAG, "writing xml...");
+ outputStreamWriter.write(xml);
+ Log.d(LOG_TAG, "flushing...");
+ outputStreamWriter.flush();
+ Log.d(LOG_TAG, "flush complete...");
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if(outputStreamWriter != null) {
+ outputStreamWriter.close();
+ }
+ if(fileOutputStream != null) {
+ fileOutputStream.close();
+ }
+ } catch (IOException e) {
+ Log.e(LOG_TAG, e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Only needed for serializing Android contacts to XML
+ * @return
+ */
+ private int getContactsCount() {
+ //for testing
+ //return 300;
+
+ Uri uri = ContactsContract.Contacts.CONTENT_URI;
+ String[] projection = new String[] {
+ ContactsContract.Contacts._ID,
+ };
+ String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'";
+
+ Cursor c = managedQuery(uri, projection, selection, null, null);
+ int count = c.getCount();
+ c.close();
+ return count;
+ }
+}
\ No newline at end of file
Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/UserLocationOverlay.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/UserLocationOverlay.java (rev 0)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/UserLocationOverlay.java 2011-06-15 17:50:23 UTC (rev 4404)
@@ -0,0 +1,33 @@
+package ch.ethz.mxquery.androidApp;
+
+import java.util.ArrayList;
+
+import android.graphics.drawable.Drawable;
+
+import com.google.android.maps.ItemizedOverlay;
+import com.google.android.maps.OverlayItem;
+
+public class UserLocationOverlay extends ItemizedOverlay<OverlayItem> {
+
+ private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
+
+ public UserLocationOverlay(Drawable defaultMarker) {
+ super(boundCenterBottom(defaultMarker));
+ populate(); // needed to prevent null pointer exception with empty list
+ }
+
+ @Override
+ protected OverlayItem createItem(int i) {
+ return mOverlays.get(i);
+ }
+
+ @Override
+ public int size() {
+ return mOverlays.size();
+ }
+
+ public void addOverlay(OverlayItem overlay) {
+ mOverlays.add(overlay);
+ populate();
+ }
+}
Added: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/XQueryListener.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/XQueryListener.java (rev 0)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/androidApp/XQueryListener.java 2011-06-15 17:50:23 UTC (rev 4404)
@@ -0,0 +1,5 @@
+package ch.ethz.mxquery.androidApp;
+
+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.
|
|
From: <max...@us...> - 2011-06-15 17:45:06
|
Revision: 4403
http://mxquery.svn.sourceforge.net/mxquery/?rev=4403&view=rev
Author: maxspeicher
Date: 2011-06-15 17:45:00 +0000 (Wed, 15 Jun 2011)
Log Message:
-----------
moved MXQueryService and XQueryListener from Android App to /android
Added Paths:
-----------
trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQueryService.java
trunk/MXQuery/android/src/ch/ethz/mxquery/android/XQueryListener.java
Added: trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQueryService.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQueryService.java (rev 0)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQueryService.java 2011-06-15 17:45:00 UTC (rev 4403)
@@ -0,0 +1,85 @@
+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 android.util.Log;
+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 MXQueryService extends Service {
+ private XQDataSource xqjd = new MXQueryXQDataSource(MXQueryXQDataSource.XQJ_SCRIPTING_MODE);
+ public static String lastResult = null;
+ private static final String LOG_TAG = "MXQuery.MXQueryService";
+
+ // 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();
+ Log.e(LOG_TAG, xqe.getMessage(), xqe);
+ return xqe.getMessage();
+ }
+ return result.toString();
+ }
+
+}
Added: trunk/MXQuery/android/src/ch/ethz/mxquery/android/XQueryListener.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/android/XQueryListener.java (rev 0)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/XQueryListener.java 2011-06-15 17:45:00 UTC (rev 4403)
@@ -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.
|
|
From: <max...@us...> - 2011-06-14 18:54:11
|
Revision: 4402
http://mxquery.svn.sourceforge.net/mxquery/?rev=4402&view=rev
Author: maxspeicher
Date: 2011-06-14 18:54:05 +0000 (Tue, 14 Jun 2011)
Log Message:
-----------
- minor changes to Start.java
- TEST_Android.zip: small sample app with app-specific logic entirely coded in XQuery
Modified Paths:
--------------
trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
Added Paths:
-----------
trunk/MXQuery_Android_App/TEST_Android.zip
Added: trunk/MXQuery_Android_App/TEST_Android.zip
===================================================================
(Binary files differ)
Property changes on: trunk/MXQuery_Android_App/TEST_Android.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java
===================================================================
--- trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-06-14 01:51:42 UTC (rev 4401)
+++ trunk/MXQuery_Android_App/src/ch/ethz/mxquery/android/Start.java 2011-06-14 18:54:05 UTC (rev 4402)
@@ -207,25 +207,6 @@
// "return b:setText($button, \"Hello XQuery!\")"
// )
// );
-
- /*
- * 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 runQuery(String query) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <et...@us...> - 2011-06-14 01:51:53
|
Revision: 4401
http://mxquery.svn.sourceforge.net/mxquery/?rev=4401&view=rev
Author: etterth
Date: 2011-06-14 01:51:42 +0000 (Tue, 14 Jun 2011)
Log Message:
-----------
- Added js-call(functionname,arg0,arg1,...) with up to 6 arguments
Modified Paths:
--------------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/MxQueryToJs.java
trunk/MXQuery/xqib_src/functiongallerytojava.xsl
Added Paths:
-----------
trunk/MXQuery/xqib_samples/js-call1.html
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/JsCall.java
Added: trunk/MXQuery/xqib_samples/js-call1.html
===================================================================
--- trunk/MXQuery/xqib_samples/js-call1.html (rev 0)
+++ trunk/MXQuery/xqib_samples/js-call1.html 2011-06-14 01:51:42 UTC (rev 4401)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>XQIB: Sample page</title>
+ <meta charset="UTF-8"/>
+ <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script>
+<script type="text/javascript">
+ foo = function (arg1){ return 'the text was ' + arg1;};
+</script>
+ <script type="application/xquery">
+ let $x := b:js-call('window.foo', string(b:dom()/id('a')/text()))
+ return
+ replace value of node b:dom()/id('a') with $x
+ </script>
+ </head>
+ <body>
+ <h1 id='a'>Some text.</h1>
+ </body>
+</html>
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-06-13 18:57:15 UTC (rev 4400)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-06-14 01:51:42 UTC (rev 4401)
@@ -1,7 +1,65 @@
<?xml version='1.0' encoding='UTF-8' ?>
<functionGallery basePackage="ch.ethz.mxquery.functions.">
<functionGroup prefix="b" namespace="http://xqib.org">
+<!-- js-call -->
+ <functionDescription>
+ <functionName>js-call</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ </parameters>
+ <className>JsCall</className>
+ </functionDescription>
<functionDescription>
+ <functionName>js-call</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ <paramType>item()*</paramType>
+ </parameters>
+ <className>JsCall</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>js-call</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ </parameters>
+ <className>JsCall</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>js-call</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ </parameters>
+ <className>JsCall</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>js-call</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ </parameters>
+ <className>JsCall</className>
+ </functionDescription> <functionDescription>
+ <functionName>js-call</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ <paramType>item()*</paramType>
+ </parameters>
+ <className>JsCall</className>
+ </functionDescription>
+<!-- js-call -->
+ <functionDescription>
<functionName>js-eval</functionName>
<parameters>
<paramType>xs:string</paramType>
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-13 18:57:15 UTC (rev 4400)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-14 01:51:42 UTC (rev 4401)
@@ -37,6 +37,7 @@
ctx.addNamespace(XQStaticContext.NS_BROWSER,
XQStaticContext.URI_BROWSER);
TypeInfo xs_string = new TypeInfo(FunctionGallery.getType("xs:string",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo item___star = new TypeInfo(FunctionGallery.getType("item()*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
TypeInfo xs_integer = new TypeInfo(FunctionGallery.getType("xs:integer",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
TypeInfo function__ = new TypeInfo(FunctionGallery.getType("function()",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
TypeInfo xs_dateTime = new TypeInfo(FunctionGallery.getType("xs:dateTime",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
@@ -52,7 +53,6 @@
TypeInfo xs_time_quest = new TypeInfo(FunctionGallery.getType("xs:time?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
TypeInfo xs_time = new TypeInfo(FunctionGallery.getType("xs:time",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
TypeInfo xs_anyAtomicType_star = new TypeInfo(FunctionGallery.getType("xs:anyAtomicType*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
- TypeInfo item___star = new TypeInfo(FunctionGallery.getType("item()*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
TypeInfo xs_integer_star = new TypeInfo(FunctionGallery.getType("xs:integer*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
TypeInfo xs_anyAtomicType_quest = new TypeInfo(FunctionGallery.getType("xs:anyAtomicType?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
TypeInfo xs_duration_quest = new TypeInfo(FunctionGallery.getType("xs:duration?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
@@ -102,50 +102,186 @@
qn = new QName(
"http://xqib.org",
"b",
- "js-eval");
+ "js-call");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_string;
+ paramTypes[0] = xs_string;
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+ {
+ ch.ethz.mxquery.functions.b.JsCall iter = new ch.ethz.mxquery.functions.b.JsCall();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "js-call");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = xs_string;
+ paramTypes[1] = item___star;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+ {
+ ch.ethz.mxquery.functions.b.JsCall iter = new ch.ethz.mxquery.functions.b.JsCall();
+ iter.setContext(context, false);
- {
- ch.ethz.mxquery.functions.b.JsEval iter = new ch.ethz.mxquery.functions.b.JsEval();
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "js-call");
+ paramTypes = new TypeInfo[3];
+
+ paramTypes[0] = xs_string;
+ paramTypes[1] = item___star;
+ paramTypes[2] = item___star;
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+ {
+ ch.ethz.mxquery.functions.b.JsCall iter = new ch.ethz.mxquery.functions.b.JsCall();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
"b",
- "timer");
- paramTypes = new TypeInfo[2];
+ "js-call");
+ paramTypes = new TypeInfo[4];
- paramTypes[0] = xs_integer;
+ paramTypes[0] = xs_string;
+ paramTypes[1] = item___star;
+ paramTypes[2] = item___star;
+ paramTypes[3] = item___star;
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
- paramTypes[1] = function__;
+ {
+ ch.ethz.mxquery.functions.b.JsCall iter = new ch.ethz.mxquery.functions.b.JsCall();
+ iter.setContext(context, false);
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "js-call");
+ paramTypes = new TypeInfo[5];
+
+ paramTypes[0] = xs_string;
+ paramTypes[1] = item___star;
+ paramTypes[2] = item___star;
+ paramTypes[3] = item___star;
+ paramTypes[4] = item___star;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+ {
+ ch.ethz.mxquery.functions.b.JsCall iter = new ch.ethz.mxquery.functions.b.JsCall();
+ iter.setContext(context, false);
- {
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "js-call");
+ paramTypes = new TypeInfo[6];
+
+ paramTypes[0] = xs_string;
+ paramTypes[1] = item___star;
+ paramTypes[2] = item___star;
+ paramTypes[3] = item___star;
+ paramTypes[4] = item___star;
+ paramTypes[5] = item___star;
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+ {
+ ch.ethz.mxquery.functions.b.JsCall iter = new ch.ethz.mxquery.functions.b.JsCall();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "js-eval");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = xs_string;
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+ {
+ ch.ethz.mxquery.functions.b.JsEval iter = new ch.ethz.mxquery.functions.b.JsEval();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "timer");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = xs_integer;
+ paramTypes[1] = function__;
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+ {
ch.ethz.mxquery.functions.b.Timer iter = new ch.ethz.mxquery.functions.b.Timer();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -155,18 +291,17 @@
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.GetCookieNames iter = new ch.ethz.mxquery.functions.b.GetCookieNames();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -174,22 +309,20 @@
"getCookie");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_string;
-
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.GetCookie iter = new ch.ethz.mxquery.functions.b.GetCookie();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -197,22 +330,20 @@
"removeCookie");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_string;
-
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.RemoveCookie iter = new ch.ethz.mxquery.functions.b.RemoveCookie();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -220,24 +351,21 @@
"setCookie");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_string;
-
- paramTypes[1] = xs_string;
-
+ paramTypes[0] = xs_string;
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -245,26 +373,22 @@
"setCookie");
paramTypes = new TypeInfo[3];
- paramTypes[0] = xs_string;
-
- paramTypes[1] = xs_string;
-
- paramTypes[2] = xs_dateTime;
-
+ paramTypes[0] = xs_string;
+ paramTypes[1] = xs_string;
+ paramTypes[2] = xs_dateTime;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -274,18 +398,17 @@
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.LocUri iter = new ch.ethz.mxquery.functions.b.LocUri();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -293,22 +416,20 @@
"setHref");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_string;
-
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.SetHref iter = new ch.ethz.mxquery.functions.b.SetHref();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -318,18 +439,17 @@
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.GetLocation iter = new ch.ethz.mxquery.functions.b.GetLocation();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -337,22 +457,20 @@
"alert");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_string;
-
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.Alert iter = new ch.ethz.mxquery.functions.b.Alert();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -360,24 +478,21 @@
"removeClass");
paramTypes = new TypeInfo[2];
- paramTypes[0] = node___plus;
-
- paramTypes[1] = xs_string;
-
+ paramTypes[0] = node___plus;
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.RemoveClassName iter = new ch.ethz.mxquery.functions.b.RemoveClassName();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -385,22 +500,20 @@
"getClasses");
paramTypes = new TypeInfo[1];
- paramTypes[0] = node___plus;
-
+ paramTypes[0] = node___plus;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.GetClasses iter = new ch.ethz.mxquery.functions.b.GetClasses();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -408,24 +521,21 @@
"addClass");
paramTypes = new TypeInfo[2];
- paramTypes[0] = node___plus;
-
- paramTypes[1] = xs_string;
-
+ paramTypes[0] = node___plus;
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.AddClassName iter = new ch.ethz.mxquery.functions.b.AddClassName();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -433,28 +543,23 @@
"addEventListener");
paramTypes = new TypeInfo[4];
- paramTypes[0] = node___plus;
-
- paramTypes[1] = xs_string;
-
- paramTypes[2] = QName;
-
- paramTypes[3] = xs_integer;
-
+ paramTypes[0] = node___plus;
+ paramTypes[1] = xs_string;
+ paramTypes[2] = QName;
+ paramTypes[3] = xs_integer;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -462,26 +567,22 @@
"addEventListener");
paramTypes = new TypeInfo[3];
- paramTypes[0] = node___plus;
-
- paramTypes[1] = xs_string;
-
- paramTypes[2] = function__;
-
+ paramTypes[0] = node___plus;
+ paramTypes[1] = xs_string;
+ paramTypes[2] = function__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -489,28 +590,23 @@
"removeEventListener");
paramTypes = new TypeInfo[4];
- paramTypes[0] = node___plus;
-
- paramTypes[1] = xs_string;
-
- paramTypes[2] = QName;
-
- paramTypes[3] = xs_integer;
-
+ paramTypes[0] = node___plus;
+ paramTypes[1] = xs_string;
+ paramTypes[2] = QName;
+ paramTypes[3] = xs_integer;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -518,26 +614,22 @@
"removeEventListener");
paramTypes = new TypeInfo[3];
- paramTypes[0] = node__;
-
- paramTypes[1] = xs_string;
-
- paramTypes[2] = function__;
-
+ paramTypes[0] = node__;
+ paramTypes[1] = xs_string;
+ paramTypes[2] = function__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -547,18 +639,17 @@
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.Dom iter = new ch.ethz.mxquery.functions.b.Dom();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -568,18 +659,17 @@
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.WindowInfo iter = new ch.ethz.mxquery.functions.b.WindowInfo();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -587,24 +677,21 @@
"getStyle");
paramTypes = new TypeInfo[2];
- paramTypes[0] = node__;
-
- paramTypes[1] = xs_string;
-
+ paramTypes[0] = node__;
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.GetStyle iter = new ch.ethz.mxquery.functions.b.GetStyle();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://xqib.org",
@@ -612,26 +699,22 @@
"setStyle");
paramTypes = new TypeInfo[3];
- paramTypes[0] = node__;
-
- paramTypes[1] = xs_string;
-
- paramTypes[2] = xs_string;
-
+ paramTypes[0] = node__;
+ paramTypes[1] = xs_string;
+ paramTypes[2] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.b.SetStyle iter = new ch.ethz.mxquery.functions.b.SetStyle();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -639,24 +722,21 @@
"QName");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_string_quest;
-
- paramTypes[1] = xs_string;
-
+ paramTypes[0] = xs_string_quest;
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.FNQName iter = new ch.ethz.mxquery.functions.fn.FNQName();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -664,22 +744,20 @@
"abs");
paramTypes = new TypeInfo[1];
- paramTypes[0] = numeric_quest;
-
+ paramTypes[0] = numeric_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Abs iter = new ch.ethz.mxquery.functions.fn.Abs();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -687,23 +765,21 @@
"adjust-date-to-timezone");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_date_quest;
-
+ paramTypes[0] = xs_date_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = xs_date;
+ type = xs_date;
iter.setReturnType(type.getType());
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -711,25 +787,22 @@
"adjust-date-to-timezone");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_date_quest;
-
- paramTypes[1] = xs_dayTimeDuration_quest;
-
+ paramTypes[0] = xs_date_quest;
+ paramTypes[1] = xs_dayTimeDuration_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = xs_date;
+ type = xs_date;
iter.setReturnType(type.getType());
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -737,23 +810,21 @@
"adjust-dateTime-to-timezone");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_dateTime_quest;
-
+ paramTypes[0] = xs_dateTime_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = xs_dateTime;
+ type = xs_dateTime;
iter.setReturnType(type.getType());
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -761,25 +832,22 @@
"adjust-dateTime-to-timezone");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_dateTime_quest;
-
- paramTypes[1] = xs_dayTimeDuration_quest;
-
+ paramTypes[0] = xs_dateTime_quest;
+ paramTypes[1] = xs_dayTimeDuration_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = xs_dateTime;
+ type = xs_dateTime;
iter.setReturnType(type.getType());
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -787,25 +855,22 @@
"adjust-time-to-timezone");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_time_quest;
-
- paramTypes[1] = xs_dayTimeDuration_quest;
-
+ paramTypes[0] = xs_time_quest;
+ paramTypes[1] = xs_dayTimeDuration_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = xs_time;
+ type = xs_time;
iter.setReturnType(type.getType());
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -813,23 +878,21 @@
"adjust-time-to-timezone");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_time_quest;
-
+ paramTypes[0] = xs_time_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = xs_time;
+ type = xs_time;
iter.setReturnType(type.getType());
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -837,22 +900,20 @@
"avg");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_anyAtomicType_star;
-
+ paramTypes[0] = xs_anyAtomicType_star;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Avg iter = new ch.ethz.mxquery.functions.fn.Avg();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -860,22 +921,20 @@
"base-uri");
paramTypes = new TypeInfo[1];
- paramTypes[0] = node__;
-
+ paramTypes[0] = node__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.BaseUri iter = new ch.ethz.mxquery.functions.fn.BaseUri();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -885,18 +944,17 @@
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.BaseUri iter = new ch.ethz.mxquery.functions.fn.BaseUri();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -904,22 +962,20 @@
"boolean");
paramTypes = new TypeInfo[1];
- paramTypes[0] = item___star;
-
+ paramTypes[0] = item___star;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.BooleanIterator iter = new ch.ethz.mxquery.functions.fn.BooleanIterator();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -927,22 +983,20 @@
"ceiling");
paramTypes = new TypeInfo[1];
- paramTypes[0] = numeric_quest;
-
+ paramTypes[0] = numeric_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Ceiling iter = new ch.ethz.mxquery.functions.fn.Ceiling();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -950,24 +1004,21 @@
"codepoint-equal");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_string_quest;
-
- paramTypes[1] = xs_string_quest;
-
+ paramTypes[0] = xs_string_quest;
+ paramTypes[1] = xs_string_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.CodePointEqual iter = new ch.ethz.mxquery.functions.fn.CodePointEqual();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -975,22 +1026,20 @@
"codepoints-to-string");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_integer_star;
-
+ paramTypes[0] = xs_integer_star;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.CodepointsToString iter = new ch.ethz.mxquery.functions.fn.CodepointsToString();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1000,18 +1049,17 @@
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Collection iter = new ch.ethz.mxquery.functions.fn.Collection();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1019,22 +1067,20 @@
"collection");
paramTypes = new TypeInfo[1];
- paramTypes[0] = xs_string_quest;
-
+ paramTypes[0] = xs_string_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Collection iter = new ch.ethz.mxquery.functions.fn.Collection();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1042,26 +1088,22 @@
"compare");
paramTypes = new TypeInfo[3];
- paramTypes[0] = xs_string_quest;
-
- paramTypes[1] = xs_string_quest;
-
- paramTypes[2] = xs_string;
-
+ paramTypes[0] = xs_string_quest;
+ paramTypes[1] = xs_string_quest;
+ paramTypes[2] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Compare iter = new ch.ethz.mxquery.functions.fn.Compare();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1069,24 +1111,21 @@
"compare");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_string_quest;
-
- paramTypes[1] = xs_string_quest;
-
+ paramTypes[0] = xs_string_quest;
+ paramTypes[1] = xs_string_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Compare iter = new ch.ethz.mxquery.functions.fn.Compare();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1094,24 +1133,21 @@
"concat");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_anyAtomicType_quest;
-
- paramTypes[1] = xs_anyAtomicType_quest;
-
+ paramTypes[0] = xs_anyAtomicType_quest;
+ paramTypes[1] = xs_anyAtomicType_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Concat iter = new ch.ethz.mxquery.functions.fn.Concat();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1119,26 +1155,22 @@
"contains");
paramTypes = new TypeInfo[3];
- paramTypes[0] = xs_string_quest;
-
- paramTypes[1] = xs_string_quest;
-
- paramTypes[2] = xs_string;
-
+ paramTypes[0] = xs_string_quest;
+ paramTypes[1] = xs_string_quest;
+ paramTypes[2] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Contains iter = new ch.ethz.mxquery.functions.fn.Contains();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1146,24 +1178,21 @@
"contains");
paramTypes = new TypeInfo[2];
- paramTypes[0] = xs_string_quest;
-
- paramTypes[1] = xs_string_quest;
-
+ paramTypes[0] = xs_string_quest;
+ paramTypes[1] = xs_string_quest;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.Contains iter = new ch.ethz.mxquery.functions.fn.Contains();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1171,22 +1200,20 @@
"count");
paramTypes = new TypeInfo[1];
- paramTypes[0] = item___star;
-
+ paramTypes[0] = item___star;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.CountIterator iter = new ch.ethz.mxquery.functions.fn.CountIterator();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- }
+ }
qn = new QName(
"http://www.w3.org/2005/xpath-functions",
@@ -1196,18 +1223,17 @@
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
+ {
ch.ethz.mxquery.functions.fn.CurrentDate iter = new ch.ethz.mxquery.functions.fn.CurrentDate();
iter.setContext(context, false);
- type = null;
+ type = null;
function = new Function(
null,signature,
iter, null, type );
fg.add(function);
- ...
[truncated message content] |
|
From: <max...@us...> - 2011-06-13 18:57:22
|
Revision: 4400
http://mxquery.svn.sourceforge.net/mxquery/?rev=4400&view=rev
Author: maxspeicher
Date: 2011-06-13 18:57:15 +0000 (Mon, 13 Jun 2011)
Log Message:
-----------
- improved method discovery in NativeFuncCall.java
- added helper classes UiListener and BackgroundTask to Android branch
- extended MXQuery helper class in Android branch with certain methods for using prepared expressions + some minor changes
- added Android-specific version of fn:doc-available() (cf. fn:doc())
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java
trunk/MXQuery/android/src/ch/ethz/mxquery/android/UiListener.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java
Added Paths:
-----------
trunk/MXQuery/android/src/ch/ethz/mxquery/android/BackgroundTask.java
trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/DocAvailable.java
Added: trunk/MXQuery/android/src/ch/ethz/mxquery/android/BackgroundTask.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/android/BackgroundTask.java (rev 0)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/BackgroundTask.java 2011-06-13 18:57:15 UTC (rev 4400)
@@ -0,0 +1,72 @@
+package ch.ethz.mxquery.android;
+
+import android.app.Activity;
+import android.os.AsyncTask;
+
+public class BackgroundTask extends AsyncTask<Void, Void, Void> {
+
+ private Activity current;
+ private String dialogTitle, whileFunction, postFunction;
+
+ public BackgroundTask(String dialogTitle, String whileFunction, String postFunction) {
+ this.current = MXQuery.getActivity();
+ this.dialogTitle = dialogTitle;
+ this.whileFunction = whileFunction;
+ this.postFunction = postFunction;
+ }
+
+ public void execute() {
+ this.execute(null, null, null);
+ }
+
+ @Override
+ protected void onPreExecute() {
+ MXQuery.setDialogTitle(dialogTitle);
+ current.showDialog(1);
+ }
+
+ @Override
+ protected Void doInBackground(Void... arg0) {
+// try {
+// XQPreparedExpression xqjp;
+//
+// if ((xqjp = MXQuery.getPreparedExpression()) != null) {
+// xqjp.bindString(new QName("yyExt"), whileFunction, null);
+// Log.i("BackgroundTask", "Query result: " + MXQuery.doPreparedQuery(xqjp));
+// }
+// } catch (XQException xqe) {
+// xqe.printStackTrace();
+// Log.e("BackgroundTask", "Error: " + xqe.getMessage());
+// }
+
+ MXQuery.doQuery(
+ MXQuery.getXQueryFile() +
+ whileFunction + "()"
+ );
+
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void unused) {
+ current.removeDialog(1);
+
+// try {
+// XQPreparedExpression xqjp;
+//
+// if ((xqjp = MXQuery.getPreparedExpression()) != null) {
+// xqjp.bindString(new QName("yyExt"), postFunction, null);
+// Log.i("BackgroundTask", "Query result: " + MXQuery.doPreparedQuery(xqjp));
+// }
+// } catch (XQException xqe) {
+// xqe.printStackTrace();
+// Log.e("BackgroundTask", "Error: " + xqe.getMessage());
+// }
+
+ MXQuery.doQuery(
+ MXQuery.getXQueryFile() +
+ postFunction + "()"
+ );
+ }
+
+}
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java 2011-06-12 23:50:51 UTC (rev 4399)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java 2011-06-13 18:57:15 UTC (rev 4400)
@@ -1,18 +1,13 @@
package ch.ethz.mxquery.android;
import java.io.BufferedReader;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
-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;
-
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -21,14 +16,26 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
+import android.widget.Toast;
+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.XQPreparedExpression;
+import ch.ethz.repackaged.xquery.XQSequence;
public class MXQuery {
private static Activity act;
private static Context ctx;
+ private static Object[] arguments;
+ private static String dialogTitle;
private static String xQueryFile;
private static XQDataSource xqjd = new MXQueryXQDataSource(MXQueryXQDataSource.XQJ_SCRIPTING_MODE);
+ private static HashMap<Activity, XQPreparedExpression> preparedExpressions = new HashMap<Activity, XQPreparedExpression>();
+
public static void init(Activity act) {
MXQuery.ctx = act.getApplicationContext();
MXQuery.act = act;
@@ -42,10 +49,6 @@
return act;
}
- public static void startActivity(Class<?> next) {
- act.startActivity(new Intent(act, next));
- }
-
public static String getXQueryFile() {
return xQueryFile;
}
@@ -54,6 +57,30 @@
xQueryFile = readXQueryFile(rawResourceId);
}
+ public static XQPreparedExpression getPreparedExpression() {
+ if (preparedExpressions.containsKey(act)) {
+ return preparedExpressions.get(act);
+ } else {
+ return null;
+ }
+ }
+
+ public static XQPreparedExpression getPreparedExpression(Activity a) {
+ if (preparedExpressions.containsKey(a)) {
+ return preparedExpressions.get(a);
+ } else {
+ return null;
+ }
+ }
+
+ public static Object getArgument(int index) {
+ return arguments[index];
+ }
+
+ public static void setArguments(Object[] args) {
+ arguments = args;
+ }
+
public static Button getButton(int id) {
return (Button) act.findViewById(id);
}
@@ -66,6 +93,91 @@
return (TextView) act.findViewById(id);
}
+ public static String getDialogTitle() {
+ return dialogTitle;
+ }
+
+ public static void setDialogTitle(String title) {
+ dialogTitle = title;
+ }
+
+ public static void startActivity(String className) {
+ try {
+ act.startActivity(new Intent(act, Class.forName(className)));
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void makeToast(String msg) {
+ Toast.makeText(act, msg, 1).show();
+ }
+
+ public static void prepareExpression(Activity a, int rawResourceId) throws XQException {
+ String xQueryFile = readXQueryFile(rawResourceId);
+ String funcSignature = "declare( simple| sequential| updating)? function ([^\\s(]+) ?\\(([^)]*)\\)";
+
+ Pattern funcSignaturePattern = Pattern.compile(funcSignature);
+ Matcher funcSignatureMatcher = funcSignaturePattern.matcher(xQueryFile);
+
+ xQueryFile += "\ndeclare variable $yyExt external;\n";
+
+ boolean updating = false;
+ boolean sequential = false;
+ int i = 0;
+ String temp = "";
+ String funcModifier, funcName, argString;
+
+ while (funcSignatureMatcher.find()) {
+ funcModifier = funcSignatureMatcher.group(1);
+ funcName = funcSignatureMatcher.group(2);
+ argString = funcSignatureMatcher.group(3);
+
+ if (funcModifier != null && funcModifier.contains("updating")) {
+ updating = true;
+ } else if (funcModifier != null && funcModifier.contains("sequential")) {
+ sequential = true;
+ }
+
+ temp += (i == 0 ? " if " : " else if ");
+ temp += "($x eq '" + funcName + "') then\n " + funcName + "(";
+
+ int dollarSigns = 0;
+
+ for (int j=0; j<argString.length(); ++j) {
+ if (argString.charAt(j) == '$') {
+ temp += (dollarSigns > 0 ? ", " : "");
+ temp += ("m:getArgument(" + dollarSigns + ")");
+ ++dollarSigns;
+ }
+ }
+
+ temp += ")\n";
+
+ ++i;
+ }
+
+ xQueryFile += "declare ";
+
+ if (updating) {
+ xQueryFile += "updating ";
+ } else if (sequential) {
+ xQueryFile += "sequential ";
+ }
+
+ xQueryFile += (
+ "function local:yyChooseFunction($x) {\n" +
+ " $x,\n" + temp +
+ " else\n 'Error! No function chosen!'\n};\n" +
+ "local:yyChooseFunction($yyExt)"
+ );
+
+ XQConnection xqjc = xqjd.getConnection();
+ XQPreparedExpression xqjp = xqjc.prepareExpression(xQueryFile);
+
+ preparedExpressions.put(a, xqjp);
+ }
+
public static String doQuery(String query) {
StringWriter result = new StringWriter();
@@ -78,11 +190,29 @@
xqjc.close();
} catch (XQException xqe) {
xqe.printStackTrace();
+
return xqe.getMessage();
}
+
return result.toString();
}
+
+ public static String doPreparedQuery(XQPreparedExpression xqjp) {
+ StringWriter result = new StringWriter();
+ try {
+ XQSequence xqjs = xqjp.executeQuery();
+
+ xqjs.writeSequence(result, null);
+ } catch (XQException xqe) {
+ xqe.printStackTrace();
+
+ return xqe.getMessage();
+ }
+
+ return result.toString();
+ }
+
public static String readXQueryFile(int rawResourceId) {
BufferedReader in = new BufferedReader(new InputStreamReader(
act.getResources().openRawResource(rawResourceId)));
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/android/UiListener.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/android/UiListener.java 2011-06-12 23:50:51 UTC (rev 4399)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/UiListener.java 2011-06-13 18:57:15 UTC (rev 4400)
@@ -2,25 +2,40 @@
import android.view.View;
import android.view.View.OnClickListener;
-import ch.ethz.mxquery.android.MXQuery;
public class UiListener implements OnClickListener {
- public String methodName;
+ private String methodName;
public static View view;
public UiListener(String methodName) {
- this.methodName = methodName;
+ this.methodName = methodName;
}
public void onClick(View v) {
- view = v;
-
- MXQuery.doQuery(
- MXQuery.getXQueryFile() +
- methodName +
- "(uil:view())"
- );
+ view = v;
+
+// Object[] args = new Object[1];
+// args[0] = v;
+// MXQuery.setArguments(args);
+//
+// try {
+// XQPreparedExpression xqjp;
+//
+// if ((xqjp = MXQuery.getPreparedExpression()) != null) {
+// xqjp.bindString(new QName("yyExt"), methodName, null);
+// Log.i("UiListener", "Query result: " + MXQuery.doPreparedQuery(xqjp));
+// }
+// } catch (XQException xqe) {
+// xqe.printStackTrace();
+// Log.e("UiListener", "Error: " + xqe.getMessage());
+// }
+
+ MXQuery.doQuery(
+ MXQuery.getXQueryFile() +
+ methodName +
+ "(uil:view())"
+ );
}
}
Added: trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/DocAvailable.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/DocAvailable.java (rev 0)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/DocAvailable.java 2011-06-13 18:57:15 UTC (rev 4400)
@@ -0,0 +1,133 @@
+/* Copyright 2006 - 2009 ETH Zurich
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.ethz.mxquery.functions.fn;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Vector;
+
+import ch.ethz.mxquery.android.MXQuery;
+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.types.TypeLexicalConstraints;
+import ch.ethz.mxquery.datamodel.xdm.BooleanToken;
+import ch.ethz.mxquery.exceptions.DynamicException;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.util.IOLib;
+
+public class DocAvailable extends TokenBasedIterator {
+
+ protected void init() throws MXQueryException {
+ String add = getStringValueOrEmpty(subIters[0]);
+
+ if (add == null) {
+ currentToken = BooleanToken.FALSE_TOKEN;
+ return;
+ }
+ URI uri;
+
+ if (!TypeLexicalConstraints.isValidURI(add))
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
+ try {
+ if (TypeLexicalConstraints.isAbsoluteURI(add)) {
+ uri = new URI(add);
+ } else {
+// String base = context.getBaseURI();
+// String add1 = add;
+// if (add1.startsWith("/"))
+// add1 = add1.substring(1);
+ uri = new URI(IOLib.convertToAndroid(add));
+ }
+ } catch (URISyntaxException se) {
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
+ }
+ if(add.startsWith("http://")){
+
+ URL url;
+ try {
+ url = uri.toURL();
+ } catch (MalformedURLException e) {
+ throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
+ }
+ try {
+ InputStream in = url.openStream();
+ in.close();
+ } catch (IOException e) {
+ currentToken = BooleanToken.FALSE_TOKEN;
+ return;
+ }
+ currentToken = BooleanToken.TRUE_TOKEN;
+ // }
+ // catch(Exception e){
+ // throw new DynamicException(ErrorCodes.A0006_EC_URI_NOT_FOUND, "Remote Data cannot be accessed: " + e);
+ // }
+ }
+ else {
+// File xml;
+// try {
+// xml = new File(uri);
+// }catch(IllegalArgumentException ia) {
+// try {
+// xml = new File(add);
+// } catch (IllegalArgumentException ia2) {
+// throw new DynamicException(ErrorCodes.F0017_INVALID_ARGUMENT_TO_FN_DOC,"Invalid URI given to fn:doc-available", loc);
+// }
+// }
+// if (xml.exists()) {
+// currentToken = BooleanToken.TRUE_TOKEN;
+// } else {
+// currentToken = BooleanToken.FALSE_TOKEN;
+// }
+
+ try {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(
+ MXQuery.getContext().openFileInput(uri.toString())
+ )
+ );
+ currentToken = BooleanToken.TRUE_TOKEN;
+ } catch (FileNotFoundException e) {
+ currentToken = BooleanToken.FALSE_TOKEN;
+ } catch (IOException e) {
+ currentToken = BooleanToken.FALSE_TOKEN;
+ }
+ }
+ }
+
+ public TypeInfo getStaticType() {
+ return new TypeInfo(Type.BOOLEAN,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack)
+ throws MXQueryException {
+ XDMIterator copy = new DocAvailable();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-06-12 23:50:51 UTC (rev 4399)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-06-13 18:57:15 UTC (rev 4400)
@@ -149,40 +149,59 @@
*/
for (int i=0; i<methods.length; ++i) {
if (methodName.equals(methods[i].getName())) {
+// System.out.println("[CAND] " + methods[i].toGenericString());
Class[] params = methods[i].getParameterTypes();
- boolean add = true;
-
- if (params.length == invocationParams.length) {
+
+ if (invocationParams.length == params.length) {
+ boolean add = true;
+
for (int j=0; j<params.length; ++j) {
+ if (params[j].equals(byte.class)) {
+ params[j] = Byte.class;
+ } else if (params[j].equals(short.class)) {
+ params[j] = Short.class;
+ } else if (params[j].equals(int.class)) {
+ params[j] = Integer.class;
+ } else if (params[j].equals(long.class)) {
+ params[j] = Long.class;
+ } else if (params[j].equals(float.class)) {
+ params[j] = Float.class;
+ } else if (params[j].equals(double.class)) {
+ params[j] = Double.class;
+ } else if (params[j].equals(boolean.class)) {
+ params[j] = Boolean.class;
+ } else if (params[j].equals(char.class)) {
+ params[j] = Character.class;
+ }
+
if (!params[j].isInstance(invocationParams[j])) {
+// System.out.println("failure: "
+// + invocationParams[j].toString() + ", "
+// + invocationParamsTypes[j].getName() + " -> "
+// + params[j].getName());
add = false;
+ } else {
+// System.out.println("success: "
+// + invocationParams[j].toString() + ", "
+// + invocationParamsTypes[j].getName() + " -> "
+// + params[j].getName());
}
}
-
+
if (add) {
+// System.out.println("[ADD] " + methods[i].toGenericString());
candidates.add(methods[i]);
}
}
- }
+ }
}
- try {
- meth = native_function.getMethod(methodName, invocationParamsTypes);
+ if (candidates.size() > 0) {
+ meth = (Method) candidates.get(0);
res = meth.invoke(instanceToCall, invocationParams);
- } catch (NoSuchMethodException e) {
- /*
- * The method name provided by XQuery is either the
- * name of a field, or the method could not be
- * retrieved b/c the parameter types of the signature
- * are interfaces or abstract classes.
- */
- if (candidates.size() == 1) {
- meth = (Method) candidates.get(0);
- res = meth.invoke(instanceToCall, invocationParams);
- } else {
- field = native_function.getField(methodName);
- res = field.get(instanceToCall);
- }
+ } else {
+ field = native_function.getField(methodName);
+ res = field.get(instanceToCall);
}
}
@@ -197,19 +216,19 @@
this.current = new TokenIterator(context, wrap, loc, false);
}
} catch (SecurityException e) {
- throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Native call failed: "+e.getMessage(), loc);
+ throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "SecurityException: Native call failed: "+e.getMessage(), loc);
} catch (NoSuchFieldException e) {
- throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Native call failed: "+e.getMessage(), loc);
+ throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "NoSuchFieldException: Native call failed: "+e.getMessage(), loc);
} catch (NoSuchMethodException e) {
- throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Native call failed: "+e.getMessage(), loc);
+ throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "NoSuchMethodException: Native call failed: "+e.getMessage(), loc);
} catch (IllegalArgumentException e) {
- throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Native call failed: "+e.getMessage(), loc);
+ throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "IllegalArgumentException: Native call failed: "+e.getMessage(), loc);
} catch (IllegalAccessException e) {
- throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Native call failed: "+e.getMessage(), loc);
+ throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "IllegalAccessException: Native call failed: "+e.getMessage(), loc);
} catch (InvocationTargetException e) {
- throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Native call failed: "+e.getMessage(), loc);
+ throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "InvocationTargetException: Native call failed: "+e.getMessage(), loc);
} catch (InstantiationException e) {
- throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Native call failed: "+e.getMessage(), loc);
+ throw new DynamicException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "InstantiationException: Native call failed: "+e.getMessage(), loc);
}
//this.current = new TokenIterator(context, 42,Type.INT, loc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <et...@us...> - 2011-06-12 23:50:59
|
Revision: 4399
http://mxquery.svn.sourceforge.net/mxquery/?rev=4399&view=rev
Author: etterth
Date: 2011-06-12 23:50:51 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
- changed functiongallerytojava.xsl to produce code which should reduce the filesize and improve startup time
- some refactoring for window events
Modified Paths:
--------------
trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Timer.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/JsToMxQuery.java
trunk/MXQuery/xqib_src/functiongallerytojava.xsl
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-06-10 17:28:38 UTC (rev 4398)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-06-12 23:50:51 UTC (rev 4399)
@@ -25,11 +25,14 @@
import ch.ethz.mxquery.util.Hashtable;
import ch.ethz.mxquery.util.LogLevel;
import ch.ethz.mxquery.util.Logger;
+import ch.ethz.mxquery.util.browser.JsToMxQuery;
+import ch.ethz.mxquery.util.browser.MxQueryToJs;
import ch.ethz.mxquery.util.browser.dom.Element;
import ch.ethz.mxquery.util.browser.dom.Node;
import ch.ethz.mxquery.xdmio.XDMSerializer;
import ch.ethz.mxquery.xdmio.XDMSerializerSettings;
+import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.NodeList;
@@ -59,94 +62,118 @@
}
- public static void addModuleContext(Context ctx){
- if (ctx.getModuleURI() != null){
+ public static void addModuleContext(Context ctx) {
+ if (ctx.getModuleURI() != null) {
modules.put(ctx.getModuleURI(), ctx);
}
}
/**
- * creates a new Context with all known modules added
+ * creates a new Context with all known modules added
+ *
* @return the newly created context
* @throws MXQueryException
*/
public static Context createContext() throws MXQueryException {
Context ret = new Context();
Enumeration<String> moduleuris = modules.keys();
- while (moduleuris.hasMoreElements()){
+ while (moduleuris.hasMoreElements()) {
String moduleuri = moduleuris.nextElement();
ret.addModule(modules.get(moduleuri), moduleuri);
}
ret.setDefaultElementNamespace("http://www.w3.org/1999/xhtml");
- // ret.addNamespace("local", Context.URI_LOCAL + (new Integer(contextcounter++)).toString());
+ // ret.addNamespace("local", Context.URI_LOCAL + (new
+ // Integer(contextcounter++)).toString());
return ret;
- // if (modCtx != null)
- // return modCtx;
- //
- // modCtx = new Context();
- //
- // NodeStore nodestore = new NodeStore(Document.get());
- //
- // modCtx.setVariableValue(Context.CONTEXT_ITEM,
- // nodestore.getIterator(Environment.getContext()));
- //
- // return modCtx;
+ // if (modCtx != null)
+ // return modCtx;
+ //
+ // modCtx = new Context();
+ //
+ // NodeStore nodestore = new NodeStore(Document.get());
+ //
+ // modCtx.setVariableValue(Context.CONTEXT_ITEM,
+ // nodestore.getIterator(Environment.getContext()));
+ //
+ // return modCtx;
}
public static void reset() {
- //modCtx = null;
+ // modCtx = null;
co = null;
handlers = null;
}
- public static void addEventListener(Element el, String eventName,
+ public static void addEventListener(JavaScriptObject obj, String eventName,
FunctionItemToken fi, Context ctx) {
if (eventName.startsWith("on"))
eventName = eventName.substring(2);
if (handlers == null)
handlers = new Hashtable<NodeAndEventName, List<FunctionItemToken>>();
- NodeAndEventName test = new NodeAndEventName(el, eventName);
- List<FunctionItemToken> lst = handlers.get(test);
- if (lst == null) {
- lst = new ArrayList<FunctionItemToken>();
- handlers.put(test, lst);
+
+ if (JsToMxQuery.isNode(obj)) {
+ //node
+ Element el = (Element) obj;
+ NodeAndEventName test = new NodeAndEventName(el, eventName);
+ List<FunctionItemToken> lst = handlers.get(test);
+ if (lst == null) {
+ lst = new ArrayList<FunctionItemToken>();
+ handlers.put(test, lst);
+ }
+ lst.add(fi);
}
- lst.add(fi);
- nativeAddEventListener(el, eventName);
+ else {
+ //window
+ //TODO
+
+ }
+
+ nativeAddEventListener(obj, eventName);
}
- public static void removeEventListener(Element el, String eventName,
+ public static void removeEventListener(JavaScriptObject obj, String eventName,
FunctionItemToken fi, Context ctx) throws MXQueryException {
if (eventName.startsWith("on"))
eventName = eventName.substring(2);
if (handlers == null)
throw new MXQueryException("Eventlistener cannot be removed",
"handler to remove cannot be found", null);
- NodeAndEventName test = new NodeAndEventName(el, eventName);
- List<FunctionItemToken> lst = handlers.get(test);
- if (lst == null) {
- throw new MXQueryException("Eventlistener cannot be removed",
- "handler to remove cannot be found", null);
+
+
+ if (JsToMxQuery.isNode(obj)) {
+ Element el = (Element) obj;
+ NodeAndEventName test = new NodeAndEventName(el, eventName);
+ List<FunctionItemToken> lst = handlers.get(test);
+ if (lst == null) {
+ throw new MXQueryException("Eventlistener cannot be removed",
+ "handler to remove cannot be found", null);
+ }
+ List<FunctionItemToken> lstnew = new ArrayList<FunctionItemToken>();
+ ListIterator<FunctionItemToken> it = lst.listIterator();
+
+ while (it.hasNext()) {
+ FunctionItemToken ft = it.next();
+ FunctionSignature fts = ft.getFunction().getFunctionSignature();
+ FunctionSignature fis = fi.getFunction().getFunctionSignature();
+ if (!fis.getName().equals(fts.getName())
+ || fts.getArity() != fis.getArity())
+ lstnew.add(ft);
+ }
+ handlers.remove(test);
+ handlers.put(test, lstnew);
+ if (lst.isEmpty()) {
+ handlers.put(test, null);
+ nativeRemoveEventListener(el, eventName);
+ }
+ } else {
+ //window
+ //TODO
}
- List<FunctionItemToken> lstnew = new ArrayList<FunctionItemToken>();
- ListIterator<FunctionItemToken> it = lst.listIterator();
- while (it.hasNext()) {
- FunctionItemToken ft = it.next();
- FunctionSignature fts = ft.getFunction().getFunctionSignature();
- FunctionSignature fis = fi.getFunction().getFunctionSignature();
- if (!fis.getName().equals(fts.getName()) || fts.getArity() != fis.getArity())
- lstnew.add(ft);
- }
- handlers.remove(test);
- handlers.put(test, lstnew);
- if (lst.isEmpty()) {
- handlers.put(test, null);
- nativeRemoveEventListener(el, eventName);
- }
}
- public static void removeAnonymousEventListeners(Element el, String eventName, Context ctx) throws MXQueryException {
+ public static void removeAnonymousEventListeners(Element el,
+ String eventName, Context ctx) throws MXQueryException {
if (eventName.startsWith("on"))
eventName = eventName.substring(2);
if (handlers == null)
@@ -159,9 +186,9 @@
"handler to remove cannot be found", null);
}
List<FunctionItemToken> lstnew = new ArrayList<FunctionItemToken>();
-
+
ListIterator<FunctionItemToken> it = lst.listIterator();
-
+
while (it.hasNext()) {
FunctionItemToken fi = it.next();
if (fi.getFunction().getFunctionSignature().getName() != null)
@@ -175,7 +202,6 @@
}
}
-
/**
* the callback called by any listened event
*
@@ -186,66 +212,66 @@
Logger log = Logger.getLogger(Environment.class.toString());
log.log(LogLevel.FINER, "Got an event: " + event.getString());
NodeAndEventName test = new NodeAndEventName(event);
- while (test.node.getParentElement()!= null && handlers.get(test) == null){
+ while (test.node.getParentElement() != null
+ && handlers.get(test) == null) {
test.node = test.node.getParentElement();
}
for (FunctionItemToken fi : handlers.get(test)) {
- SingleNodeIterator nodeiter = new SingleNodeIterator(
- test.node);
+ SingleNodeIterator nodeiter = new SingleNodeIterator(test.node);
try {
- //TODO: remove name reference - inline functions don't have a name
- //log.log(LogLevel.FINER, "Calling eventcallback " + fi.getFunction().getFunctionSignature().getName().toString());
+ // TODO: remove name reference - inline functions don't have a
+ // name
+ // log.log(LogLevel.FINER, "Calling eventcallback " +
+ // fi.getFunction().getFunctionSignature().getName().toString());
ListBasedIterator eventiter = new EventIterator(event);
eventiter.setContext(new Context(), true);
Iterator[] subiterators = { nodeiter, eventiter };
-
+
Environment.invokeModule(fi, subiterators);
- //log.log(LogLevel.FINER, "Eventcallback " + fi.getFunction().getFunctionSignature().getName().toString() + " done");
+ // log.log(LogLevel.FINER, "Eventcallback " +
+ // fi.getFunction().getFunctionSignature().getName().toString()
+ // + " done");
eventiter = null;
subiterators = null;
nodeiter = null;
} catch (MXQueryException e) {
- // TODO Auto-generated catch block
-
Environment.displayErrorMessage(new StringBuffer(), null, e,
true);
e.printStackTrace();
}
}
- //TODO decide this dynamically
+ // TODO decide this dynamically
event.stopPropagation();
event.preventDefault();
}
- public static void invokeModule(FunctionItemToken ft, XDMIterator[] subiterators)
- throws MXQueryException {
+ public static void invokeModule(FunctionItemToken ft,
+ XDMIterator[] subiterators) throws MXQueryException {
preProcessDocument();
// try {
if (subiterators == null) {
subiterators = new XDMIterator[0];
}
-
+
Logger log = Logger.getLogger("Environment");
log.log(LogLevel.FINER, "Invoke 'module'");
-
Function f = ft.getFunction();
log.log(LogLevel.FINER, "Got function");
- //set currenttime
+ // set currenttime
modCtx.setCurrentTime(null);
log.log(LogLevel.FINER, "Set time");
- XDMIterator func = f.getFunctionImplementation(modCtx);
-
+ XDMIterator func = f.getFunctionImplementation(modCtx);
+
for (XDMIterator iter : subiterators) {
iter.staticInit();
}
-
+
func.setSubIters(subiterators);
// func.setContext(getContext(), true);
- PreparedStatement prep = new PreparedStatementImpl(
- modCtx, func,
+ PreparedStatement prep = new PreparedStatementImpl(modCtx, func,
Environment.getCompilerOptions(), null);
// NodeStore nodestore = new NodeStore(Document.get());
// prep.addExternalResource(Context.CONTEXT_ITEM,
@@ -281,18 +307,21 @@
}
public static void preProcessDocument() {
- NodeList<com.google.gwt.dom.client.Element> textareas = Document.get().getElementsByTagName("textarea");
- for (int i=0;i<textareas.getLength();i++){
- //TODO more workarounds
+ NodeList<com.google.gwt.dom.client.Element> textareas = Document.get()
+ .getElementsByTagName("textarea");
+ for (int i = 0; i < textareas.getLength(); i++) {
+ // TODO more workarounds
TextAreaElement ta = (TextAreaElement) textareas.getItem(i);
Element.createFromGwtNode(ta).setTextContent(ta.getValue());
-
+
}
}
+
public static void postProcessDocument() {
- NodeList<com.google.gwt.dom.client.Element> textareas = Document.get().getElementsByTagName("textarea");
- for (int i=0;i<textareas.getLength();i++){
- //TODO more workarounds
+ NodeList<com.google.gwt.dom.client.Element> textareas = Document.get()
+ .getElementsByTagName("textarea");
+ for (int i = 0; i < textareas.getLength(); i++) {
+ // TODO more workarounds
TextAreaElement ta = (TextAreaElement) textareas.getItem(i);
ta.setValue(Element.createFromGwtNode(ta).getTextContent());
@@ -310,18 +339,18 @@
// subs[i]=null;
// }
// }
- private static final native void nativeAddEventListener(Element el,
- String eventName)/*-{
- // el.addEventListener('click', function (ev) {$wnd.alert('test');}, false);
- if (el.addEventListener){//good browser
- el.addEventListener(eventName, @ch.ethz.mxqjs.client.Environment::eventCallback(Lcom/google/gwt/dom/client/NativeEvent;), false);
- }
- else {//bad browser
- el.attachEvent('on' + eventName, @ch.ethz.mxqjs.client.Environment::eventCallback(Lcom/google/gwt/dom/client/NativeEvent;));
-
- }
-
- }-*/;
+ private static final native void nativeAddEventListener(
+ JavaScriptObject obj, String eventName)/*-{
+ // el.addEventListener('click', function (ev) {$wnd.alert('test');}, false);
+ if (el.addEventListener){//good browser
+ el.addEventListener(eventName, @ch.ethz.mxqjs.client.Environment::eventCallback(Lcom/google/gwt/dom/client/NativeEvent;), false);
+ }
+ else {//bad browser
+ el.attachEvent('on' + eventName, @ch.ethz.mxqjs.client.Environment::eventCallback(Lcom/google/gwt/dom/client/NativeEvent;));
+
+ }
+
+ }-*/;
private static final native void nativeRemoveEventListener(Element el,
String eventName)/*-{
@@ -342,10 +371,10 @@
queryResult = new StringBuffer();
if (compiled)
queryResult
- .append("MXQuery successfully compiled, but output the following error during execution:\n");
+ .append("MXQuery successfully compiled, but output the following error during execution:\n");
else
queryResult
- .append("MXQuery output the following error during compilation:\n");
+ .append("MXQuery output the following error during compilation:\n");
QueryLocation loc = err.getLocation();
if (loc.getFile() != null) {
@@ -368,7 +397,7 @@
columnStart));
queryResult.append(" ERROR ");
queryResult.append(queryLines[lineStart - 1]
- .substring(columnStart));
+ .substring(columnStart));
for (int i = 0; i < columnStart + 2; i++)
queryResult.append(" ");
@@ -377,10 +406,9 @@
queryResult.append(i + ": " + queryLines[i - 1] + "\n");
} catch (Exception ex) {
}
- }
- else {//query == nulll
- queryResult.append(err.getErrorCode() + " "
- + err.getMessage() + "\n");
+ } else {// query == nulll
+ queryResult.append(err.getErrorCode() + " " + err.getMessage()
+ + "\n");
}
for (StackTraceElement trace : err.getStackTrace()) {
@@ -396,14 +424,15 @@
}
private native static void native_log(String valueAsString) /*-{
- if (typeof console != "undefined"){
- if (console.log != "undefined")
- console.log(valueAsString);
- }
+ if (typeof console != "undefined") {
+ if (console.log != "undefined")
+ console.log(valueAsString);
+ }
- }-*/;
+ }-*/;
}
+
class NodeAndEventName {
public NodeAndEventName(Node node, String eventName) {
this.node = node;
@@ -439,6 +468,3 @@
String eventName;
}
-
-
-
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-10 17:28:38 UTC (rev 4398)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-12 23:50:51 UTC (rev 4399)
@@ -36,5888 +36,5545 @@
ctx.addNamespace(XQStaticContext.NS_BROWSER,
XQStaticContext.URI_BROWSER);
+ TypeInfo xs_string = new TypeInfo(FunctionGallery.getType("xs:string",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_integer = new TypeInfo(FunctionGallery.getType("xs:integer",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo function__ = new TypeInfo(FunctionGallery.getType("function()",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_dateTime = new TypeInfo(FunctionGallery.getType("xs:dateTime",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo node___plus = new TypeInfo(FunctionGallery.getType("node()+",ctx), Type.OCCURRENCE_IND_ONE_OR_MORE,null);
+ TypeInfo QName = new TypeInfo(FunctionGallery.getType("QName",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo node__ = new TypeInfo(FunctionGallery.getType("node()",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_string_quest = new TypeInfo(FunctionGallery.getType("xs:string?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo numeric_quest = new TypeInfo(FunctionGallery.getType("numeric?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_date_quest = new TypeInfo(FunctionGallery.getType("xs:date?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_date = new TypeInfo(FunctionGallery.getType("xs:date",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_dayTimeDuration_quest = new TypeInfo(FunctionGallery.getType("xs:dayTimeDuration?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_dateTime_quest = new TypeInfo(FunctionGallery.getType("xs:dateTime?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_time_quest = new TypeInfo(FunctionGallery.getType("xs:time?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_time = new TypeInfo(FunctionGallery.getType("xs:time",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_anyAtomicType_star = new TypeInfo(FunctionGallery.getType("xs:anyAtomicType*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
+ TypeInfo item___star = new TypeInfo(FunctionGallery.getType("item()*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
+ TypeInfo xs_integer_star = new TypeInfo(FunctionGallery.getType("xs:integer*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
+ TypeInfo xs_anyAtomicType_quest = new TypeInfo(FunctionGallery.getType("xs:anyAtomicType?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_duration_quest = new TypeInfo(FunctionGallery.getType("xs:duration?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo string = new TypeInfo(FunctionGallery.getType("string",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo node___quest = new TypeInfo(FunctionGallery.getType("node()?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_string_star = new TypeInfo(FunctionGallery.getType("xs:string*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
+ TypeInfo xs_QName_quest = new TypeInfo(FunctionGallery.getType("xs:QName?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_QName = new TypeInfo(FunctionGallery.getType("xs:QName",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo element__ = new TypeInfo(FunctionGallery.getType("element()",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_anyAtomicType = new TypeInfo(FunctionGallery.getType("xs:anyAtomicType",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo node___star = new TypeInfo(FunctionGallery.getType("node()*",ctx), Type.OCCURRENCE_IND_ZERO_OR_MORE,null);
+ TypeInfo item___quest = new TypeInfo(FunctionGallery.getType("item()?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
+ TypeInfo xs_double = new TypeInfo(FunctionGallery.getType("xs:double",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo anyAtomicType = new TypeInfo(FunctionGallery.getType("anyAtomicType",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_ENTITY = new TypeInfo(FunctionGallery.getType("xs:ENTITY",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_ID = new TypeInfo(FunctionGallery.getType("xs:ID",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_IDREF = new TypeInfo(FunctionGallery.getType("xs:IDREF",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_NCName = new TypeInfo(FunctionGallery.getType("xs:NCName",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_NMTOKEN = new TypeInfo(FunctionGallery.getType("xs:NMTOKEN",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_Name = new TypeInfo(FunctionGallery.getType("xs:Name",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_anyURI = new TypeInfo(FunctionGallery.getType("xs:anyURI",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_base64Binary = new TypeInfo(FunctionGallery.getType("xs:base64Binary",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_byte = new TypeInfo(FunctionGallery.getType("xs:byte",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_gDay = new TypeInfo(FunctionGallery.getType("xs:gDay",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_gMonth = new TypeInfo(FunctionGallery.getType("xs:gMonth",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_gMonthDay = new TypeInfo(FunctionGallery.getType("xs:gMonthDay",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_gYear = new TypeInfo(FunctionGallery.getType("xs:gYear",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo gYearMonth = new TypeInfo(FunctionGallery.getType("gYearMonth",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_hexBinary = new TypeInfo(FunctionGallery.getType("xs:hexBinary",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_int = new TypeInfo(FunctionGallery.getType("xs:int",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_language = new TypeInfo(FunctionGallery.getType("xs:language",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_long = new TypeInfo(FunctionGallery.getType("xs:long",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_negativeInteger = new TypeInfo(FunctionGallery.getType("xs:negativeInteger",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_nonNegativeInteger = new TypeInfo(FunctionGallery.getType("xs:nonNegativeInteger",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_nonPositiveInteger = new TypeInfo(FunctionGallery.getType("xs:nonPositiveInteger",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_normalizedString = new TypeInfo(FunctionGallery.getType("xs:normalizedString",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_positiveInteger = new TypeInfo(FunctionGallery.getType("xs:positiveInteger",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_short = new TypeInfo(FunctionGallery.getType("xs:short",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_token = new TypeInfo(FunctionGallery.getType("xs:token",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_unsignedByte = new TypeInfo(FunctionGallery.getType("xs:unsignedByte",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_unsignedInt = new TypeInfo(FunctionGallery.getType("xs:unsignedInt",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_unsignedLong = new TypeInfo(FunctionGallery.getType("xs:unsignedLong",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_unsignedShort = new TypeInfo(FunctionGallery.getType("xs:unsignedShort",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_untypedAtomic = new TypeInfo(FunctionGallery.getType("xs:untypedAtomic",ctx), Type.OCCURRENCE_IND_EXACTLY_ONE,null);
+ TypeInfo xs_double_quest = new TypeInfo(FunctionGallery.getType("xs:double?",ctx), Type.OCCURRENCE_IND_ZERO_OR_ONE,null);
- qn = new QName(
- "http://xqib.org",
- "b",
- "js-eval");
- paramTypes = new TypeInfo[1];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "js-eval");
+ paramTypes = new TypeInfo[1];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.JsEval iter = new ch.ethz.mxquery.functions.b.JsEval();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.JsEval iter = new ch.ethz.mxquery.functions.b.JsEval();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "timer");
- paramTypes = new TypeInfo[2];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "timer");
+ paramTypes = new TypeInfo[2];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:integer",ctx),FunctionGallery.getOccur("xs:integer"),null);
+ paramTypes[0] = xs_integer;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "function()",ctx),FunctionGallery.getOccur("function()"),null);
+ paramTypes[1] = function__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.Timer iter = new ch.ethz.mxquery.functions.b.Timer();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.Timer iter = new ch.ethz.mxquery.functions.b.Timer();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "getCookieNames");
- paramTypes = new TypeInfo[0];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getCookieNames");
+ paramTypes = new TypeInfo[0];
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.GetCookieNames iter = new ch.ethz.mxquery.functions.b.GetCookieNames();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.GetCookieNames iter = new ch.ethz.mxquery.functions.b.GetCookieNames();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "getCookie");
- paramTypes = new TypeInfo[1];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getCookie");
+ paramTypes = new TypeInfo[1];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.GetCookie iter = new ch.ethz.mxquery.functions.b.GetCookie();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.GetCookie iter = new ch.ethz.mxquery.functions.b.GetCookie();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "removeCookie");
- paramTypes = new TypeInfo[1];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeCookie");
+ paramTypes = new TypeInfo[1];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.RemoveCookie iter = new ch.ethz.mxquery.functions.b.RemoveCookie();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.RemoveCookie iter = new ch.ethz.mxquery.functions.b.RemoveCookie();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "setCookie");
- paramTypes = new TypeInfo[2];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "setCookie");
+ paramTypes = new TypeInfo[2];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[0] = xs_string;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "setCookie");
- paramTypes = new TypeInfo[3];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "setCookie");
+ paramTypes = new TypeInfo[3];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[0] = xs_string;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
- paramTypes[2] = new TypeInfo(FunctionGallery.getType(
- "xs:dateTime",ctx),FunctionGallery.getOccur("xs:dateTime"),null);
+ paramTypes[2] = xs_dateTime;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "pageURI");
- paramTypes = new TypeInfo[0];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "pageURI");
+ paramTypes = new TypeInfo[0];
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.LocUri iter = new ch.ethz.mxquery.functions.b.LocUri();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.LocUri iter = new ch.ethz.mxquery.functions.b.LocUri();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "setHref");
- paramTypes = new TypeInfo[1];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "setHref");
+ paramTypes = new TypeInfo[1];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.SetHref iter = new ch.ethz.mxquery.functions.b.SetHref();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.SetHref iter = new ch.ethz.mxquery.functions.b.SetHref();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "getLocation");
- paramTypes = new TypeInfo[0];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getLocation");
+ paramTypes = new TypeInfo[0];
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.GetLocation iter = new ch.ethz.mxquery.functions.b.GetLocation();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.GetLocation iter = new ch.ethz.mxquery.functions.b.GetLocation();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "alert");
- paramTypes = new TypeInfo[1];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "alert");
+ paramTypes = new TypeInfo[1];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[0] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.Alert iter = new ch.ethz.mxquery.functions.b.Alert();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.Alert iter = new ch.ethz.mxquery.functions.b.Alert();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "removeClass");
- paramTypes = new TypeInfo[2];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeClass");
+ paramTypes = new TypeInfo[2];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+ paramTypes[0] = node___plus;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.RemoveClassName iter = new ch.ethz.mxquery.functions.b.RemoveClassName();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.RemoveClassName iter = new ch.ethz.mxquery.functions.b.RemoveClassName();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "getClasses");
- paramTypes = new TypeInfo[1];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getClasses");
+ paramTypes = new TypeInfo[1];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+ paramTypes[0] = node___plus;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.GetClasses iter = new ch.ethz.mxquery.functions.b.GetClasses();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.GetClasses iter = new ch.ethz.mxquery.functions.b.GetClasses();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "addClass");
- paramTypes = new TypeInfo[2];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "addClass");
+ paramTypes = new TypeInfo[2];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+ paramTypes[0] = node___plus;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.AddClassName iter = new ch.ethz.mxquery.functions.b.AddClassName();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.AddClassName iter = new ch.ethz.mxquery.functions.b.AddClassName();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "addEventListener");
- paramTypes = new TypeInfo[4];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "addEventListener");
+ paramTypes = new TypeInfo[4];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+ paramTypes[0] = node___plus;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
- paramTypes[2] = new TypeInfo(FunctionGallery.getType(
- "QName",ctx),FunctionGallery.getOccur("QName"),null);
+ paramTypes[2] = QName;
- paramTypes[3] = new TypeInfo(FunctionGallery.getType(
- "xs:integer",ctx),FunctionGallery.getOccur("xs:integer"),null);
+ paramTypes[3] = xs_integer;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "addEventListener");
- paramTypes = new TypeInfo[3];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "addEventListener");
+ paramTypes = new TypeInfo[3];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+ paramTypes[0] = node___plus;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
- paramTypes[2] = new TypeInfo(FunctionGallery.getType(
- "function()",ctx),FunctionGallery.getOccur("function()"),null);
+ paramTypes[2] = function__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "removeEventListener");
- paramTypes = new TypeInfo[4];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeEventListener");
+ paramTypes = new TypeInfo[4];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+ paramTypes[0] = node___plus;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
- paramTypes[2] = new TypeInfo(FunctionGallery.getType(
- "QName",ctx),FunctionGallery.getOccur("QName"),null);
+ paramTypes[2] = QName;
- paramTypes[3] = new TypeInfo(FunctionGallery.getType(
- "xs:integer",ctx),FunctionGallery.getOccur("xs:integer"),null);
+ paramTypes[3] = xs_integer;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "removeEventListener");
- paramTypes = new TypeInfo[3];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeEventListener");
+ paramTypes = new TypeInfo[3];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()",ctx),FunctionGallery.getOccur("node()"),null);
+ paramTypes[0] = node__;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
- paramTypes[2] = new TypeInfo(FunctionGallery.getType(
- "function()",ctx),FunctionGallery.getOccur("function()"),null);
+ paramTypes[2] = function__;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "dom");
- paramTypes = new TypeInfo[0];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "dom");
+ paramTypes = new TypeInfo[0];
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.Dom iter = new ch.ethz.mxquery.functions.b.Dom();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.Dom iter = new ch.ethz.mxquery.functions.b.Dom();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "windowInfo");
- paramTypes = new TypeInfo[0];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "windowInfo");
+ paramTypes = new TypeInfo[0];
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.WindowInfo iter = new ch.ethz.mxquery.functions.b.WindowInfo();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.WindowInfo iter = new ch.ethz.mxquery.functions.b.WindowInfo();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "getStyle");
- paramTypes = new TypeInfo[2];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getStyle");
+ paramTypes = new TypeInfo[2];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()",ctx),FunctionGallery.getOccur("node()"),null);
+ paramTypes[0] = node__;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.GetStyle iter = new ch.ethz.mxquery.functions.b.GetStyle();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.GetStyle iter = new ch.ethz.mxquery.functions.b.GetStyle();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://xqib.org",
- "b",
- "setStyle");
- paramTypes = new TypeInfo[3];
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "setStyle");
+ paramTypes = new TypeInfo[3];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()",ctx),FunctionGallery.getOccur("node()"),null);
+ paramTypes[0] = node__;
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[1] = xs_string;
- paramTypes[2] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+ paramTypes[2] = xs_string;
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
- {
- ch.ethz.mxquery.functions.b.SetStyle iter = new ch.ethz.mxquery.functions.b.SetStyle();
- iter.setContext(context, false);
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
+ {
+ ch.ethz.mxquery.functions.b.SetStyle iter = new ch.ethz.mxquery.functions.b.SetStyle();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
}
- qn = new QName(
- "http://www.w3.org/2005/xpath-functions",
- "fn",
- "QName");
- paramTypes = new TypeInfo[2];
+ qn = new QName(
+ "http://www.w3.org/2005/xpath-functions",
+ "fn",
+ "QName");
+ paramTypes = new TypeInfo[2];
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string?",ctx),FunctionGallery.getOccur("xs:string?"),null);
+ paramTypes[0] = xs_string_quest;
- ...
[truncated message content] |
|
From: <et...@us...> - 2011-06-10 17:28:45
|
Revision: 4398
http://mxquery.svn.sourceforge.net/mxquery/?rev=4398&view=rev
Author: etterth
Date: 2011-06-10 17:28:38 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
- Updated functiongallery and functiongallerytojava.xsl
- Fixed a Bug where the Store of the document node itself was null
- added b:setHref(xs:string) to change the location
Modified Paths:
--------------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetLocation.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/ElementNodeToken.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java
trunk/MXQuery/xqib_src/functiongallerytojava.xsl
Added Paths:
-----------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetHref.java
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-06-09 06:01:06 UTC (rev 4397)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-06-10 17:28:38 UTC (rev 4398)
@@ -12,7 +12,7 @@
<functionName>timer</functionName>
<parameters>
<paramType>xs:integer</paramType>
- <paramType>QName</paramType>
+ <paramType>function()</paramType>
</parameters>
<className>Timer</className>
</functionDescription>
@@ -52,23 +52,23 @@
<className>SetCookie</className>
</functionDescription>
<!-- TODO: setcookie and removeCookie with more arguments -->
-
+
<functionDescription>
<functionName>pageURI</functionName>
<className>LocUri</className>
</functionDescription>/
<functionDescription>
- <functionName>getLocation</functionName>
- <className>GetLocation</className>
- </functionDescription>
- <functionDescription>
- <functionName>log</functionName>
+ <functionName>setHref</functionName>
<parameters>
<paramType>xs:string</paramType>
</parameters>
- <className>Log</className>
- </functionDescription>
+ <className>SetHref</className>
+ </functionDescription>/
<functionDescription>
+ <functionName>getLocation</functionName>
+ <className>GetLocation</className>
+ </functionDescription>
+ <functionDescription>
<functionName>alert</functionName>
<parameters>
<paramType>xs:string</paramType>
@@ -111,7 +111,7 @@
<parameters>
<paramType>node()+</paramType>
<paramType>xs:string</paramType>
- <paramType>QName</paramType>
+ <paramType>function()</paramType>
</parameters>
<className>AddEventListener</className>
</functionDescription>
@@ -130,7 +130,7 @@
<parameters>
<paramType>node()</paramType>
<paramType>xs:string</paramType>
- <paramType>QName</paramType>
+ <paramType>function()</paramType>
</parameters>
<className>RemoveEventListener</className>
</functionDescription>
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-09 06:01:06 UTC (rev 4397)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-10 17:28:38 UTC (rev 4398)
@@ -18,14 +18,14 @@
class FGPopulator {
public static void populateFunctionGallery(XQStaticContext ctx,
FunctionGallery fg, String id, String resType) throws MXQueryException {
-
- if (resType.equals("ctx")) {
- populateExPath(ctx, fg);
- return;
- }
-
-
-
+
+
+
+ if (resType.equals("ctx")) {
+ populateExPath(ctx, fg);
+ return;
+ }
+
Context context = (Context)ctx;
QName qn;
TypeInfo [] paramTypes;
@@ -238,6 +238,30 @@
qn = new QName(
"http://xqib.org",
"b",
+ "setHref");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+
+ {
+ ch.ethz.mxquery.functions.b.SetHref iter = new ch.ethz.mxquery.functions.b.SetHref();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
"getLocation");
paramTypes = new TypeInfo[0];
@@ -255,7 +279,7 @@
iter, null, type );
fg.add(function);
}
-
+
qn = new QName(
"http://xqib.org",
"b",
@@ -362,6 +386,39 @@
"http://xqib.org",
"b",
"addEventListener");
+ paramTypes = new TypeInfo[4];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "QName",ctx),FunctionGallery.getOccur("QName"),null);
+
+ paramTypes[3] = new TypeInfo(FunctionGallery.getType(
+ "xs:integer",ctx),FunctionGallery.getOccur("xs:integer"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+
+ {
+ ch.ethz.mxquery.functions.b.AddEventListener iter = new ch.ethz.mxquery.functions.b.AddEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "addEventListener");
paramTypes = new TypeInfo[3];
paramTypes[0] = new TypeInfo(FunctionGallery.getType(
@@ -388,8 +445,39 @@
fg.add(function);
}
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeEventListener");
+ paramTypes = new TypeInfo[4];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()+",ctx),FunctionGallery.getOccur("node()+"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(FunctionGallery.getType(
+ "QName",ctx),FunctionGallery.getOccur("QName"),null);
+
+ paramTypes[3] = new TypeInfo(FunctionGallery.getType(
+ "xs:integer",ctx),FunctionGallery.getOccur("xs:integer"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+
+ {
+ ch.ethz.mxquery.functions.b.RemoveEventListener iter = new ch.ethz.mxquery.functions.b.RemoveEventListener();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
-
qn = new QName(
"http://xqib.org",
"b",
@@ -419,36 +507,7 @@
iter, null, type );
fg.add(function);
}
-
- qn = new QName(
- "http://xqib.org",
- "b",
- "removeAnonymousEventListeners");
- paramTypes = new TypeInfo[2];
-
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "node()",ctx),FunctionGallery.getOccur("node()"),null);
-
- paramTypes[1] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
-
- signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
-
- {
- ch.ethz.mxquery.functions.b.RemoveAnonymousEventListener iter = new ch.ethz.mxquery.functions.b.RemoveAnonymousEventListener();
- //ch.ethz.mxquery.functions.b.Alert iter = new ch.ethz.mxquery.functions.b.Alert();
- iter.setContext(context, false);
-
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
- }
-
-
+
qn = new QName(
"http://xqib.org",
"b",
@@ -615,7 +674,9 @@
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:date",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:date",ctx),
+ FunctionGallery.getOccur("xs:date"),null);
iter.setReturnType(type.getType());
@@ -644,7 +705,9 @@
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:date",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:date",ctx),
+ FunctionGallery.getOccur("xs:date"),null);
iter.setReturnType(type.getType());
@@ -670,7 +733,9 @@
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:dateTime",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:dateTime",ctx),
+ FunctionGallery.getOccur("xs:dateTime"),null);
iter.setReturnType(type.getType());
@@ -699,7 +764,9 @@
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:dateTime",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:dateTime",ctx),
+ FunctionGallery.getOccur("xs:dateTime"),null);
iter.setReturnType(type.getType());
@@ -728,7 +795,9 @@
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:time",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:time",ctx),
+ FunctionGallery.getOccur("xs:time"),null);
iter.setReturnType(type.getType());
@@ -754,7 +823,9 @@
ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone iter = new ch.ethz.mxquery.functions.fn.DateTimeAdjustTimezone();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:time",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:time",ctx),
+ FunctionGallery.getOccur("xs:time"),null);
iter.setReturnType(type.getType());
@@ -4504,7 +4575,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:ENTITY",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:ENTITY",ctx),
+ FunctionGallery.getOccur("xs:ENTITY"),null);
iter.setReturnType(type.getType());
@@ -4530,7 +4603,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:ID",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:ID",ctx),
+ FunctionGallery.getOccur("xs:ID"),null);
iter.setReturnType(type.getType());
@@ -4556,7 +4631,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:IDREF",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:IDREF",ctx),
+ FunctionGallery.getOccur("xs:IDREF"),null);
iter.setReturnType(type.getType());
@@ -4582,7 +4659,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:NCName",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:NCName",ctx),
+ FunctionGallery.getOccur("xs:NCName"),null);
iter.setReturnType(type.getType());
@@ -4608,7 +4687,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:NMTOKEN",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:NMTOKEN",ctx),
+ FunctionGallery.getOccur("xs:NMTOKEN"),null);
iter.setReturnType(type.getType());
@@ -4634,7 +4715,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:Name",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:Name",ctx),
+ FunctionGallery.getOccur("xs:Name"),null);
iter.setReturnType(type.getType());
@@ -4684,7 +4767,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:anyURI",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:anyURI",ctx),
+ FunctionGallery.getOccur("xs:anyURI"),null);
iter.setReturnType(type.getType());
@@ -4710,7 +4795,9 @@
ch.ethz.mxquery.functions.xs.XSBinary iter = new ch.ethz.mxquery.functions.xs.XSBinary();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:base64Binary",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:base64Binary",ctx),
+ FunctionGallery.getOccur("xs:base64Binary"),null);
iter.setReturnType(type.getType());
@@ -4760,7 +4847,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:byte",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:byte",ctx),
+ FunctionGallery.getOccur("xs:byte"),null);
iter.setReturnType(type.getType());
@@ -4954,7 +5043,9 @@
ch.ethz.mxquery.functions.xs.XSGregorian iter = new ch.ethz.mxquery.functions.xs.XSGregorian();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:gDay",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:gDay",ctx),
+ FunctionGallery.getOccur("xs:gDay"),null);
iter.setReturnType(type.getType());
@@ -4980,7 +5071,9 @@
ch.ethz.mxquery.functions.xs.XSGregorian iter = new ch.ethz.mxquery.functions.xs.XSGregorian();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:gMonth",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:gMonth",ctx),
+ FunctionGallery.getOccur("xs:gMonth"),null);
iter.setReturnType(type.getType());
@@ -5006,7 +5099,9 @@
ch.ethz.mxquery.functions.xs.XSGregorian iter = new ch.ethz.mxquery.functions.xs.XSGregorian();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:gMonthDay",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:gMonthDay",ctx),
+ FunctionGallery.getOccur("xs:gMonthDay"),null);
iter.setReturnType(type.getType());
@@ -5032,7 +5127,9 @@
ch.ethz.mxquery.functions.xs.XSGregorian iter = new ch.ethz.mxquery.functions.xs.XSGregorian();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:gYear",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:gYear",ctx),
+ FunctionGallery.getOccur("xs:gYear"),null);
iter.setReturnType(type.getType());
@@ -5058,7 +5155,9 @@
ch.ethz.mxquery.functions.xs.XSGregorian iter = new ch.ethz.mxquery.functions.xs.XSGregorian();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("gYearMonth",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("gYearMonth",ctx),
+ FunctionGallery.getOccur("gYearMonth"),null);
iter.setReturnType(type.getType());
@@ -5084,7 +5183,9 @@
ch.ethz.mxquery.functions.xs.XSBinary iter = new ch.ethz.mxquery.functions.xs.XSBinary();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:hexBinary",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:hexBinary",ctx),
+ FunctionGallery.getOccur("xs:hexBinary"),null);
iter.setReturnType(type.getType());
@@ -5110,7 +5211,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:int",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:int",ctx),
+ FunctionGallery.getOccur("xs:int"),null);
iter.setReturnType(type.getType());
@@ -5136,7 +5239,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:integer",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:integer",ctx),
+ FunctionGallery.getOccur("xs:integer"),null);
iter.setReturnType(type.getType());
@@ -5162,7 +5267,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:language",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:language",ctx),
+ FunctionGallery.getOccur("xs:language"),null);
iter.setReturnType(type.getType());
@@ -5188,7 +5295,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:long",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:long",ctx),
+ FunctionGallery.getOccur("xs:long"),null);
iter.setReturnType(type.getType());
@@ -5214,7 +5323,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:negativeInteger",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:negativeInteger",ctx),
+ FunctionGallery.getOccur("xs:negativeInteger"),null);
iter.setReturnType(type.getType());
@@ -5240,7 +5351,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:nonNegativeInteger",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:nonNegativeInteger",ctx),
+ FunctionGallery.getOccur("xs:nonNegativeInteger"),null);
iter.setReturnType(type.getType());
@@ -5266,7 +5379,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:nonPositiveInteger",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:nonPositiveInteger",ctx),
+ FunctionGallery.getOccur("xs:nonPositiveInteger"),null);
iter.setReturnType(type.getType());
@@ -5292,7 +5407,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:normalizedString",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:normalizedString",ctx),
+ FunctionGallery.getOccur("xs:normalizedString"),null);
iter.setReturnType(type.getType());
@@ -5318,7 +5435,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:positiveInteger",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:positiveInteger",ctx),
+ FunctionGallery.getOccur("xs:positiveInteger"),null);
iter.setReturnType(type.getType());
@@ -5344,7 +5463,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:short",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:short",ctx),
+ FunctionGallery.getOccur("xs:short"),null);
iter.setReturnType(type.getType());
@@ -5370,7 +5491,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:string",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:string",ctx),
+ FunctionGallery.getOccur("xs:string"),null);
iter.setReturnType(type.getType());
@@ -5420,7 +5543,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:token",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:token",ctx),
+ FunctionGallery.getOccur("xs:token"),null);
iter.setReturnType(type.getType());
@@ -5446,7 +5571,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:unsignedByte",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:unsignedByte",ctx),
+ FunctionGallery.getOccur("xs:unsignedByte"),null);
iter.setReturnType(type.getType());
@@ -5472,7 +5599,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:unsignedInt",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:unsignedInt",ctx),
+ FunctionGallery.getOccur("xs:unsignedInt"),null);
iter.setReturnType(type.getType());
@@ -5498,7 +5627,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:unsignedLong",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:unsignedLong",ctx),
+ FunctionGallery.getOccur("xs:unsignedLong"),null);
iter.setReturnType(type.getType());
@@ -5524,7 +5655,9 @@
ch.ethz.mxquery.functions.xs.XSInteger iter = new ch.ethz.mxquery.functions.xs.XSInteger();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:unsignedShort",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:unsignedShort",ctx),
+ FunctionGallery.getOccur("xs:unsignedShort"),null);
iter.setReturnType(type.getType());
@@ -5550,7 +5683,9 @@
ch.ethz.mxquery.functions.xs.XSString iter = new ch.ethz.mxquery.functions.xs.XSString();
iter.setContext(context, false);
- type = new TypeInfo(FunctionGallery.getType("xs:untypedAtomic",ctx),Type.OCCURRENCE_IND_EXACTLY_ONE);
+ type = new TypeInfo(
+ FunctionGallery.getType("xs:untypedAtomic",ctx),
+ FunctionGallery.getOccur("xs:untypedAtomic"),null);
iter.setReturnType(type.getType());
@@ -5784,7 +5919,9 @@
iter, null, type );
fg.add(function);
}
-}
+
+
+ }
public static void populateExPath(XQStaticContext ctx,
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetLocation.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetLocation.java 2011-06-09 06:01:06 UTC (rev 4397)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetLocation.java 2011-06-10 17:28:38 UTC (rev 4398)
@@ -67,7 +67,10 @@
@Override
protected XDMIterator copy(Context context, XDMIterator[] subIters,
Vector nestedPredCtxStack) throws MXQueryException {
- return new GetLocation();
+ XDMIterator copy = new GetLocation();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
}
}
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetHref.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetHref.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetHref.java 2011-06-10 17:28:38 UTC (rev 4398)
@@ -0,0 +1,41 @@
+package ch.ethz.mxquery.functions.b;
+
+import java.util.Vector;
+
+import com.google.gwt.user.client.Window.Location;
+
+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.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+
+
+public class SetHref extends TokenBasedIterator {
+
+ @Override
+ protected void init() throws MXQueryException {
+ currentToken = Token.END_SEQUENCE_TOKEN;
+
+ TokenInterface tok = subIters[0].next();
+ String href = tok.getValueAsString();
+ if (href == null) {
+ throw new MXQueryException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "invalid argument in setHref", loc);
+ }
+ Location.replace(href);
+
+ }
+
+ @Override
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ SetHref ret = new SetHref();
+ ret.setContext(context, true);
+ ret.setSubIters(subIters);
+ return ret;
+ }
+
+}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/ElementNodeToken.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/ElementNodeToken.java 2011-06-09 06:01:06 UTC (rev 4397)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/ElementNodeToken.java 2011-06-10 17:28:38 UTC (rev 4398)
@@ -39,10 +39,10 @@
}
@Override
- public String getID() {
- // TODO Auto-generated method stub
- return null;
- }
+ public native String getID() /*-{
+
+ return th...@ch...::node.id || null;
+ }-*/;
@Override
public String[] getIDREFS() {
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java 2011-06-09 06:01:06 UTC (rev 4397)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/update/store/domImpl/NodeToken.java 2011-06-10 17:28:38 UTC (rev 4398)
@@ -20,6 +20,7 @@
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
import ch.ethz.mxquery.datamodel.xdm.XDMScope;
import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.util.browser.dom.Document;
import ch.ethz.mxquery.util.browser.dom.Node;
@@ -120,6 +121,10 @@
@Override
public NodeStore getStore() {
+ if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ return new NodeStore((Document) node);
+
+ }
return new NodeStore(node.getOwnerDocument());
}
Modified: trunk/MXQuery/xqib_src/functiongallerytojava.xsl
===================================================================
--- trunk/MXQuery/xqib_src/functiongallerytojava.xsl 2011-06-09 06:01:06 UTC (rev 4397)
+++ trunk/MXQuery/xqib_src/functiongallerytojava.xsl 2011-06-10 17:28:38 UTC (rev 4398)
@@ -6,12 +6,19 @@
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
+
+
+ if (resType.equals("ctx")) {
+ populateExPath(ctx, fg);
+ return;
+ }
+
Context context = (Context)ctx;
QName qn;
TypeInfo [] paramTypes;
FunctionSignature signature;
Function function;
- int type;
+ TypeInfo type;
String classname;
ctx.addNamespace(XQStaticContext.NS_BROWSER,
@@ -30,10 +37,10 @@
select="count(./parameters/paramType)"/>];
<xsl:for-each select="./parameters/paramType">
paramTypes[<xsl:value-of select="
- position()-1"/>] = new TypeInfo(getType(
- "<xsl:value-of select="text()"/>",ctx),getOccur("<xsl:value-of select="text()"/>"),null);
+ position()-1"/>] = new TypeInfo(FunctionGallery.getType(
+ "<xsl:value-of select="text()"/>",ctx),FunctionGallery.getOccur("<xsl:value-of select="text()"/>"),null);
</xsl:for-each>
- signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
<xsl:variable name="classname"><xsl:value-of select="$basepack"/><xsl:value-of select="$funcgroup/@prefix"/>.<xsl:value-of select="./className"/></xsl:variable>
{
@@ -44,12 +51,14 @@
</xsl:if>
<xsl:choose>
<xsl:when test="count(./className/@type) >0">
- type = getType("<xsl:value-of select="className/@type"/>",ctx);
+ type = new TypeInfo(
+ FunctionGallery.getType("<xsl:value-of select="className/@type"/>",ctx),
+ FunctionGallery.getOccur("<xsl:value-of select="className/@type"/>"),null);
- iter.setReturnType(type);
+ iter.setReturnType(type.getType());
</xsl:when>
<xsl:otherwise>
- type = -1;
+ type = null;
</xsl:otherwise>
</xsl:choose>
function = new Function(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-06-09 06:01:12
|
Revision: 4397
http://mxquery.svn.sourceforge.net/mxquery/?rev=4397&view=rev
Author: pm_fischer
Date: 2011-06-09 06:01:06 +0000 (Thu, 09 Jun 2011)
Log Message:
-----------
More XQJ fixes, this time for better scripting support
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQConnection.java
trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQExpression.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQConnection.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQConnection.java 2011-06-08 20:09:52 UTC (rev 4396)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQConnection.java 2011-06-09 06:01:06 UTC (rev 4397)
@@ -177,15 +177,13 @@
throw new XQException("Static context is null");
try {
XQCompiler compiler = new CompilerImpl();
- if (languageLevel == MXQueryXQDataSource.XQJ_UPDATE_MODE) {
+ if (languageLevel == MXQueryXQDataSource.XQJ_UPDATE_MODE || languageLevel == MXQueryXQDataSource.XQJ_SCRIPTING_MODE) {
co.setUpdate(true);
StoreSet ss = runtime.getEngineContext().getStores();
ss.setSerializeStores(true);
- } else if (languageLevel == MXQueryXQDataSource.XQJ_SCRIPTING_MODE) {
- co.setUpdate(true);
- StoreSet ss = runtime.getEngineContext().getStores();
- ss.setSerializeStores(true);
- }
+ if (languageLevel == MXQueryXQDataSource.XQJ_SCRIPTING_MODE)
+ co.setScripting(true);
+ }
PreparedStatement statement = compiler.compile(ctx.runtime, xquery,co, null, null);
MXQueryXQPreparedExpression mxPreExp = new MXQueryXQPreparedExpression(this, statement);
this.expStore.add(mxPreExp);
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQExpression.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQExpression.java 2011-06-08 20:09:52 UTC (rev 4396)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xqj/MXQueryXQExpression.java 2011-06-09 06:01:06 UTC (rev 4397)
@@ -107,14 +107,12 @@
}
XQCompiler compiler = new CompilerImpl();
// checking the language level
- if (languageLevel == MXQueryXQDataSource.XQJ_UPDATE_MODE) {
+ if (languageLevel == MXQueryXQDataSource.XQJ_UPDATE_MODE ||languageLevel == MXQueryXQDataSource.XQJ_SCRIPTING_MODE) {
co.setUpdate(true);
StoreSet ss = runtime.getEngineContext().getStores();
ss.setSerializeStores(true);
- } else if (languageLevel == MXQueryXQDataSource.XQJ_SCRIPTING_MODE) {
- co.setUpdate(true);
- StoreSet ss = runtime.getEngineContext().getStores();
- ss.setSerializeStores(true);
+ if (languageLevel == MXQueryXQDataSource.XQJ_SCRIPTING_MODE)
+ co.setScripting(true);
}
PreparedStatement statement = compiler.compile(runtime.getEngineContext(), expr,co, null, null);
if(this.cancel){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-06-08 20:09:58
|
Revision: 4396
http://mxquery.svn.sourceforge.net/mxquery/?rev=4396&view=rev
Author: maxspeicher
Date: 2011-06-08 20:09:52 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
- changed Android branch to use XQJ scripting mode
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java
trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java 2011-06-08 11:10:16 UTC (rev 4395)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java 2011-06-08 20:09:52 UTC (rev 4396)
@@ -19,6 +19,7 @@
import android.location.Location;
import android.location.LocationManager;
import android.widget.Button;
+import android.widget.EditText;
import android.widget.TextView;
public class MXQuery {
@@ -26,7 +27,7 @@
private static Activity act;
private static Context ctx;
private static String xQueryFile;
- private static XQDataSource xqjd = new MXQueryXQDataSource(MXQueryXQDataSource.XQJ_UPDATE_MODE);
+ private static XQDataSource xqjd = new MXQueryXQDataSource(MXQueryXQDataSource.XQJ_SCRIPTING_MODE);
public static void init(Activity act) {
MXQuery.ctx = act.getApplicationContext();
@@ -57,6 +58,10 @@
return (Button) act.findViewById(id);
}
+ public static EditText getEditText(int id) {
+ return (EditText) act.findViewById(id);
+ }
+
public static TextView getTextView(int id) {
return (TextView) act.findViewById(id);
}
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-06-08 11:10:16 UTC (rev 4395)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/util/IOLib.java 2011-06-08 20:09:52 UTC (rev 4396)
@@ -264,7 +264,7 @@
return fl.toURI().toString();
}
- private static String convertToAndroid(String toOpen) {
+ public static String convertToAndroid(String toOpen) {
String result = toOpen;
//android-specific treatment of local/file URIs:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-06-08 11:10:22
|
Revision: 4395
http://mxquery.svn.sourceforge.net/mxquery/?rev=4395&view=rev
Author: pm_fischer
Date: 2011-06-08 11:10:16 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
propagate XQJ fix to Android code
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQForwardSequence.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQForwardSequence.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQForwardSequence.java 2011-06-08 08:55:18 UTC (rev 4394)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQForwardSequence.java 2011-06-08 11:10:16 UTC (rev 4395)
@@ -293,44 +293,50 @@
public void writeSequence(OutputStream os, Properties props)
throws XQException {
checkNotClosed();
+ boolean hasNext = true;
if(this.position == 0)
- this.next();
- do {
+ hasNext = this.next();
+ while (hasNext){
getCurrentXQItem(true).writeItem(os, props);
try {
os.write(' ');
} catch (IOException e) {
throw new XQQueryException("Could not write sequence "+e);
}
- } while(next());
+ hasNext = next();
+ };
}
public void writeSequence(Writer ow, Properties props) throws XQException {
checkNotClosed();
+ boolean hasNext = true;
if(this.position == 0)
- this.next();
- do {
+ hasNext = this.next();
+ while (hasNext){
getCurrentXQItem(true).writeItem(ow, props);
try {
ow.write(' ');
} catch (IOException e) {
throw new XQQueryException("Could not write sequence "+e);
}
- } while(next());
+ hasNext = next();
+ };
}
public void writeSequenceToSAX(ContentHandler saxhdlr) throws XQException {
checkNotClosed();
+ boolean hasNext = true;
if (position == 0) {
- next();
+ hasNext = this.next();
}
if (position < 0) {
throw new XQException("The XQSequence is positioned after the last item");
}
- do {
+ while (hasNext){
checkAndSetRetrieved();
resultItem.writeItemToSAX(saxhdlr);
- } while(next());
+ hasNext = next();
+ };
}
protected void checkNotClosed() throws XQException {
if (connection.isClosed()) {
@@ -370,18 +376,19 @@
public void writeSequenceToResult(Result result) throws XQException {
checkNotClosed();
+ boolean hasNext = true;
if (position == 0) {
- next();
+ hasNext = this.next();
}
if (position < 0) {
throw new XQException("The XQSequence is positioned after the last item");
}
- do {
+ while (hasNext){
checkAndSetRetrieved();
resultItem.writeItemToResult(result);
- } while(next());
+ hasNext = next();
+ };
}
-
public XMLStreamReader getItemAsStream() throws XQException {
checkNotClosed();
if (position == 0) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-06-08 08:55:24
|
Revision: 4394
http://mxquery.svn.sourceforge.net/mxquery/?rev=4394&view=rev
Author: pm_fischer
Date: 2011-06-08 08:55:18 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
use new event handler example
Added Paths:
-----------
trunk/MXQuery/xqib_samples/EventHandlers.html
Removed Paths:
-------------
trunk/MXQuery/xqib_samples/removeEventListener.html
Added: trunk/MXQuery/xqib_samples/EventHandlers.html
===================================================================
--- trunk/MXQuery/xqib_samples/EventHandlers.html (rev 0)
+++ trunk/MXQuery/xqib_samples/EventHandlers.html 2011-06-08 08:55:18 UTC (rev 4394)
@@ -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">
+
+ declare updating function local:named-handler($loc, $evt) {
+ insert node <b>named</b> as last into b:dom()//body
+ };
+
+ (b:addEventListener(b:dom()//input[@value="Add named"], "onclick",
+ function($loc,$evt){b:addEventListener((b:dom()//p)[1]/input[@type="button"], "onclick",local:named-handler#2)}),
+ b:addEventListener(b:dom()//input[@value="Remove named"], "onclick",
+ function($loc,$evt){b:removeEventListener((b:dom()//p)[1]/input[@type="button"], "onclick",local:named-handler#2)}),
+ b:addEventListener(b:dom()//input[@value="Add anonymous"], "onclick",
+ function($loc,$evt){b:addEventListener((b:dom()//p)[1]/input[@type="button"], "onclick",
+ %updating function($loc,$evt){insert node <b>anonymous</b> as last into b:dom()//body})}),
+ b:addEventListener(b:dom()//input[@value="Remove anonymous"], "onclick",
+ function($loc,$evt){b:removeAnonymousEventListeners((b:dom()//p)[1]/input[@type="button"], "onclick")})
+
+
+ )
+
+ </script>
+ </head>
+ <body>
+ <a href="index.html"><< Index</a>
+ <h1>Add/Remove Event Listeners</h1>
+ <div><a href="EventHandlers.html">Page</a> | <a href="EventHandlers_source.html">Source</a></div>
+ <p>
+ <input type="button" value="Click for events"/>
+ </p><p>
+ <input type="button" value="Add named"/>
+ <input type="button" value="Add anonymous"/>
+ <input type="button" value="Remove named"/>
+ <input type="button" value="Remove anonymous"/>
+ </p>
+ </body>
+</html>
Deleted: trunk/MXQuery/xqib_samples/removeEventListener.html
===================================================================
--- trunk/MXQuery/xqib_samples/removeEventListener.html 2011-06-08 08:54:35 UTC (rev 4393)
+++ trunk/MXQuery/xqib_samples/removeEventListener.html 2011-06-08 08:55:18 UTC (rev 4394)
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
-
- <head>
- <title>MXQuery JS Demo</title>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
-
- <link type="text/css" rel="stylesheet" href="MXQueryJS.css"></link>
- <script type="text/javascript" language="javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script>
- </head>
-
- <body>
-
- <!-- OPTIONAL: include this if you want history support -->
- <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
-
- <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
- <noscript>
- <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
- Your web browser must have JavaScript enabled
- in order for this application to display correctly.
- </div>
- </noscript>
-
- <script type="application/xquery">
- declare sequential function local:listener($loc, $evtObj) {
-
- b:removeEventListener($loc, "onclick", local:listener#2),
- b:alert($loc);
-
- };
- for $d in b:dom()//div
- return b:addEventListener
- ($d, "onclick", "local:listener")
-
- </script>
-
- <h1>This sample will fire once for each of {Foo, Bar}</h1>
-
- <table align="center">
- <tr>
- <td id="nameFieldContainer"></td>
- <td id="sendButtonContainer"></td>
- </tr>
- <tr>
- <td colspan="2" style="color:red;" id="errorLabelContainer"></td>
- </tr>
- </table>
-
- <div id="paragraph1" style="font-size: 20pt;">Foo</div>
- <div id="paragraph2" style="font-size: 20pt;">Bar</div>
- <p id="someid">This is a pre-alpha version, translated from MXQuery 0.7.0 to Javascript using Google Web Toolkit. Expect bugs!</p>
- </body>
-</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-06-08 08:54:41
|
Revision: 4393
http://mxquery.svn.sourceforge.net/mxquery/?rev=4393&view=rev
Author: pm_fischer
Date: 2011-06-08 08:54:35 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
- removed unneeded b:log function, use fn:trace instead
- support annotations also for inline functions
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
Removed Paths:
-------------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Log.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-06-08 08:52:53 UTC (rev 4392)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-06-08 08:54:35 UTC (rev 4393)
@@ -1751,10 +1751,12 @@
logger.log(LogLevel.INFO, "Completed parsing function "+qname.toString()+ " took "+(System.currentTimeMillis()-startTime));
return true;
- } else {
- index = declareIndex;
- }
-
+ } else
+ if (annotations.size() > 0)
+ generateParseError("function");
+ else
+ index = declareIndex;
+
if (parseKeyword("option")) {
XQName qname = EQName();
@@ -6586,8 +6588,9 @@
private Iterator InlineFunction() throws MXQueryException {
int startIndex = index;
+ Hashtable annotations = Annotation();
if (parseKeyword("function")) {
- Function fn = parseFunctionDef(new Hashtable(), null, false);
+ Function fn = parseFunctionDef(annotations, null, false);
if (fn == null) {
index = startIndex;
return null;
@@ -6599,6 +6602,9 @@
FunctionItemToken fTok = new FunctionItemToken(fn);
return new TokenIterator(getCurrentContext(), fTok, getCurrentLoc(),false);
}
+ } else {
+ if (annotations.size() > 0)
+ generateParseError("function");
}
return null;
}
Deleted: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Log.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Log.java 2011-06-08 08:52:53 UTC (rev 4392)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/Log.java 2011-06-08 08:54:35 UTC (rev 4393)
@@ -1,80 +0,0 @@
-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.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.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.TypeException;
-import ch.ethz.mxquery.functions.fn.Abs;
-import ch.ethz.mxquery.model.TokenBasedIterator;
-import ch.ethz.mxquery.model.XDMIterator;
-
-public class Log extends TokenBasedIterator {
-
- @Override
- protected void init() throws MXQueryException {
- currentToken = Token.END_SEQUENCE_TOKEN;
- if (subIters[0] == null) {
- throw new IllegalArgumentException();
- }
- XDMIterator iter = subIters[0];
- //if (iter instanceof DataValuesIterator) ((DataValuesIterator)iter).setFnData(true);
- TokenInterface tok;
- try {
- tok = iter.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);
- }
-
- switch (type) {
- case Type.END_SEQUENCE:
- break;
- default:
- Environment.log(tok.getValueAsString());
-
- }
-
- }
-
-
-
- @Override
- public TypeInfo getStaticType() {
- return new TypeInfo();
- }
-
-
- @Override
- protected XDMIterator copy(Context context, XDMIterator[] subIters,
- Vector nestedPredCtxStack) throws MXQueryException {
- XDMIterator copy = new Log();
- copy.setContext(context, true);
- copy.setSubIters(subIters);
- return copy;
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-06-08 08:52:59
|
Revision: 4392
http://mxquery.svn.sourceforge.net/mxquery/?rev=4392&view=rev
Author: pm_fischer
Date: 2011-06-08 08:52:53 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
add function to remove anonymous event handlers, some fixes
Modified Paths:
--------------
trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveEventListener.java
Added Paths:
-----------
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveAnonymousEventListener.java
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-06-08 08:50:56 UTC (rev 4391)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-06-08 08:52:53 UTC (rev 4392)
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import java.util.ListIterator;
import ch.ethz.mxquery.contextConfig.CompilerOptions;
import ch.ethz.mxquery.contextConfig.Context;
@@ -12,6 +13,7 @@
import ch.ethz.mxquery.exceptions.QueryLocation;
import ch.ethz.mxquery.functions.Function;
import ch.ethz.mxquery.functions.FunctionGallery;
+import ch.ethz.mxquery.functions.FunctionSignature;
import ch.ethz.mxquery.iterators.browser.EventIterator;
import ch.ethz.mxquery.iterators.browser.ListBasedIterator;
import ch.ethz.mxquery.iterators.browser.SingleNodeIterator;
@@ -126,13 +128,54 @@
throw new MXQueryException("Eventlistener cannot be removed",
"handler to remove cannot be found", null);
}
- lst.remove(fi);
+ List<FunctionItemToken> lstnew = new ArrayList<FunctionItemToken>();
+ ListIterator<FunctionItemToken> it = lst.listIterator();
+
+ while (it.hasNext()) {
+ FunctionItemToken ft = it.next();
+ FunctionSignature fts = ft.getFunction().getFunctionSignature();
+ FunctionSignature fis = fi.getFunction().getFunctionSignature();
+ if (!fis.getName().equals(fts.getName()) || fts.getArity() != fis.getArity())
+ lstnew.add(ft);
+ }
+ handlers.remove(test);
+ handlers.put(test, lstnew);
if (lst.isEmpty()) {
handlers.put(test, null);
nativeRemoveEventListener(el, eventName);
}
}
+ public static void removeAnonymousEventListeners(Element el, String eventName, Context ctx) throws MXQueryException {
+ if (eventName.startsWith("on"))
+ eventName = eventName.substring(2);
+ if (handlers == null)
+ throw new MXQueryException("Eventlistener cannot be removed",
+ "handler to remove cannot be found", null);
+ NodeAndEventName test = new NodeAndEventName(el, eventName);
+ List<FunctionItemToken> lst = handlers.get(test);
+ if (lst == null) {
+ throw new MXQueryException("Eventlistener cannot be removed",
+ "handler to remove cannot be found", null);
+ }
+ List<FunctionItemToken> lstnew = new ArrayList<FunctionItemToken>();
+
+ ListIterator<FunctionItemToken> it = lst.listIterator();
+
+ while (it.hasNext()) {
+ FunctionItemToken fi = it.next();
+ if (fi.getFunction().getFunctionSignature().getName() != null)
+ lstnew.add(fi);
+ }
+ handlers.remove(test);
+ handlers.put(test, lstnew);
+ if (lst.isEmpty()) {
+ handlers.put(test, null);
+ nativeRemoveEventListener(el, eventName);
+ }
+ }
+
+
/**
* the callback called by any listened event
*
@@ -151,13 +194,13 @@
test.node);
try {
//TODO: remove name reference - inline functions don't have a name
- log.log(LogLevel.FINER, "Calling eventcallback " + fi.getFunction().getFunctionSignature().getName().toString());
+ //log.log(LogLevel.FINER, "Calling eventcallback " + fi.getFunction().getFunctionSignature().getName().toString());
ListBasedIterator eventiter = new EventIterator(event);
eventiter.setContext(new Context(), true);
Iterator[] subiterators = { nodeiter, eventiter };
Environment.invokeModule(fi, subiterators);
- log.log(LogLevel.FINER, "Eventcallback " + fi.getFunction().getFunctionSignature().getName().toString() + " done");
+ //log.log(LogLevel.FINER, "Eventcallback " + fi.getFunction().getFunctionSignature().getName().toString() + " done");
eventiter = null;
subiterators = null;
nodeiter = null;
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-08 08:50:56 UTC (rev 4391)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FGPopulator.java 2011-06-08 08:52:53 UTC (rev 4392)
@@ -255,34 +255,10 @@
iter, null, type );
fg.add(function);
}
-
+
qn = new QName(
"http://xqib.org",
"b",
- "log");
- paramTypes = new TypeInfo[1];
-
- paramTypes[0] = new TypeInfo(FunctionGallery.getType(
- "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
-
- signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
-
-
- {
- ch.ethz.mxquery.functions.b.Log iter = new ch.ethz.mxquery.functions.b.Log();
- iter.setContext(context, false);
-
- type = null;
-
- function = new Function(
- null,signature,
- iter, null, type );
- fg.add(function);
- }
-
- qn = new QName(
- "http://xqib.org",
- "b",
"alert");
paramTypes = new TypeInfo[1];
@@ -443,7 +419,36 @@
iter, null, type );
fg.add(function);
}
-
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeAnonymousEventListeners");
+ paramTypes = new TypeInfo[2];
+
+ paramTypes[0] = new TypeInfo(FunctionGallery.getType(
+ "node()",ctx),FunctionGallery.getOccur("node()"),null);
+
+ paramTypes[1] = new TypeInfo(FunctionGallery.getType(
+ "xs:string",ctx),FunctionGallery.getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, new Hashtable());
+
+
+ {
+ ch.ethz.mxquery.functions.b.RemoveAnonymousEventListener iter = new ch.ethz.mxquery.functions.b.RemoveAnonymousEventListener();
+ //ch.ethz.mxquery.functions.b.Alert iter = new ch.ethz.mxquery.functions.b.Alert();
+ iter.setContext(context, false);
+
+ type = null;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+
qn = new QName(
"http://xqib.org",
"b",
Copied: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveAnonymousEventListener.java (from rev 4391, trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveEventListener.java)
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveAnonymousEventListener.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveAnonymousEventListener.java 2011-06-08 08:52:53 UTC (rev 4392)
@@ -0,0 +1,82 @@
+package ch.ethz.mxquery.functions.b;
+
+import java.util.LinkedList;
+import java.util.Vector;
+
+
+import ch.ethz.mxqjs.client.Environment;
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.types.Type;
+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.DynamicException;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.exceptions.TypeException;
+import ch.ethz.mxquery.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.update.store.domImpl.ElementNodeToken;
+import ch.ethz.mxquery.util.LogLevel;
+import ch.ethz.mxquery.util.browser.dom.Element;
+
+public class RemoveAnonymousEventListener extends TokenBasedIterator {
+
+
+ protected void init() throws MXQueryException {
+ currentToken = Token.END_SEQUENCE_TOKEN;
+ String eventname = getStringValue(subIters[1]);
+
+ XDMIterator iter = subIters[0];
+ //if (iter instanceof DataValuesIterator) ((DataValuesIterator)iter).setFnData(true);
+ TokenInterface tok;
+ int type;
+ int level = 0;
+ LinkedList<TokenInterface> tokens = new LinkedList<TokenInterface>();
+ do {
+ tok = iter.next();
+ type = tok.getEventType();
+ switch (type) {
+ case Type.END_SEQUENCE:
+ break;
+ case Type.START_TAG:
+ if (level++ == 0)
+ tokens.add(tok);
+ break;
+ case Type.END_TAG:
+ level--;
+ break;
+ default:
+ }
+ } while (type != Type.END_SEQUENCE);
+ for (TokenInterface token:tokens){
+ removeAnonymousEventHandler(token, eventname);
+ }
+ }
+
+ private void removeAnonymousEventHandler(TokenInterface tok, String eventname) throws MXQueryException {
+ if (!(tok instanceof ElementNodeToken)){
+ return;
+ }
+ ElementNodeToken nt = (ElementNodeToken) tok;
+ Element el = (Element)nt.getNode();
+
+ //resolve functionname
+// qfunctionname.setNamespaceURI(this.getContext().getNamespace(qfunctionname.getNamespacePrefix()).getURI());
+ Context ctx = this.getContext().getParent();//Environment.getContext();
+ Environment.removeAnonymousEventListeners(el, eventname, ctx);
+
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ RemoveAnonymousEventListener copy = new RemoveAnonymousEventListener();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+
+}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveEventListener.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveEventListener.java 2011-06-08 08:50:56 UTC (rev 4391)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveEventListener.java 2011-06-08 08:52:53 UTC (rev 4392)
@@ -19,6 +19,7 @@
import ch.ethz.mxquery.model.TokenBasedIterator;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.update.store.domImpl.ElementNodeToken;
+import ch.ethz.mxquery.util.LogLevel;
import ch.ethz.mxquery.util.browser.dom.Element;
public class RemoveEventListener extends TokenBasedIterator {
@@ -35,6 +36,10 @@
if (functiontoken.getEventType() != Type.FUNCTION_ITEM && subIters[2].next().getEventType() != Type.END_SEQUENCE)
throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Function Item expected", loc);
+ FunctionItemToken ft = (FunctionItemToken)functiontoken;
+ if (ft.getFunction().getFunctionSignature().getName() == null)
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Cannot remove anonymous functions individually", loc);
+
XDMIterator iter = subIters[0];
//if (iter instanceof DataValuesIterator) ((DataValuesIterator)iter).setFnData(true);
TokenInterface tok;
@@ -58,7 +63,7 @@
}
} while (type != Type.END_SEQUENCE);
for (TokenInterface token:tokens){
- removeEventHandler(token, eventname, (FunctionItemToken)functiontoken);
+ removeEventHandler(token, eventname, ft);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-06-08 08:51:03
|
Revision: 4391
http://mxquery.svn.sourceforge.net/mxquery/?rev=4391&view=rev
Author: pm_fischer
Date: 2011-06-08 08:50:56 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
decrease log level for parser
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-06-07 14:50:09 UTC (rev 4390)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-06-08 08:50:56 UTC (rev 4391)
@@ -372,7 +372,7 @@
Object queryVersion) throws MXQueryException {
long parseTime = 0;
if (logger.isLoggable(LogLevel.INFO)) {
- logger.log(LogLevel.FINE,"Parsing started");
+ logger.log(LogLevel.INFO,"Parsing started");
parseTime = System.currentTimeMillis();
}
this.query = query;
@@ -1544,6 +1544,7 @@
int tempIndex = index;
// boolean isCopy = false;
+ long startTime = System.currentTimeMillis();
if (parseKeyword("declare")) {
int declareIndex = index;
boolean expectVar = false;
@@ -1747,7 +1748,7 @@
}
getCurrentContext().addFunction(fn);
- logger.log(LogLevel.FINE, "Completed parsing function "+qname.toString());
+ logger.log(LogLevel.INFO, "Completed parsing function "+qname.toString()+ " took "+(System.currentTimeMillis()-startTime));
return true;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-06-07 14:50:19
|
Revision: 4390
http://mxquery.svn.sourceforge.net/mxquery/?rev=4390&view=rev
Author: maxspeicher
Date: 2011-06-07 14:50:09 +0000 (Tue, 07 Jun 2011)
Log Message:
-----------
Extended NativeFuncCall so that a method is also recognized if the signature contains interfaces/superclasses of the actual parameter objects.
Modified Paths:
--------------
trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java
trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java
Added Paths:
-----------
trunk/MXQuery/android/src/ch/ethz/mxquery/android/UiListener.java
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java 2011-06-07 08:33:26 UTC (rev 4389)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/MXQuery.java 2011-06-07 14:50:09 UTC (rev 4390)
@@ -4,9 +4,18 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.StringWriter;
+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;
+
import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.location.Location;
import android.location.LocationManager;
import android.widget.Button;
@@ -14,8 +23,10 @@
public class MXQuery {
+ private static Activity act;
private static Context ctx;
- private static Activity act;
+ private static String xQueryFile;
+ private static XQDataSource xqjd = new MXQueryXQDataSource(MXQueryXQDataSource.XQJ_UPDATE_MODE);
public static void init(Activity act) {
MXQuery.ctx = act.getApplicationContext();
@@ -30,26 +41,18 @@
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 void startActivity(Class<?> next) {
+ act.startActivity(new Intent(act, next));
}
+ public static String getXQueryFile() {
+ return xQueryFile;
+ }
+
+ public static void setXQueryFile(int rawResourceId) {
+ xQueryFile = readXQueryFile(rawResourceId);
+ }
+
public static Button getButton(int id) {
return (Button) act.findViewById(id);
}
@@ -58,6 +61,40 @@
return (TextView) act.findViewById(id);
}
+ public static 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 xqe.getMessage();
+ }
+ return result.toString();
+ }
+
+ public static String readXQueryFile(int rawResourceId) {
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ act.getResources().openRawResource(rawResourceId)));
+ String query = "";
+ String line;
+
+ try {
+ while ((line = in.readLine()) != null) {
+ query += line;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return query;
+ }
+
public static Location getLocation() {
Location lastKnownLocation = null;
LocationManager locationManager = (LocationManager) act.getSystemService(Context.LOCATION_SERVICE);
Added: trunk/MXQuery/android/src/ch/ethz/mxquery/android/UiListener.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/android/UiListener.java (rev 0)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/android/UiListener.java 2011-06-07 14:50:09 UTC (rev 4390)
@@ -0,0 +1,26 @@
+package ch.ethz.mxquery.android;
+
+import android.view.View;
+import android.view.View.OnClickListener;
+import ch.ethz.mxquery.android.MXQuery;
+
+public class UiListener implements OnClickListener {
+
+ public String methodName;
+ public static View view;
+
+ public UiListener(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public void onClick(View v) {
+ view = v;
+
+ MXQuery.doQuery(
+ MXQuery.getXQueryFile() +
+ methodName +
+ "(uil:view())"
+ );
+ }
+
+}
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java 2011-06-07 08:33:26 UTC (rev 4389)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java 2011-06-07 14:50:09 UTC (rev 4390)
@@ -121,13 +121,19 @@
else
throw de;
}
- //if (operation!=OPERATION_DOC)
+
+ /*
+ * Next five commented-out lines: quick workaround to get
+ * fn:doc(...) working on Android.
+ */
+
+// if (operation!=OPERATION_DOC)
rd = IOLib.getInput(uri, false, encoding, loc);
XDMIterator cur = null;
try {
switch(operation) {
case OPERATION_DOC:
- cur = XDMInputFactory.createXMLInput(context, rd, true, Context.NO_VALIDATION, loc);
+ cur = XDMInputFactory.createXMLInput(context, rd, true, context.getInputValidationMode(), loc);
// if (isInValidateExpression())
// cur = XDMInputFactory.createXMLInput(context, rd, true, Context.SCHEMA_VALIDATION_STRICT, loc);
// else
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-06-07 08:33:26 UTC (rev 4389)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-06-07 14:50:09 UTC (rev 4390)
@@ -19,6 +19,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.ArrayList;
import java.util.Vector;
import ch.ethz.mxquery.contextConfig.Context;
@@ -132,17 +133,56 @@
Method meth = null;
Field field = null;
Object res;
+
if (methodName.equals("new")) {
Constructor con = native_function.getConstructor(invocationParamsTypes);
res = con.newInstance(invocationParams);
- }
- else {
+ } else {
+ ArrayList candidates = new ArrayList();
+ Method[] methods = native_function.getMethods();
+
+ /*
+ * This retrieves a correct method even if the parameter
+ * types of the method signature are interfaces or abstract
+ * classes, which are not the actual types of the objects
+ * passed.
+ */
+ for (int i=0; i<methods.length; ++i) {
+ if (methodName.equals(methods[i].getName())) {
+ Class[] params = methods[i].getParameterTypes();
+ boolean add = true;
+
+ if (params.length == invocationParams.length) {
+ for (int j=0; j<params.length; ++j) {
+ if (!params[j].isInstance(invocationParams[j])) {
+ add = false;
+ }
+ }
+
+ if (add) {
+ candidates.add(methods[i]);
+ }
+ }
+ }
+ }
+
try {
meth = native_function.getMethod(methodName, invocationParamsTypes);
res = meth.invoke(instanceToCall, invocationParams);
} catch (NoSuchMethodException e) {
- field = native_function.getField(methodName);
- res = field.get(instanceToCall);
+ /*
+ * The method name provided by XQuery is either the
+ * name of a field, or the method could not be
+ * retrieved b/c the parameter types of the signature
+ * are interfaces or abstract classes.
+ */
+ if (candidates.size() == 1) {
+ meth = (Method) candidates.get(0);
+ res = meth.invoke(instanceToCall, invocationParams);
+ } else {
+ field = native_function.getField(methodName);
+ res = field.get(instanceToCall);
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|