in src/language/semantics/xsltTokenDiagnostics.ts [1620:1683]
public static resolveXPathVariableReference(
globalVarName: string | null,
document: vscode.TextDocument,
importedVariables: string[],
token: BaseToken,
xpathVariableCurrentlyBeingDefined: boolean,
inScopeXPathVariablesList: VariableData[],
xpathStack: XPathData[],
inScopeVariablesList: VariableData[],
elementStack: ElementData[],
xmlNamespaces: string[]
): BaseToken | null {
let fullVarName = XsltTokenDiagnostics.getTextForToken(
token.line,
token,
document
)
let varName = fullVarName.startsWith('$')
? fullVarName.substring(1)
: fullVarName.substring(1, fullVarName.length - 1)
let result: BaseToken | null = null
let globalVariable = null
let resolved = this.resolveVariableName(
inScopeXPathVariablesList,
varName,
xpathVariableCurrentlyBeingDefined,
globalVariable
)
if (!resolved) {
resolved = this.resolveStackVariableName(xpathStack, varName)
}
if (!resolved) {
resolved = this.resolveVariableName(
inScopeVariablesList,
varName,
false,
globalVariable
)
}
if (!resolved) {
if (elementStack.length === 1 && globalVarName === varName) {
// don't asign
} else {
resolved = this.resolveStackVariableName(elementStack, varName)
}
}
let importedResolved = false
if (!resolved) {
importedResolved =
globalVarName !== varName && importedVariables.indexOf(varName) > -1
}
// Parse the namespaces from the DFDL document that contains the XPath segments. If the variable is
// defined in an external namespace that we are importing, don't flag it. This is a temporary solution
// that we can remove once we have the ability to create a DFDL model outside of a Parse operation.
if (!resolved && !importedResolved && varName.includes(':')) {
let splits = varName.split(':')
resolved = xmlNamespaces.includes(splits[0]) ? token : undefined
}
if (!resolved && !importedResolved) {
result = token
}
return result
}