|
From: <di...@us...> - 2011-02-01 11:49:23
|
Revision: 13711
http://exist.svn.sourceforge.net/exist/?rev=13711&view=rev
Author: dizzzz
Date: 2011-02-01 11:49:14 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
[bugfix] fixed remaining namespace , found and isolated AST/antlr issie
Modified Paths:
--------------
branches/adam/eXist-xq3/src/org/exist/xquery/functions/FunError.java
branches/adam/eXist-xq3/test/src/org/exist/xquery/functions/xquery3/TryCatchTest.java
Modified: branches/adam/eXist-xq3/src/org/exist/xquery/functions/FunError.java
===================================================================
--- branches/adam/eXist-xq3/src/org/exist/xquery/functions/FunError.java 2011-02-01 11:17:47 UTC (rev 13710)
+++ branches/adam/eXist-xq3/src/org/exist/xquery/functions/FunError.java 2011-02-01 11:49:14 UTC (rev 13711)
@@ -112,12 +112,13 @@
if (!args[0].isEmpty()) {
QName errorQName = ((QNameValue) args[0].itemAt(0)).getQName();
-// String prefix = errorQName.getPrefix();
-// if(prefix==null){
-// String ns = errorQName.getNamespaceURI();
-// prefix = getContext().getInScopePrefix(ns);
-// errorQName.setPrefix(prefix);
-// }
+// Set prefix if present
+ String prefix = errorQName.getPrefix();
+ if(prefix==null){
+ String ns = errorQName.getNamespaceURI();
+ prefix = getContext().getPrefixForURI(ns);
+ errorQName.setPrefix(prefix);
+ }
errorCode = new ErrorCode(errorQName, errorDesc);
}
Modified: branches/adam/eXist-xq3/test/src/org/exist/xquery/functions/xquery3/TryCatchTest.java
===================================================================
--- branches/adam/eXist-xq3/test/src/org/exist/xquery/functions/xquery3/TryCatchTest.java 2011-02-01 11:17:47 UTC (rev 13710)
+++ branches/adam/eXist-xq3/test/src/org/exist/xquery/functions/xquery3/TryCatchTest.java 2011-02-01 11:49:14 UTC (rev 13711)
@@ -373,12 +373,37 @@
}
- @Test @Ignore(" <AST>:0:0: unexpected end of subtree") // leave out the <A></A> for fun
- public void catchDefinedNamespace() {
+ @Test
+ public void catchDefinedNamespace1() {
String query = "xquery version '3.0';"
+ "declare namespace foo='http://foo.com'; "
+ "try { "
+ + " fn:error(fn:QName('http://foo.com', 'ERRORNAME'), 'ERRORTEXT') "
+ + "} "
+ + "catch foo:ERRORNAME { 'good' } "
+ + "catch * { 'bad' } ";
+ try {
+ ResourceSet results = executeQuery(query);
+
+ assertEquals(1, results.getSize());
+
+ String r1 = (String) results.getResource(0).getContent();
+ assertEquals("good", r1);
+
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ fail(ex.getMessage());
+ }
+
+ }
+
+ @Test @Ignore(" <AST>:0:0: unexpected end of subtree") // change good into 'good' and all is fine.
+ public void catchDefinedNamespace2() {
+
+ String query = "xquery version '3.0';"
+ + "declare namespace foo='http://foo.com'; "
+ + "try { "
+ " fn:error(fn:QName('http://foo.com', 'ERRORNAME'), 'ERRORTEXT')"
+ "} "
+ "catch foo:ERRORNAME { good } "
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|