{"record":{"id":"6bc6b014bc25c28e","repo":"dianping/cat","slug":"xqst0048","errorCode":"XQST0048","errorMessage":"\"{prefix}:{name}\": Qname not library namespace","messagePattern":"\"(.+?):(.+?)\": Qname not library namespace","errorType":"error_code","errorClass":"StaticError","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/editor/worker-xquery.js","lineNumber":1899,"sourceCode":"                }\n                if(namespace) {\n                    qname.uri = namespace.uri;\n                }\n                qname.name = value.substring(idx + 1);\n            }\n            return qname;\n        },\n        \n        variables: {},\n        varRefs: {},\n        functionCalls: {},\n    \n        addVariable: function(qname, type, pos){\n            if(\n                type === 'VarDecl' && this.moduleNamespace !== '' &&\n                !(this.moduleNamespace === qname.uri || (qname.uri === '' && this.defaultFunctionNamespace === this.moduleNamespace))\n            ) {\n                throw new StaticError('XQST0048', '\"' + qname.prefix + ':' + qname.name + '\": Qname not library namespace', pos);\n            }\n            var key = getVarKey(qname);\n            if(type === 'VarDecl' && this.variables[key]) {\n                throw new StaticError('XQST0049', '\"' + qname.name + '\": duplicate variable declaration', pos);\n            }\n            this.variables[key] = {\n                type: type,\n                pos: pos,\n                qname: qname,\n                annotations: {}\n            };\n            return this;\n        },\n        \n        getVariables: function(){\n            var variables = {};\n            var that = this;\n            var handler = function(key){","sourceCodeStart":1881,"sourceCodeEnd":1917,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/editor/worker-xquery.js#L1881-L1917","documentation":"XQST0048 is raised when a variable is declared inside a library module but its QName is not in the module's own namespace. addVariable() checks VarDecl entries in a module context (moduleNamespace !== '') and requires qname.uri to equal moduleNamespace, or qname.uri === '' while the default function namespace equals the module namespace. Library module components must live in the module namespace.","triggerScenarios":"In a library module (module namespace m = \"U\"), writing 'declare variable $other:foo ...' where other maps to a different URI, or declaring an unprefixed variable while the default function namespace is not the module namespace.","commonSituations":"Converting a main module to a library module and forgetting to prefix declared variables; copy-pasting variable declarations from another module; declaring $m:foo but with a stale prefix bound to the wrong URI.","solutions":["Prefix the variable with the module's own prefix: 'declare variable $m:foo ...'.","Ensure the prefix used expands to exactly the module namespace URI.","Or move shared variable declarations to the module that owns the namespace."],"exampleFix":"// before (library module, namespace m = \"http://example.org/m\")\ndeclare variable $foo as xs:integer := 1;\n\n// after\ndeclare variable $m:foo as xs:integer := 1;","handlingStrategy":"validation","validationCode":"// Library module lint: every declared variable must use the module prefix\nif (isLibraryModule) {\n  var decls = source.match(/declare\\s+variable\\s+\\$([\\w-]+):/g) || [];\n  decls.forEach(function(d) {\n    var p = d.match(/\\$(.+):/)[1];\n    if (p !== modulePrefix) { warn('Variable prefix must be ' + modulePrefix); }\n  });\n}","typeGuard":"function isInModuleNamespace(moduleNs, qname, defaultFnNs) {\n  return moduleNs === qname.uri ||\n         (qname.uri === '' && defaultFnNs === moduleNs);\n}","tryCatchPattern":"if (e.code === 'XQST0048') {\n  highlight(e.pos, 'Library module variables must use the module namespace prefix');\n}","preventionTips":["When converting a main module to a library module, prefix every declared variable and function.","Keep the module prefix consistent from 'module namespace' down to each declaration."],"tags":["xquery","library-module","variable-declaration","namespace"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}