dianping/cat · warning · StaticWarning
W06
W06
Error message
Avoid default element namespace declarations.
What it means
Style warning W06 raised by the XQuery static-analysis pass in the ACE XQuery worker (worker-xquery.js:1460-1475). The translator hooks URILiteral: when it sees 'declare default element namespace "..."' (fn flag not set, so the URI belongs to an element-namespace declaration) it throws a StaticWarning advising against default element namespaces. Warnings are collected and reported as editor annotations; they do not abort parsing.
Source
Thrown at cat-home/src/main/webapp/assets/js/editor/worker-xquery.js:1468
});
}
};
};
exports.DefaultNamespaceDecl = function(translator, rootSctx, node) {
var fn = false;
var ns = '';
return {
TOKEN: function(token){
fn = fn ? true : (token.value === 'function');
},
URILiteral: function(uri){
ns = TreeOps.flatten(uri);
ns = ns.substring(1, ns.length - 1);
if(!fn) {
translator.apply(function(){
throw new StaticWarning('W06', 'Avoid default element namespace declarations.', node.pos);
});
rootSctx.defaultElementNamespace = ns;
} else {
rootSctx.defaultFunctionNamespace = ns;
}
}
};
};
exports.NamespaceDecl = function(translator, rootSctx, node) {
var prefix = '';
return {
NCName: function(ncname) {
prefix = TreeOps.flatten(ncname);
},
URILiteral: function(uri) {
uri = TreeOps.flatten(uri);
uri = uri.substring(1, uri.length - 1);View on GitHub (pinned to e815e74d4c)
Solutions
- Replace the default element namespace with a prefixed declaration: 'declare namespace ns = "http://example.com/ns";' and prefix element tests/literals (ns:element).
- If the default namespace is intentional and team style accepts it, configure the editor to hide W06-level warnings.
- Update all unprefixed element names/tests in the module to use the new prefix after switching.
Example fix
(: before :) declare default element namespace "http://example.com/ns"; /doc//item (: after :) declare namespace ns = "http://example.com/ns"; /ns:doc//ns:item
Defensive patterns
Strategy: validation
Validate before calling
// Flag default element namespace declarations before linting:
function usesDefaultElementNamespace(xquery) {
return /declare\s+default\s+element\s+namespace/.test(xquery);
} Type guard
function isStaticWarning(ex) {
return ex instanceof StaticWarning || /^W\d+$/.test(ex.code || '');
} Try / catch
translator.apply(function () {
try { fn(); }
catch (ex) {
if (isStaticWarning(ex)) warnings.push({ code: ex.code, pos: ex.pos, message: ex.message });
else throw ex;
}
}); Prevention
- Declare namespaces with prefixes and use prefixed names throughout the module.
- Treat W06 as style-only: it never blocks parsing or execution.
- Filter by code 'W06' in the editor annotation pipeline if the team accepts default namespaces.
When it happens
Trigger: An XQuery module containing 'declare default element namespace "http://example.com/ns";'. The URILiteral handler sees fn===false, so translator.apply throws StaticWarning('W06', ...) at line 1466-1468 while still recording rootSctx.defaultElementNamespace = ns.
Common situations: XQuery written for a single-namespace document model where authors default the namespace to avoid prefixes; eXist-db/BaseX modules; code style rules that require explicit prefixes so every element's namespace is visible at the element site.
Related errors
- Expected (none | [ <flex-grow> <flex-shrink>? || <flex-basis
- syntax error, unexpected + terminals[tokenId] + expectedStr
- W01
- W02
- Unknown property '{}'.
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/006f06b622052039.
Report an issue: GitHub.