Skip to content

Commit ca26a59

Browse files
committed
[bugfix] Small cleanup to REST Server External Variable handling
1 parent 5f23038 commit ca26a59

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
@@ -1523,21 +1523,25 @@ private void declareExternalAndXQJVariables(final XQueryContext context,
15231523
child = (NodeImpl) child.getNextSibling();
15241524
}
15251525

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

1530-
if (localname == null) {
1531-
continue;
1530+
if (uri == null && prefix != null) {
1531+
uri = context.getURIForPrefix(prefix);
15321532
}
15331533

15341534
final QName q;
1535-
if (prefix != null && localname != null) {
1535+
if (prefix != null) {
15361536
q = new QName(localname, uri, prefix);
15371537
} else {
15381538
q = new QName(localname, uri, XMLConstants.DEFAULT_NS_PREFIX);
15391539
}
15401540

1541+
if (uri != null && prefix != null) {
1542+
context.declareNamespace(prefix, uri);
1543+
}
1544+
15411545
// get serialized sequence
15421546
final NodeImpl value = variable.getFirstChild(new NameTest(Type.ELEMENT, Marshaller.SEQUENCE_ELEMENT_QNAME));
15431547
final Sequence sequence;

0 commit comments

Comments
 (0)