Skip to content

Commit dcccf8f

Browse files
committed
[bugfix] Small cleanup to REST Server External Variable handling
1 parent 38959cb commit dcccf8f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

exist-core/src/main/java/org/exist/http/RESTServer.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,21 +1500,25 @@ private void declareExternalAndXQJVariables(final XQueryContext context,
15001500
child = (NodeImpl) child.getNextSibling();
15011501
}
15021502

1503-
if (uri != null && prefix != null) {
1504-
context.declareNamespace(prefix, uri);
1503+
if (localname == null) {
1504+
throw new XPathException(ErrorCodes.W3CErrorCode.XPDY0002, String.format("External variable is missing local name in its qualified name. Prefix=%s URI=%s", prefix, uri));
15051505
}
15061506

1507-
if (localname == null) {
1508-
continue;
1507+
if (uri == null && prefix != null) {
1508+
uri = context.getURIForPrefix(prefix);
15091509
}
15101510

15111511
final QName q;
1512-
if (prefix != null && localname != null) {
1512+
if (prefix != null) {
15131513
q = new QName(localname, uri, prefix);
15141514
} else {
15151515
q = new QName(localname, uri, XMLConstants.DEFAULT_NS_PREFIX);
15161516
}
15171517

1518+
if (uri != null && prefix != null) {
1519+
context.declareNamespace(prefix, uri);
1520+
}
1521+
15181522
// get serialized sequence
15191523
final NodeImpl value = variable.getFirstChild(new NameTest(Type.ELEMENT, Marshaller.SEQUENCE_ELEMENT_QNAME));
15201524
final Sequence sequence;

0 commit comments

Comments
 (0)