{"record":{"id":"006f06b622052039","repo":"dianping/cat","slug":"w06","errorCode":"W06","errorMessage":"Avoid default element namespace declarations.","messagePattern":"Avoid default element namespace declarations\\.","errorType":"validation","errorClass":"StaticWarning","httpStatus":null,"severity":"warning","filePath":"cat-home/src/main/webapp/assets/js/editor/worker-xquery.js","lineNumber":1468,"sourceCode":"            });\n        }\n    };\n};\n\nexports.DefaultNamespaceDecl = function(translator, rootSctx, node) {\n    var fn = false;\n    var ns = '';\n\n    return {\n        TOKEN: function(token){\n            fn = fn ? true : (token.value === 'function');\n        },\n        URILiteral: function(uri){\n            ns = TreeOps.flatten(uri);\n            ns = ns.substring(1, ns.length - 1);\n            if(!fn) {\n                translator.apply(function(){\n                    throw new StaticWarning('W06', 'Avoid default element namespace declarations.', node.pos);\n                });\n                rootSctx.defaultElementNamespace = ns;\n            } else {\n                rootSctx.defaultFunctionNamespace = ns;\n            }\n        }\n    };\n};\n\nexports.NamespaceDecl = function(translator, rootSctx, node) {\n    var prefix = '';\n    return {\n        NCName: function(ncname) {\n            prefix = TreeOps.flatten(ncname);\n        },\n        URILiteral: function(uri) {\n            uri = TreeOps.flatten(uri);\n            uri = uri.substring(1, uri.length - 1);","sourceCodeStart":1450,"sourceCodeEnd":1486,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/editor/worker-xquery.js#L1450-L1486","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"(: before :)\ndeclare default element namespace \"http://example.com/ns\";\n/doc//item\n\n(: after :)\ndeclare namespace ns = \"http://example.com/ns\";\n/ns:doc//ns:item","handlingStrategy":"validation","validationCode":"// Flag default element namespace declarations before linting:\nfunction usesDefaultElementNamespace(xquery) {\n  return /declare\\s+default\\s+element\\s+namespace/.test(xquery);\n}","typeGuard":"function isStaticWarning(ex) {\n  return ex instanceof StaticWarning || /^W\\d+$/.test(ex.code || '');\n}","tryCatchPattern":"translator.apply(function () {\n  try { fn(); }\n  catch (ex) {\n    if (isStaticWarning(ex)) warnings.push({ code: ex.code, pos: ex.pos, message: ex.message });\n    else throw ex;\n  }\n});","preventionTips":["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."],"tags":["xquery","ace-editor","lint","namespaces","style-warning"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}