{"record":{"id":"0defc4d0d075142a","repo":"dianping/cat","slug":"w01","errorCode":"W01","errorMessage":"Avoid this type of import. Use import module namespace instead","messagePattern":"Avoid this type of import\\. Use import module namespace instead","errorType":"validation","errorClass":"StaticWarning","httpStatus":null,"severity":"warning","filePath":"cat-home/src/main/webapp/assets/js/editor/worker-xquery.js","lineNumber":1801,"sourceCode":"                    }\n                    if(mod.functions) {\n                        TreeOps.concat(this.functions, mod.functions);\n                    }\n                } catch(e) {\n                    throw new StaticError('XQST0059', 'module \"' + uri + '\" not found', pos);\n                }\n            }\n            return this;\n        },\n        getAvailableModuleNamespaces: function(){\n            return this.root.availableModuleNamespaces;\n        },\n        getPrefixByNamespace: function(uri){\n            return this.root.namespaces[uri].prefix;\n        },\n        addNamespace: function (uri, prefix, pos, type) {\n            if(prefix === '' && type === 'module') {\n                throw new StaticWarning('W01', 'Avoid this type of import. Use import module namespace instead', pos);\n            }\n            if (uri === '') {\n                throw new StaticError('XQST0088', 'empty target namespace in module import or module declaration', pos);\n            }\n            var namespace = this.getNamespace(uri);\n            if (namespace && namespace.type === type && type !== 'declare' && !namespace.override) {\n                throw new StaticError('XQST0047', '\"' + uri + '\": duplicate target namespace', pos);\n            }\n            namespace = this.getNamespaceByPrefix(prefix);\n            if (namespace && !namespace.override) {\n                throw new StaticError('XQST0033', '\"' + prefix + '\": namespace prefix already bound to \"' + namespace.uri + '\"', pos);\n            }\n\n            namespace = this.namespaces[uri];\n            this.namespaces[uri] = {\n                prefix: prefix,\n                pos: pos,\n                type: type","sourceCodeStart":1783,"sourceCodeEnd":1819,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/editor/worker-xquery.js#L1783-L1819","documentation":"W01 is a lint-level StaticWarning, not a spec error. The worker's addNamespace() emits it when a module import arrives with an empty prefix (type === 'module' && prefix === ''), i.e. an 'import module' written without a namespace prefix binding. The recommendation is to always use 'import module namespace prefix = \"uri\"' so imported functions/variables have an explicit, addressable prefix.","triggerScenarios":"Any module import parsed with prefix '' — e.g. a construct like 'import module default-element-namespace style' or a parser state that yields no prefix for the module import. addNamespace(uri, '', pos, 'module') triggers it immediately.","commonSituations":"Hand-written queries that rely on a default namespace instead of explicit prefixes; code migrated from XQuery processors that tolerate unprefixed module imports; generated code that omits the namespace clause.","solutions":["Rewrite the import as 'import module namespace p = \"URI\";' with an explicit prefix.","Use the prefix when calling the module's functions (p:func(...)) so names resolve unambiguously.","Treat it as advisory: warnings do not abort compilation, but fix them to keep static analysis (prefix expansion, XPST0081 checks) accurate."],"exampleFix":"// before\nimport module \"http://example.org/mod\";\n\n// after\nimport module namespace m = \"http://example.org/mod\";","handlingStrategy":"validation","validationCode":"// Reject unprefixed module imports before sending source to the worker\nif (/import\\s+module\\s+[\"']/.test(queryText)) {\n  warn('Use: import module namespace prefix = \"URI\";');\n}","typeGuard":null,"tryCatchPattern":"if (e.name === 'StaticWarning' && e.code === 'W01') {\n  reportLint(e.pos, e.message); // non-fatal\n}","preventionTips":["Adopt a project style rule: every module import binds an explicit prefix.","Surface W01 warnings in the editor gutter rather than the error list so they stay non-blocking."],"tags":["xquery","lint","module-import","namespace"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}