|
From: <di...@us...> - 2011-01-23 18:53:40
|
Revision: 13619
http://exist.svn.sourceforge.net/exist/?rev=13619&view=rev
Author: dizzzz
Date: 2011-01-23 18:53:34 +0000 (Sun, 23 Jan 2011)
Log Message:
-----------
[ignore] wrap up of today. things are a bit unclear yet
Modified Paths:
--------------
branches/adam/eXist-xq3/nbproject/build-impl.xml
branches/adam/eXist-xq3/nbproject/genfiles.properties
branches/adam/eXist-xq3/nbproject/project.properties
branches/adam/eXist-xq3/nbproject/project.xml
branches/adam/eXist-xq3/src/org/exist/xquery/TryCatchExpression.java
branches/adam/eXist-xq3/test/src/xquery/TestRunner.java
branches/adam/eXist-xq3/test/src/xquery/xq3_trycatch.xml
Modified: branches/adam/eXist-xq3/nbproject/build-impl.xml
===================================================================
--- branches/adam/eXist-xq3/nbproject/build-impl.xml 2011-01-23 18:44:11 UTC (rev 13618)
+++ branches/adam/eXist-xq3/nbproject/build-impl.xml 2011-01-23 18:53:34 UTC (rev 13619)
@@ -19,7 +19,7 @@
- cleanup
-->
-<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="eXist-1.5-impl">
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="try-catch-impl">
<fail message="Please build using Ant 1.7.1 or higher.">
<condition>
<not>
@@ -319,15 +319,18 @@
<attribute default="${build.classes.dir}" name="destdir"/>
<sequential>
<fail unless="javac.includes">Must set javac.includes</fail>
- <pathconvert pathsep="," property="javac.includes.binary">
+ <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
<path>
<filelist dir="@{destdir}" files="${javac.includes}"/>
</path>
<globmapper from="*.java" to="*.class"/>
</pathconvert>
+ <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
+ <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
<delete>
- <files includes="${javac.includes.binary}"/>
+ <files includesfile="${javac.includesfile.binary}"/>
</delete>
+ <delete file="${javac.includesfile.binary}"/>
</sequential>
</macrodef>
</target>
@@ -522,7 +525,7 @@
<delete file="${built-jar.properties}" quiet="true"/>
</target>
<target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
- <echo level="warn" message="Cycle detected: eXist-1.5 was already built"/>
+ <echo level="warn" message="Cycle detected: try-catch was already built"/>
</target>
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
<mkdir dir="${build.dir}"/>
@@ -976,7 +979,7 @@
<delete file="${built-clean.properties}" quiet="true"/>
</target>
<target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
- <echo level="warn" message="Cycle detected: eXist-1.5 was already built"/>
+ <echo level="warn" message="Cycle detected: try-catch was already built"/>
</target>
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
<mkdir dir="${build.dir}"/>
Modified: branches/adam/eXist-xq3/nbproject/genfiles.properties
===================================================================
--- branches/adam/eXist-xq3/nbproject/genfiles.properties 2011-01-23 18:44:11 UTC (rev 13618)
+++ branches/adam/eXist-xq3/nbproject/genfiles.properties 2011-01-23 18:53:34 UTC (rev 13619)
@@ -3,6 +3,6 @@
nbbuild.xml.stylesheet.CRC32=958a1d3e@1.26.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=d27eb3f9
-nbproject/build-impl.xml.script.CRC32=9e93939f
-nbproject/build-impl.xml.stylesheet.CRC32=f33e10ff@1.38.2.45
+nbproject/build-impl.xml.data.CRC32=b4f7ba84
+nbproject/build-impl.xml.script.CRC32=37d6ceb5
+nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45
Modified: branches/adam/eXist-xq3/nbproject/project.properties
===================================================================
--- branches/adam/eXist-xq3/nbproject/project.properties 2011-01-23 18:44:11 UTC (rev 13618)
+++ branches/adam/eXist-xq3/nbproject/project.properties 2011-01-23 18:53:34 UTC (rev 13619)
@@ -25,7 +25,6 @@
file.reference.milton-api-1.5.5-SNAPSHOT.jar=extensions/webdav/lib/milton-api-1.5.5-SNAPSHOT.jar
file.reference.milton-servlet-1.5.5-SNAPSHOT.jar=extensions/webdav/lib/milton-servlet-1.5.5-SNAPSHOT.jar
file.reference.mime-util-1.3.1.jar=extensions/webdav/lib/mime-util-1.3.1.jar
-file.reference.openid4java-full-0.9.5.jar=lib/user/openid4java-full-0.9.5.jar
file.reference.pkg-repo.jar=lib/core/pkg-repo.jar
file.reference.saxonb-9.1.0.8.jar=lib/endorsed/saxonb-9.1.0.8.jar
file.reference.saxonb-dom-9.1.0.8.jar=lib/endorsed/saxonb-dom-9.1.0.8.jar
@@ -247,8 +246,7 @@
${file.reference.jetty-util-7.1.6.v20100715.jar}:\
${file.reference.jetty-webapp-7.1.6.v20100715.jar}:\
${file.reference.jetty-websocket-7.1.6.v20100715.jar}:\
- ${file.reference.jetty-xml-7.1.6.v20100715.jar}:\
- ${file.reference.openid4java-full-0.9.5.jar}
+ ${file.reference.jetty-xml-7.1.6.v20100715.jar}
javadoc.additionalparam=-J-Xmx320m
build.classes.dir=${build.dir}/classes
file.reference.samples-src=samples/src
Modified: branches/adam/eXist-xq3/nbproject/project.xml
===================================================================
--- branches/adam/eXist-xq3/nbproject/project.xml 2011-01-23 18:44:11 UTC (rev 13618)
+++ branches/adam/eXist-xq3/nbproject/project.xml 2011-01-23 18:53:34 UTC (rev 13619)
@@ -3,7 +3,7 @@
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
- <name>eXist-1.5</name>
+ <name>try-catch</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<source-roots>
<root id="src.dir" name="Core"/>
Modified: branches/adam/eXist-xq3/src/org/exist/xquery/TryCatchExpression.java
===================================================================
--- branches/adam/eXist-xq3/src/org/exist/xquery/TryCatchExpression.java 2011-01-23 18:44:11 UTC (rev 13618)
+++ branches/adam/eXist-xq3/src/org/exist/xquery/TryCatchExpression.java 2011-01-23 18:53:34 UTC (rev 13619)
@@ -28,8 +28,10 @@
import org.exist.dom.QName;
import org.exist.xquery.util.ExpressionDumper;
import org.exist.xquery.value.Item;
+import org.exist.xquery.value.QNameValue;
import org.exist.xquery.value.Sequence;
import org.exist.xquery.value.SequenceType;
+import org.exist.xquery.value.StringValue;
import org.exist.xquery.value.Type;
/**
@@ -42,7 +44,7 @@
private final Expression tryTargetExpr;
- private final List<List> catchClauses = new ArrayList(5);
+ private final List<CatchClause> catchClauses = new ArrayList<CatchClause>();
// fixit! - declare static code, desc, value types
@@ -52,12 +54,10 @@
}
public void addCatchClause(List<String> catchErrorList, List<QName> catchVars, Expression catchExpr) {
- List clause = new ArrayList(3);
- clause.add(catchErrorList);
- clause.add(catchVars);
- clause.add(catchExpr);
- this.catchClauses.add(clause);
+ CatchClause catchClause = new CatchClause(catchErrorList, catchVars, catchExpr);
+
+ catchClauses.add(catchClause);
}
/* (non-Javadoc)
@@ -72,7 +72,7 @@
return tryTargetExpr;
}
- public List<List> getCatchClauses() {
+ public List<CatchClause> getCatchClauses() {
return catchClauses;
}
@@ -110,7 +110,12 @@
return tryTargetSeq;
} catch(XPathException xpe) {
+ System.out.println("Exception=" + xpe.getMessage());
+ System.out.println("Errorcode=" + xpe.getErrorCode().toString() + " qname=" + xpe.getErrorCode().getErrorQName());
+ // Get qname
+ QName errorCodeQname = xpe.getErrorCode().getErrorQName();
+
// Exception in thrown, catch expression will be evaluated.
// catchvars (CatchErrorCode (, CatchErrorDesc (, CatchErrorVal)?)? )
// need to be retrieved as variables
@@ -119,10 +124,16 @@
try {
// Iterate on all catch clauses
- for (List catchClause : catchClauses) {
+ for (CatchClause catchClause : catchClauses) {
- // Get catch variables and as declared variables
- List<QName> catchVars = (List<QName>) catchClause.get(1);
+//// DW: don't understand why this yields into a CCE
+// for(String txt : catchClause.getCatchErrorList()){
+// System.out.print( txt + "++++");
+// }
+// System.out.println();
+
+ // Get catch variables
+ List<QName> catchVars = (List<QName>) catchClause.getCatchVars();
LocalVariable mark1 = context.markLocalVariables(false);
int varPos = 0;
@@ -131,18 +142,19 @@
// "(" CatchErrorCode ("," CatchErrorDesc ("," CatchErrorVal)?)? ")"
for (QName catchVar : catchVars) {
-// System.out.println(">>>> localname="+catchVar.getLocalName()
-// + " stringvalue=" + catchVar.getStringValue()
-// + " prefix=" + catchVar.getPrefix()
-// + " " + catchVar.getNamespaceURI());
+ LocalVariable var = new LocalVariable(catchVar);
- LocalVariable var = new LocalVariable(catchVar);
+// System.out.println(catchVar.getStringValue() + "_=_" + catchVar.getLocalName());
// This should be in order of existance
// xs:QName, xs:string?, and item()* respectively.
switch (varPos) {
case 1:
var.setSequenceType(new SequenceType(Type.QNAME, Cardinality.EXACTLY_ONE));
+// QNameValue qnv = new QNameValue(context, catchVar);
+// qnv.add( new StringValue("aaa") );
+// var.setValue(qnv);
+ context.declareGlobalVariable(var);
break;
case 2:
var.setSequenceType(new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE));
@@ -156,13 +168,18 @@
}
// Evaluate catch expression
- catchResultSeq = ((Expression) catchClause.get(2)).eval(contextSequence, contextItem);
+ catchResultSeq = ((Expression) catchClause.getCatchExpr()).eval(contextSequence, contextItem);
} finally {
context.popLocalVariables(mark1);
}
}
+// } catch(Throwable ex){
+// ex.printStackTrace();
+// throw new XPathException(ex);
+
+
} finally {
context.popLocalVariables(mark0);
}
@@ -183,8 +200,8 @@
dumper.startIndent();
tryTargetExpr.dump(dumper);
dumper.endIndent();
- for (List catchClause: catchClauses) {
- Expression catchExpr = (Expression) catchClause.get(2);
+ for (CatchClause catchClause: catchClauses) {
+ Expression catchExpr = (Expression) catchClause.getCatchExpr();
dumper.nl().display("} catch (expr) {");
dumper.startIndent();
catchExpr.dump(dumper);
@@ -198,8 +215,8 @@
StringBuilder result = new StringBuilder();
result.append("try { ");
result.append(tryTargetExpr.toString());
- for (List catchClause: catchClauses) {
- Expression catchExpr = (Expression) catchClause.get(2);
+ for (CatchClause catchClause: catchClauses) {
+ Expression catchExpr = (Expression) catchClause.getCatchExpr();
result.append(" } catch (expr) { ");
result.append(catchExpr.toString());
result.append("}");
@@ -213,7 +230,7 @@
@Override
public int returnsType() {
// fixme! /ljo
- return ((Expression) catchClauses.get(0).get(2)).returnsType();
+ return ((Expression) catchClauses.get(0).getCatchExpr()).returnsType();
}
/* (non-Javadoc)
@@ -223,8 +240,8 @@
public void resetState(boolean postOptimization) {
super.resetState(postOptimization);
tryTargetExpr.resetState(postOptimization);
- for (List catchClause : catchClauses) {
- Expression catchExpr = (Expression) catchClause.get(2);
+ for (CatchClause catchClause : catchClauses) {
+ Expression catchExpr = (Expression) catchClause.getCatchExpr();
catchExpr.resetState(postOptimization);
}
}
@@ -236,7 +253,46 @@
}
+ /**
+ * Data container
+ */
public class CatchClause{
+ private List<String> catchErrorList = null;
+ private List<QName> catchVars = null;
+ private Expression catchExpr = null;
+
+ public CatchClause(List<String> catchErrorList, List<QName> catchVars, Expression catchExpr) {
+ this.catchErrorList=catchErrorList;
+ this.catchVars = catchVars;
+ this.catchExpr = catchExpr;
+ }
+
+ public List<String> getCatchErrorList() {
+ return catchErrorList;
+ }
+
+ public void setCatchErrorList(List<String> catchErrorList) {
+ this.catchErrorList = catchErrorList;
+ }
+
+ public Expression getCatchExpr() {
+ return catchExpr;
+ }
+
+ public void setCatchExpr(Expression catchExpr) {
+ this.catchExpr = catchExpr;
+ }
+
+ public List<QName> getCatchVars() {
+ return catchVars;
+ }
+
+ public void setCatchVars(List<QName> catchVars) {
+ this.catchVars = catchVars;
+ }
+
+
+
}
}
Modified: branches/adam/eXist-xq3/test/src/xquery/TestRunner.java
===================================================================
--- branches/adam/eXist-xq3/test/src/xquery/TestRunner.java 2011-01-23 18:44:11 UTC (rev 13618)
+++ branches/adam/eXist-xq3/test/src/xquery/TestRunner.java 2011-01-23 18:53:34 UTC (rev 13619)
@@ -70,7 +70,7 @@
// A test failed, report it
if (passed.equals("false")) {
- System.err.println(resource.getContent());
+ //System.err.println(resource.getContent());
fail("Test " + test.getAttribute("n") + " failed");
}
}
@@ -116,6 +116,7 @@
(DatabaseInstanceManager) testCollection.getService(
"DatabaseInstanceManager", "1.0");
dim.shutdown();
+
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
Modified: branches/adam/eXist-xq3/test/src/xquery/xq3_trycatch.xml
===================================================================
--- branches/adam/eXist-xq3/test/src/xquery/xq3_trycatch.xml 2011-01-23 18:44:11 UTC (rev 13618)
+++ branches/adam/eXist-xq3/test/src/xquery/xq3_trycatch.xml 2011-01-23 18:53:34 UTC (rev 13619)
@@ -2,7 +2,7 @@
<TestSet>
<testName>xquery3 try-catch</testName>
<description>
- <p>Test xquery3 try-catch functionality, derived from w3c: http://www.w3.org/TR/xquery-30-use-cases/#try-catch-use-cases</p>
+ <p>Test xquery3 try-catch functionality</p>
<author>Dannes Wessels</author>
</description>
<setup>
@@ -47,6 +47,9 @@
<remove-collection collection="/db/xquery3"/>
</tearDown>
+ <!-- derived from w3c: http://www.w3.org/TR/xquery-30-use-cases/#try-catch-use-cases -->
+
+<!--
<test output="text">
<task>Usecases Q1</task>
<code><![CDATA[
@@ -64,6 +67,7 @@
</code>
<expected>An error occured, please ask your consultant for help.</expected>
</test>
+ -->
<test output="text">
<task>Usecases Q2</task>
@@ -109,6 +113,8 @@
</expected>
</test>
+ <!--
+
<test output="text">
<task>Usecases Q3</task>
<code><![CDATA[
@@ -142,12 +148,14 @@
</result>
</expected>
</test>
+ -->
<!-- the following tests are derived from http://www.w3.org/TR/xquery-30/#id-try-catch -->
-
+<!--
<test output="text">
<task>A try/catch expression without a CatchErrorList catches
- any error</task>
+ any error
+ </task>
<code><![CDATA[
let $x := "a b c"
return
@@ -164,7 +172,8 @@
<test output="text">
<task>The CatchErrorList in this try/catch expression specifies
- that only err:FORG0001 is caught</task>
+ that only err:FORG0001 is caught
+ </task>
<code><![CDATA[
let $x := "a b c"
return
@@ -176,12 +185,13 @@
}
]]>
</code>
- <expected>0</expected><!-- should fail -->
+ <expected>0</expected>
</test>
<test output="text">
<task>The CatchErrorList in this try/catch expression specifies
- that errors err:FORG0001 and err:XPTY0004 are caught</task>
+ that errors err:FORG0001 and err:XPTY0004 are caught
+ </task>
<code><![CDATA[
let $x := "a b c"
return
@@ -199,7 +209,8 @@
<test output="text">
<task>This try/catch expression shows how to bind variables to
the error code, error description, and error value. Since the
- CatchErrorList is a wildcard, it catches any error:</task>
+ CatchErrorList is a wildcard, it catches any error:
+ </task>
<code><![CDATA[
try {
fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FOER0000'))
@@ -214,7 +225,8 @@
<test output="text">
<task>Errors raised by using the result of a try/catch expression
- are not caught, since they are outside the scope of the try expression.</task>
+ are not caught, since they are outside the scope of the try expression.
+ </task>
<code><![CDATA[
declare function local:thrice($x as xs:integer) as xs:integer
{
@@ -227,4 +239,6 @@
<expected>a</expected>
</test>
+ -->
+
</TestSet>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|