dianping/cat · error · StaticError
XQST0033
XQST0033
Error message
"{prefix}": namespace prefix already bound to "{uri}" What it means
XQST0033 is the standard XQuery error for a namespace prefix already bound to a different URI. addNamespace() resolves the requested prefix via getPrefixByPrefix lookup; if a prior binding exists and is not marked override, the new binding is rejected because re-binding a prefix to a different namespace within overlapping scope is illegal (predeclared prefixes like xml/xmlns can never be rebound).
Source
Thrown at cat-home/src/main/webapp/assets/js/editor/worker-xquery.js:1812
return this.root.availableModuleNamespaces;
},
getPrefixByNamespace: function(uri){
return this.root.namespaces[uri].prefix;
},
addNamespace: function (uri, prefix, pos, type) {
if(prefix === '' && type === 'module') {
throw new StaticWarning('W01', 'Avoid this type of import. Use import module namespace instead', pos);
}
if (uri === '') {
throw new StaticError('XQST0088', 'empty target namespace in module import or module declaration', pos);
}
var namespace = this.getNamespace(uri);
if (namespace && namespace.type === type && type !== 'declare' && !namespace.override) {
throw new StaticError('XQST0047', '"' + uri + '": duplicate target namespace', pos);
}
namespace = this.getNamespaceByPrefix(prefix);
if (namespace && !namespace.override) {
throw new StaticError('XQST0033', '"' + prefix + '": namespace prefix already bound to "' + namespace.uri + '"', pos);
}
namespace = this.namespaces[uri];
this.namespaces[uri] = {
prefix: prefix,
pos: pos,
type: type
};
if (namespace) {
throw new StaticWarning('W02', '"' + uri + '" already bound to the "' + namespace.prefix + '" prefix', pos);
}
},
getNamespaces: function(){
return this.root.namespaces;
},View on GitHub (pinned to e815e74d4c)
Solutions
- Pick a different prefix for the new namespace binding.
- Or remove/merge the earlier declaration that already claimed the prefix.
- Avoid reusing well-known prefixes (fn, local, xml, xs) for your own namespaces.
Example fix
// before declare namespace foo = "http://a.com"; import module namespace foo = "http://b.com"; // after declare namespace foo = "http://a.com"; import module namespace bmod = "http://b.com";
Defensive patterns
Strategy: validation
Validate before calling
// Check prefix uniqueness across declarations/imports before analysis
var byPrefix = {};
bindings.forEach(function(b) {
if (byPrefix[b.prefix] && byPrefix[b.prefix] !== b.uri) {
warn('Prefix ' + b.prefix + ' rebound from ' + byPrefix[b.prefix] + ' to ' + b.uri);
}
byPrefix[b.prefix] = b.uri;
}); Try / catch
if (e.code === 'XQST0033') {
highlight(e.pos, 'Pick a different prefix or remove the earlier binding');
} Prevention
- Use one prefix per namespace across the whole project (project-level prefix convention).
- Never rebind reserved prefixes (xml, xmlns, fn, xs, local).
- When merging files, dedupe the combined prolog before saving.
When it happens
Trigger: 'declare namespace foo = "U1";' followed later by 'import module namespace foo = "U2";', or two declare namespace statements using the same prefix with different URIs in the same scope chain.
Common situations: Concatenating query prologs from multiple sources; a module's internal prefix colliding with the main query's prefix; renaming refactors that leave stale declarations.
Related errors
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/c73070bd2cd1ce14.
Report an issue: GitHub.