Skip to content

Commit e04b80b

Browse files
committed
[bugfix] When processing an XUpdate document whose default namespace prefix is bound to the XUpdate namespace, do not bind the default namespace prefix in XQuery
1 parent 9692675 commit e04b80b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

exist-core/src/main/java/org/exist/xupdate/XUpdateProcessor.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ public class XUpdateProcessor implements ContentHandler, LexicalHandler {
134134
public static final String VARIABLE = "variable";
135135
public static final String IF = "if";
136136

137-
public final static String XUPDATE_NS = "http://www.xmldb.org/xupdate";
137+
public static final String XUPDATE_NS = "http://www.xmldb.org/xupdate";
138+
public static final String XUPDATE_PREFIX = "xupdate";
138139

139140
private static final String XML_SPACE_DEFAULT = "default";
140141
private static final String XML_SPACE_PRESERVE = "preserve";
@@ -759,9 +760,15 @@ private Sequence processQuery(final String select) throws SAXException {
759760
context = new XQueryContext(broker.getBrokerPool());
760761
context.setStaticallyKnownDocuments(documentSet);
761762

763+
context.declareNamespace(XUPDATE_PREFIX, XUPDATE_NS);
762764
if (namespaces != null) {
763765
for (final Map.Entry<String, String> namespace : namespaces.entrySet()) {
764-
context.declareNamespace(namespace.getKey(), namespace.getValue());
766+
final String prefix = namespace.getKey();
767+
final String uri = namespace.getValue();
768+
// NOTE(AR) guard against declaring XUpdate as the default namespace prefix
769+
if (!(XMLConstants.DEFAULT_NS_PREFIX.equals(prefix) && XUPDATE_NS.equals(uri))) {
770+
context.declareNamespace(prefix, uri);
771+
}
765772
}
766773
}
767774

0 commit comments

Comments
 (0)