Skip to content

Add support for XQuery Update Facility 3.0 #4956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 39 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f6b3623
[refactor] Move existing non W3C specification compliant XQuery Updat…
adamretter Jun 10, 2023
3b5b54f
[feature] Add support for XQUF 3.0 updating and simple annotations
gabriele-tomassetti Jul 7, 2022
c02bb02
[refactor] Add detection of error XUST0032
gabriele-tomassetti Jul 7, 2022
5814ad6
[feature] Add annotation support for testing of an XQUF updating func…
gabriele-tomassetti Jul 7, 2022
669f90e
[refactor] Change SequenceType to support annotations
gabriele-tomassetti Jul 7, 2022
6fb663a
[test] Add test for annotation in testing of an updating function
gabriele-tomassetti Jul 7, 2022
98fa9f6
[feature] Add Revalidation Mode to XQueryContext
gabriele-tomassetti Jul 8, 2022
bab26ef
[feature] Add support for revalidation declaration
gabriele-tomassetti Jul 8, 2022
fd36ddc
[refactor] Add detection of error XUST0003
gabriele-tomassetti Jul 8, 2022
2d55fff
[feature] Add test for revalidation declaration
gabriele-tomassetti Jul 8, 2022
c61a4be
[feature] Add parsing support for Transform With expression
gabriele-tomassetti Jul 11, 2022
1f944c8
[feature] Add parsing support for Copy Modify expression
gabriele-tomassetti Jul 11, 2022
9b5b14c
[feature] Add CopyModifyExpression class to implement Transform With …
gabriele-tomassetti Jul 11, 2022
872ec1d
[feature] Add intermediate AST handling for Copy Modify and Transform…
gabriele-tomassetti Jul 11, 2022
9adcfb9
[test] Add tests for Copy Modify and Transform With expressions
gabriele-tomassetti Jul 11, 2022
47fc3e7
[refactor] Add Category enum to Expression in order to distinguish be…
gabriele-tomassetti Jul 11, 2022
dd9631b
[feature] Add parsing support for Dynamic updating function call
gabriele-tomassetti Jul 11, 2022
4848644
[feature] Add intermediate AST handling for dynamic updating function…
gabriele-tomassetti Jul 11, 2022
d53f922
[test] Add test for dynamic updating function call
gabriele-tomassetti Jul 11, 2022
5031dcc
[feature] Add parsing support for insert expression
gabriele-tomassetti Jul 12, 2022
d37154c
[feature] Add intermediate AST support for insert expression
gabriele-tomassetti Jul 12, 2022
e2895fa
[feature] Add InsertExpr class to support XQUF insert expression
gabriele-tomassetti Jul 12, 2022
b1d14de
[test] Add test for insert expression
gabriele-tomassetti Jul 12, 2022
ba1e1c7
[feature] Add base class ModifyingExpression to support insert, delet…
gabriele-tomassetti Jul 13, 2022
7e9057a
[refactor] Update class InsertExpr
gabriele-tomassetti Jul 13, 2022
ec9b38b
[feature] Add parsing support for delete expression
gabriele-tomassetti Jul 13, 2022
b7ee82c
[feature] Add intermediate AST support for delete expression
gabriele-tomassetti Jul 13, 2022
e7f3495
[feature] Add DeleteExpr class to support XQUF delete expression
gabriele-tomassetti Jul 13, 2022
e94b0d9
[test] Add test for delete expression
gabriele-tomassetti Jul 13, 2022
a2b8153
[feature] Add parsing support for replace expression
gabriele-tomassetti Jul 13, 2022
71d0e09
[feature] Add handling of intermediate AST for replace expression
gabriele-tomassetti Jul 13, 2022
3514f7f
[feature] Add ReplaceExpr class to implement replace expression
gabriele-tomassetti Jul 13, 2022
1d80f17
[test] Add tests for replace expression
gabriele-tomassetti Jul 13, 2022
7481ee1
[feature] Add parsing support for rename expression
gabriele-tomassetti Jul 13, 2022
391afe9
[feature] Add handling of intermediate AST for rename expression
gabriele-tomassetti Jul 13, 2022
d426c2c
[feature] Add class RenameExpr to support rename expression
gabriele-tomassetti Jul 13, 2022
ac7e942
[test] Add test for rename expression
gabriele-tomassetti Jul 13, 2022
a0ec78a
[test] Add new tests found in reference
gabriele-tomassetti Jul 20, 2022
4d774ba
[bugfix] Add missing reserved keyword 'copy'
adamretter Jun 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[refactor] Add detection of error XUST0032
  • Loading branch information
