/** * Check that all the types used in the signature of an imported function * are available in the module of the caller of the function * @param fd the declaration of the imported function * @throws XPathException if an error is found */ public void checkImportedFunctionSignature(XQueryFunction fd) throws XPathException { checkImportedType(fd.getResultType(), fd); for (int a=0; a<fd.getNumberOfArguments(); a++) { SequenceType argType = fd.getArgumentTypes()[a]; checkImportedType(argType, fd); } }
/** * Check that all the types used in the signature of an imported function * are available in the module of the caller of the function * @param fd the declaration of the imported function * @throws XPathException if an error is found */ public void checkImportedFunctionSignature(XQueryFunction fd) throws XPathException { checkImportedType(fd.getResultType(), fd); for (int a=0; a<fd.getNumberOfArguments(); a++) { SequenceType argType = fd.getArgumentTypes()[a]; checkImportedType(argType, fd); } }
/** * Bind unbound variables (these are typically variables that reference another module * participating in a same-namespace cycle, since local forwards references are not allowed */ public void bindUnboundVariables() throws XPathException { for (Iterator iter = undeclaredVariables.values().iterator(); iter.hasNext();) { UndeclaredVariable uv = (UndeclaredVariable)iter.next(); StructuredQName qName = uv.getVariableQName(); VariableDeclaration var = (VariableDeclaration)variables.get(qName); if (var == null) { String uri = qName.getNamespaceURI(); if (importsNamespace(uri)) { QueryModule main = getTopLevelModule(); var = (VariableDeclaration)main.libraryVariables.get(qName); } } if (var == null) { XPathException err = new XPathException("Unresolved reference to variable $" + uv.getVariableQName().getDisplayName()); err.setErrorCode("XPST0008"); err.setIsStaticError(true); throw err; } else { GlobalVariableDefinition gvar = ((GlobalVariableDefinition)var); checkImportedType(gvar.getRequiredType(), gvar); uv.transferReferences(var); } } }
/** * Bind unbound variables (these are typically variables that reference another module * participating in a same-namespace cycle, since local forwards references are not allowed */ public void bindUnboundVariables() throws XPathException { for (Iterator iter = undeclaredVariables.values().iterator(); iter.hasNext();) { UndeclaredVariable uv = (UndeclaredVariable)iter.next(); StructuredQName qName = uv.getVariableQName(); VariableDeclaration var = (VariableDeclaration)variables.get(qName); if (var == null) { String uri = qName.getNamespaceURI(); if (importsNamespace(uri)) { QueryModule main = getTopLevelModule(this); var = (VariableDeclaration)main.libraryVariables.get(qName); } } if (var == null) { XPathException err = new XPathException("Unresolved reference to variable $" + uv.getVariableQName().getDisplayName()); err.setErrorCode("XPST0008"); err.setIsStaticError(true); throw err; } else { GlobalVariableDefinition gvar = ((GlobalVariableDefinition)var); checkImportedType(gvar.getRequiredType(), gvar); uv.transferReferences(var); } } }
} else { GlobalVariableDefinition gvar = ((GlobalVariableDefinition)var); checkImportedType(gvar.getRequiredType(), gvar);
} else { GlobalVariableDefinition gvar = ((GlobalVariableDefinition)var); checkImportedType(gvar.getRequiredType(), gvar);
/** * Check that a SequenceType used in the definition of an imported variable or function * is available in the importing module * @param importedType the type that is to be checked * @param declaration the containing query or function definition * @throws net.sf.saxon.trans.XPathException if an error is fonnd. */ public void checkImportedType(SequenceType importedType, Declaration declaration) throws XPathException { ItemType type = importedType.getPrimaryType(); if (type instanceof AnyItemType) { return; } if (type.isAtomicType()) { int f = ((AtomicType)type).getFingerprint(); checkSchemaNamespaceImported(f, declaration); } else if (type instanceof ContentTypeTest) { SchemaType annotation = ((ContentTypeTest)type).getSchemaType(); int f = annotation.getFingerprint(); checkSchemaNamespaceImported(f, declaration); } else if (type instanceof CombinedNodeTest) { NodeTest[] tests = ((CombinedNodeTest)type).getComponentNodeTests(); for (int i=0; i<tests.length; i++) { SequenceType st = SequenceType.makeSequenceType(tests[i], StaticProperty.EXACTLY_ONE); checkImportedType(st, declaration); } } }
/** * Check that a SequenceType used in the definition of an imported variable or function * is available in the importing module * @param importedType the type that is to be checked * @param declaration the containing query or function definition * @throws net.sf.saxon.trans.XPathException if an error is fonnd. */ public void checkImportedType(SequenceType importedType, Declaration declaration) throws XPathException { ItemType type = importedType.getPrimaryType(); if (type instanceof AnyItemType) { return; } if (type.isAtomicType()) { int f = ((AtomicType)type).getFingerprint(); checkSchemaNamespaceImported(f, declaration); } else if (type instanceof ContentTypeTest) { SchemaType annotation = ((ContentTypeTest)type).getSchemaType(); int f = annotation.getFingerprint(); checkSchemaNamespaceImported(f, declaration); } else if (type instanceof CombinedNodeTest) { NodeTest[] tests = ((CombinedNodeTest)type).getComponentNodeTests(); for (int i=0; i<tests.length; i++) { SequenceType st = SequenceType.makeSequenceType(tests[i], StaticProperty.EXACTLY_ONE); checkImportedType(st, declaration); } } }