|
From: <et...@us...> - 2011-05-09 02:20:35
|
Revision: 4326
http://mxquery.svn.sourceforge.net/mxquery/?rev=4326&view=rev
Author: etterth
Date: 2011-05-09 02:20:28 +0000 (Mon, 09 May 2011)
Log Message:
-----------
- Cookies added
- Fixed build
- Asynchronous expath now with handler as last parameter
- Fixed a bug with setting the value in input elements
- The setup script no longer destroys the root's .svn
Modified Paths:
--------------
trunk/MXQuery/xqib_setup_env.sh
trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/EXPathHTTP.xml
trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java
trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml
Added Paths:
-----------
trunk/MXQuery/xqib_samples/cookies.html
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookie.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookieNames.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveCookie.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetCookie.java
Added: trunk/MXQuery/xqib_samples/cookies.html
===================================================================
--- trunk/MXQuery/xqib_samples/cookies.html (rev 0)
+++ trunk/MXQuery/xqib_samples/cookies.html 2011-05-09 02:20:28 UTC (rev 4326)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>XQIB: Sample page</title>
+ <meta charset="UTF-8"/>
+ <link href="style.css" rel="stylesheet" type="text/css">
+ <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script>
+ <script type="application/xquery">
+ import module namespace http-client = "http://expath.org/ns/http-client";
+
+ declare updating function local:getCookie($loc, $evtObj) {
+ let $name := b:dom()//input[@id='name']/@value
+ let $value := b:getCookie($name)
+ return if ($value) then
+
+ (replace value of node b:dom()//div[@id='status'] with ('the value of', $name, 'is', $value),
+ replace value of node b:dom()//input[@id='value']/@value with $value)
+ else
+ (replace value of node b:dom()//div[@id='status'] with concat('there is no cookie with name "', $name , '"'))
+ };
+
+ declare updating function local:setCookie($loc, $evtObj) {
+ b:setCookie(b:dom()//input[@id='name']/@value, b:dom()//input[@id='value']/@value)
+ };
+
+
+ b:addEventListener(b:dom()//input[@id="getbutton"], "onclick", xs:QName("local:getCookie")),
+ b:addEventListener(b:dom()//input[@id="setbutton"], "onclick", xs:QName("local:setCookie"))
+
+ </script>
+ </head>
+ <body>
+ <h1>Cookies</h1>
+ <p/>
+ <div>Name: <input type="text" value="" style="font-size: 30pt; font-weight: bold" id="name"/></div>
+ <div>Value: <input type="text" value="" style="font-size: 30pt; font-weight: bold" id="value"/></div>
+
+ <input type="button" value="Set" style="font-size: 30pt; font-weight: bold" id="setbutton"/>
+ <input type="button" value="Get" style="font-size: 30pt; font-weight: bold" id="getbutton"/>
+ <div id="status"></div>
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/MXQuery/xqib_setup_env.sh
===================================================================
--- trunk/MXQuery/xqib_setup_env.sh 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_setup_env.sh 2011-05-09 02:20:28 UTC (rev 4326)
@@ -1,5 +1,10 @@
cp .classpath mxquery.classpath
-cp -rf xqib_files/* .
-cp -rf xqib_files/.* .
+#mkdir $(find xqib_files/ -type d | grep -v '.svn' )
+#cp $(find xqib_files/ | grep -v '.svn' ) .
+#cp -rf xqib_files/* .
+#cp -rf xqib_files/.* .
+(cd xqib_files ; tar --exclude='.svn' -c -f - .) | tar xfv -
ant xqib-js_prepare
-cp -rf xqib_samples/* war
+
+#cp -rf xqib_samples/* war
+(cd xqib_samples ; tar --exclude='.svn' -c -f - .) | (cd war ; tar xfv -)
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxqjs/client/Environment.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -150,6 +150,7 @@
try {
log.log(LogLevel.FINER, "Calling eventcallback " + functionname.qname.toString());
ListBasedIterator eventiter = new EventIterator(event);
+ eventiter.setContext(new Context(), true);
Iterator[] subiterators = { nodeiter, eventiter };
QName qn = functionname.qname;
qn.setNamespaceURI(functionname.context.getNamespace(
@@ -164,7 +165,7 @@
// TODO Auto-generated catch block
Environment.displayErrorMessage(new StringBuffer(), null, e,
- false);
+ true);
e.printStackTrace();
}
}
@@ -324,6 +325,11 @@
} catch (Exception ex) {
}
}
+ else {//query == nulll
+ queryResult.append(err.getErrorCode() + " "
+ + err.getMessage() + "\n");
+
+ }
for (StackTraceElement trace : err.getStackTrace()) {
queryResult.append("\n");
queryResult.append(trace.toString());
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/EXPathHTTP.xml
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/EXPathHTTP.xml 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/EXPathHTTP.xml 2011-05-09 02:20:28 UTC (rev 4326)
@@ -29,27 +29,27 @@
<functionDescription>
<functionName>async-request</functionName>
<parameters>
- <paramType>QName</paramType>
<paramType>element()?</paramType>
<paramType>string?</paramType>
<paramType>item()*</paramType>
+ <paramType>QName</paramType>
</parameters>
<className op="async">HttpIO</className>
</functionDescription>
<functionDescription>
<functionName>async-request</functionName>
<parameters>
- <paramType>QName</paramType>
<paramType>element()?</paramType>
<paramType>string?</paramType>
+ <paramType>QName</paramType>
</parameters>
<className op="async">HttpIO</className>
</functionDescription>
<functionDescription>
<functionName>async-request</functionName>
<parameters>
+ <paramType>element()?</paramType>
<paramType>QName</paramType>
- <paramType>element()?</paramType>
</parameters>
<className op="async">HttpIO</className>
</functionDescription>
@@ -63,10 +63,10 @@
<functionDescription>
<functionName>async-read</functionName>
<parameters>
+ <paramType>xs:string</paramType>
<paramType>QName</paramType>
- <paramType>xs:string</paramType>
</parameters>
<className op="async read">HttpIO</className>
</functionDescription>
</functionGroup>
-</functionGallery>
\ No newline at end of file
+</functionGallery>
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -172,7 +172,7 @@
private void init() throws MXQueryException {
if (async) {
- XDMIterator handleriter = subIters[0];
+ XDMIterator handleriter = subIters[subIters.length - 1];
this.asynchandlername = handleriter.next().getQNameTokenValue();
if (asynchandlername != null) {
if (this.getContext().getRootContext()
@@ -209,8 +209,8 @@
}
XDMIterator[] oldsubiters = subIters;
subIters = new XDMIterator[oldsubiters.length - 1];
- for (int i = 1; i < oldsubiters.length; i++) {
- subIters[i - 1] = oldsubiters[i];
+ for (int i = 0; i < oldsubiters.length-1; i++) {
+ subIters[i] = oldsubiters[i];
}
}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FG.xml 2011-05-09 02:20:28 UTC (rev 4326)
@@ -2,9 +2,46 @@
<functionGallery basePackage="ch.ethz.mxquery.functions.">
<functionGroup prefix="b" namespace="http://xqib.org">
<functionDescription>
+ <functionName>getCookieNames</functionName>
+ <className>GetCookieNames</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>getCookie</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ </parameters>
+ <className>GetCookie</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>removeCookie</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ </parameters>
+ <className>RemoveCookie</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>setCookie</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ <paramType>xs:string</paramType>
+ </parameters>
+ <className>SetCookie</className>
+ </functionDescription>
+ <functionDescription>
+ <functionName>setCookie</functionName>
+ <parameters>
+ <paramType>xs:string</paramType>
+ <paramType>xs:string</paramType>
+ <paramType>xs:dateTime</paramType>
+ </parameters>
+ <className>SetCookie</className>
+ </functionDescription>
+<!-- TODO: setcookie and removeCookie with more arguments -->
+
+ <functionDescription>
<functionName>pageURI</functionName>
<className>LocUri</className>
- </functionDescription>
+ </functionDescription>/
<functionDescription>
<functionName>getLocation</functionName>
<className>GetLocation</className>
@@ -1645,4 +1682,4 @@
</functionDescription>
</functionGroup>
-</functionGallery>
\ No newline at end of file
+</functionGallery>
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/FunctionGallery.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -198,10 +198,9 @@
Function function;
int type;
String classname;
+
+ ctx.addNamespace("expathhttp", "http://expath.org/ns/http-client");
- ctx.addNamespace(XQStaticContext.NS_EXPATH,
- XQStaticContext.URI_EXPATH);
-
qn = new QName(
"http://expath.org/ns/http-client",
"expathhttp",
@@ -290,16 +289,16 @@
paramTypes = new TypeInfo[4];
paramTypes[0] = new TypeInfo(getType(
- "QName",ctx),getOccur("QName"),null);
+ "element()?",ctx),getOccur("element()?"),null);
paramTypes[1] = new TypeInfo(getType(
- "element()?",ctx),getOccur("element()?"),null);
+ "string?",ctx),getOccur("string?"),null);
paramTypes[2] = new TypeInfo(getType(
- "string?",ctx),getOccur("string?"),null);
+ "item()*",ctx),getOccur("item()*"),null);
paramTypes[3] = new TypeInfo(getType(
- "item()*",ctx),getOccur("item()*"),null);
+ "QName",ctx),getOccur("QName"),null);
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
@@ -325,13 +324,13 @@
paramTypes = new TypeInfo[3];
paramTypes[0] = new TypeInfo(getType(
- "QName",ctx),getOccur("QName"),null);
+ "element()?",ctx),getOccur("element()?"),null);
paramTypes[1] = new TypeInfo(getType(
- "element()?",ctx),getOccur("element()?"),null);
+ "string?",ctx),getOccur("string?"),null);
paramTypes[2] = new TypeInfo(getType(
- "string?",ctx),getOccur("string?"),null);
+ "QName",ctx),getOccur("QName"),null);
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
@@ -357,10 +356,10 @@
paramTypes = new TypeInfo[2];
paramTypes[0] = new TypeInfo(getType(
- "QName",ctx),getOccur("QName"),null);
+ "element()?",ctx),getOccur("element()?"),null);
paramTypes[1] = new TypeInfo(getType(
- "element()?",ctx),getOccur("element()?"),null);
+ "QName",ctx),getOccur("QName"),null);
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
@@ -412,10 +411,10 @@
paramTypes = new TypeInfo[2];
paramTypes[0] = new TypeInfo(getType(
- "QName",ctx),getOccur("QName"),null);
+ "xs:string",ctx),getOccur("xs:string"),null);
paramTypes[1] = new TypeInfo(getType(
- "xs:string",ctx),getOccur("xs:string"),null);
+ "QName",ctx),getOccur("QName"),null);
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
@@ -454,20 +453,89 @@
qn = new QName(
"http://xqib.org",
"b",
- "timer");
+ "getCookieNames");
+ paramTypes = new TypeInfo[0];
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.GetCookieNames iter = new ch.ethz.mxquery.functions.b.GetCookieNames();
+ iter.setContext(context, false);
+
+ type = -1;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "getCookie");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(getType(
+ "xs:string",ctx),getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.GetCookie iter = new ch.ethz.mxquery.functions.b.GetCookie();
+ iter.setContext(context, false);
+
+ type = -1;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "removeCookie");
+ paramTypes = new TypeInfo[1];
+
+ paramTypes[0] = new TypeInfo(getType(
+ "xs:string",ctx),getOccur("xs:string"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.RemoveCookie iter = new ch.ethz.mxquery.functions.b.RemoveCookie();
+ iter.setContext(context, false);
+
+ type = -1;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
+ "setCookie");
paramTypes = new TypeInfo[2];
paramTypes[0] = new TypeInfo(getType(
- "numeric",ctx),getOccur("numeric"),null);
+ "xs:string",ctx),getOccur("xs:string"),null);
paramTypes[1] = new TypeInfo(getType(
- "QName",ctx),getOccur("QName"),null);
+ "xs:string",ctx),getOccur("xs:string"),null);
signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
{
- ch.ethz.mxquery.functions.b.Timer iter = new ch.ethz.mxquery.functions.b.Timer();
+ ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
iter.setContext(context, false);
type = -1;
@@ -481,6 +549,36 @@
qn = new QName(
"http://xqib.org",
"b",
+ "setCookie");
+ paramTypes = new TypeInfo[3];
+
+ paramTypes[0] = new TypeInfo(getType(
+ "xs:string",ctx),getOccur("xs:string"),null);
+
+ paramTypes[1] = new TypeInfo(getType(
+ "xs:string",ctx),getOccur("xs:string"),null);
+
+ paramTypes[2] = new TypeInfo(getType(
+ "xs:dateTime",ctx),getOccur("xs:dateTime"),null);
+
+ signature = new FunctionSignature(qn, paramTypes, FunctionSignature.SYSTEM_FUNCTION, XDMIterator.EXPR_CATEGORY_SIMPLE, false, false);
+
+
+ {
+ ch.ethz.mxquery.functions.b.SetCookie iter = new ch.ethz.mxquery.functions.b.SetCookie();
+ iter.setContext(context, false);
+
+ type = -1;
+
+ function = new Function(
+ null,signature,
+ iter, null, type );
+ fg.add(function);
+ }
+
+ qn = new QName(
+ "http://xqib.org",
+ "b",
"pageURI");
paramTypes = new TypeInfo[0];
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookie.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookie.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookie.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -0,0 +1,43 @@
+package ch.ethz.mxquery.functions.b;
+
+import java.util.Vector;
+
+import com.google.gwt.user.client.Cookies;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.xdm.Token;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.TypeException;
+import ch.ethz.mxquery.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class GetCookie extends TokenBasedIterator {
+
+ @Override
+ protected void init() throws MXQueryException {
+ TokenInterface tok = subIters[0].next();
+ String name = tok.getValueAsString();
+ if (name == null){
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Invalid argument type", loc);
+ }
+
+ String value = Cookies.getCookie(name);
+ if (value != null)
+ this.currentToken = new UntypedAtomicToken(null, value);
+ else
+ this.currentToken = Token.END_SEQUENCE_TOKEN;
+ }
+
+ @Override
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ GetCookie copy = new GetCookie();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookieNames.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookieNames.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/GetCookieNames.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -0,0 +1,36 @@
+package ch.ethz.mxquery.functions.b;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Vector;
+
+import com.google.gwt.user.client.Cookies;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.iterators.browser.ListBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class GetCookieNames extends ListBasedIterator {
+
+ @Override
+ protected void init() throws MXQueryException {
+ lst = new LinkedList<TokenInterface>();
+ Collection<String> cookies = Cookies.getCookieNames();
+ for (String cookie: cookies){
+ lst.add(new UntypedAtomicToken(null, cookie));
+ }
+ }
+
+ @Override
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ GetCookieNames copy = new GetCookieNames();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveCookie.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveCookie.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveCookie.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -0,0 +1,38 @@
+package ch.ethz.mxquery.functions.b;
+
+import java.util.Vector;
+
+import com.google.gwt.user.client.Cookies;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.TypeException;
+import ch.ethz.mxquery.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class RemoveCookie extends TokenBasedIterator {
+
+ @Override
+ protected void init() throws MXQueryException {
+ TokenInterface tok = subIters[0].next();
+ String name = tok.getValueAsString();
+ if (name == null){
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Invalid argument type", loc);
+ }
+
+ Cookies.removeCookie(name);
+ }
+
+ @Override
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ RemoveCookie copy = new RemoveCookie();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Added: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetCookie.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetCookie.java (rev 0)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/SetCookie.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -0,0 +1,58 @@
+package ch.ethz.mxquery.functions.b;
+
+import java.util.Vector;
+
+import com.google.gwt.user.client.Cookies;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.MXQueryDateTime;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.TypeException;
+import ch.ethz.mxquery.model.TokenBasedIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class SetCookie extends TokenBasedIterator {
+
+ @Override
+ protected void init() throws MXQueryException {
+ TokenInterface tok = subIters[0].next();
+ String name = tok.getValueAsString();
+ if (name == null) {
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
+ "Invalid argument type", loc);
+ }
+
+ tok = subIters[1].next();
+ String value = tok.getValueAsString();
+ if (value == null) {
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
+ "Invalid argument type", loc);
+ }
+
+ if (subIters.length == 2) {
+ Cookies.setCookie(name, value);
+ return;
+ }
+ MXQueryDateTime expires = tok.getDateTime();
+ if (expires == null) {
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,
+ "Invalid argument type", loc);
+ }
+
+ Cookies.setCookie(name, value, expires.createCalendar().getTime());
+ // TODO: more overloads
+
+ }
+
+ @Override
+ protected XDMIterator copy(Context context, XDMIterator[] subIters,
+ Vector nestedPredCtxStack) throws MXQueryException {
+ SetCookie copy = new SetCookie();
+ copy.setContext(context, true);
+ copy.setSubIters(subIters);
+ return copy;
+ }
+
+}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -177,7 +177,21 @@
public native Document createDocument() /*-{
return $doc.implementation.createDocument('http://www.w3.org/1999/xhtml', '', null);
}-*/;
+
+ public void nodeSetValue(Node node, String nodeValue) {
+ if (node.getNodeType() == Node.ATTRIBUTE_NODE){
+ ((Attribute)node).getOwnerElement().setAttributeNS(node.getNameSpaceURI(), node.getLocalName(), nodeValue);
+ return;
+ }
+ native_nodeSetValue(node, nodeValue);
+
+ }
+ public native void native_nodeSetValue(Node node, String nodeValue) /*-{
+ node.nodeValue= nodeValue;
+
+ }-*/;
+
// public native Document getIFrameDocument(IFrameElement iframe) /*-{
//// $wnd.ifr = iframe;
// return iframe.contentDocument.document;
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -2,7 +2,13 @@
import java.util.List;
+import org.eclipse.jdt.internal.compiler.ast.ThisReference;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.Namespace;
+
import com.google.gwt.core.client.JsArray;
+import com.google.gwt.dom.client.InputElement;
import com.google.gwt.dom.client.Style;
public class Element extends Node {
@@ -25,6 +31,21 @@
};
public final void setAttributeNS (String namespace, String localName, String value) {
+ String thisNameSpaceURI = this.getNameSpaceURI();
+ if ("http://www.w3.org/1999/xhtml".equals(thisNameSpaceURI)){
+ if ("input".equals(this.getLocalName())) {
+ InputElement el = (InputElement) this.getAsGwtElement();
+ if ("value".equals(localName)) {
+ el.setValue(value);
+ return;
+ } else if ("checked".equals(localName)) {
+
+ el.setChecked("true".equals(value));
+ return;
+ }
+ }
+
+ }
DOMImpl.impl.elementSetAttributeNS(this, namespace, localName, value);
};
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Node.java 2011-05-09 02:20:28 UTC (rev 4326)
@@ -366,7 +366,7 @@
* The value of this node, depending on its type; see the table above. When
* it is defined to be null, setting it has no effect.
*/
- public final native void setNodeValue(String nodeValue) /*-{
- this.nodeValue = nodeValue;
- }-*/;
+ public final void setNodeValue(String nodeValue) {
+ DOMImpl.impl.nodeSetValue(this, nodeValue);
+ }
}
Modified: trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml
===================================================================
--- trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml 2011-05-08 16:32:28 UTC (rev 4325)
+++ trunk/MXQuery/xqib_src/nu/validator/htmlparser/HtmlParser.gwt.xml 2011-05-09 02:20:28 UTC (rev 4326)
@@ -6,6 +6,4 @@
<source path="common"/>
<source path="impl"/>
<source path="gwt"/>
- <entry-point class="nu.validator.htmlparser.gwt.HtmlParserModule"/>
- <add-linker name="sso"/>
</module>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|