gabriele-tomassetti authored and adamretter committed Oct 14, 2023
commit c02bb0275389f044072e9f20c23e8ee4d933bf61
18 changes: 18 additions & 0 deletions exist-core/src/main/antlr/org/exist/xquery/parser/XQueryTree.g
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,24 @@ throws PermissionDeniedException, EXistException, XPathException
{ List annots = new ArrayList(); }
(annotations [annots]
)?
{
for(int i = 0; i < annots.size(); i++)
{
List la = (List) annots.get(i);
if(la.size() > 0)
{
for(int a = 0; a < la.size(); a++)
{
if(la.get(a).toString().equals("simple") || la.get(a).toString().equals("updating"))
{
throw new XPathException(qname, ErrorCodes.XUST0032,
"It is a static error if an %updating or %simple annotation is used on a VarDecl.");
}
}
}
}

}
(
#(
"as"
Expand Down
3 changes: 3 additions & 0 deletions exist-core/src/main/java/org/exist/xquery/ErrorCodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ public class ErrorCodes {

public static final ErrorCode XTSE0165 = new W3CErrorCode("XTSE0165","It is a static error if the processor is not able to retrieve the resource identified by the URI reference [ in the href attribute of xsl:include or xsl:import] , or if the resource that is retrieved does not contain a stylesheet module conforming to this specification.");

/* XQuery 3.0 Update Facility https://www.w3.org/TR/xquery-update-30/#id-new-error-codes */
public static final ErrorCode XUST0032 = new W3CErrorCode("XUST0032", "It is a static error if an %updating or %simple annotation is used on a VarDecl.");

/* eXist specific XQuery and XPath errors
*
* Codes have the format [EX][XQ|XP][DY|SE|ST][nnnn]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.exist.storage.BrokerPool;
import org.exist.storage.DBBroker;
import org.exist.test.ExistEmbeddedServer;
import org.exist.xquery.ErrorCodes;
import org.exist.xquery.PathExpr;
import org.exist.xquery.XPathException;
import org.exist.xquery.XQueryContext;
Expand Down Expand Up @@ -123,4 +124,31 @@ public void simpleAnnotation() throws EXistException, RecognitionException, XPat
}
}
}

@Test
public void simpleAnnotationIsInvalidForVariableDeclaration() throws EXistException, RecognitionException, XPathException, TokenStreamException, PermissionDeniedException
{
String query = "declare %simple variable $ab := 1;";

BrokerPool pool = BrokerPool.getInstance();
try(final DBBroker broker = pool.getBroker()) {
// parse the query into the internal syntax tree
XQueryContext context = new XQueryContext(broker.getBrokerPool());
XQueryLexer lexer = new XQueryLexer(context, new StringReader(query));
XQueryParser xparser = new XQueryParser(lexer);
xparser.prolog();
if (xparser.foundErrors()) {
fail(xparser.getErrorMessage());
return;
}

XQueryAST ast = (XQueryAST) xparser.getAST();
XQueryTreeParser treeParser = new XQueryTreeParser(context);
PathExpr expr = new PathExpr(context);
treeParser.prolog(ast, expr);
}
catch(XPathException ex) {
assertEquals(ErrorCodes.XUST0032, ex.getErrorCode());
}
}
}