moduleCtx.setBoundarySpaceProperty(node.getMode());
break;
}
case DEFAULT_COLLATION_DECLARATION: {
DefaultCollationDeclNode node = (DefaultCollationDeclNode) d;
moduleCtx.setDefaultCollation(node.getCollation());
break;
}
case BASE_URI_DECLARATION: {
BaseUriDeclNode node = (BaseUriDeclNode) d;
moduleCtx.setBaseUri(node.getUri());
break;
}
case CONSTRUCTION_DECLARATION: {
ConstructionDeclNode node = (ConstructionDeclNode) d;
moduleCtx.setConstructionModeProperty(node.getMode());
break;
}
case ORDERING_MODE_DECLARATION: {
OrderingModeDeclNode node = (OrderingModeDeclNode) d;
moduleCtx.setOrderingModeProperty(node.getMode());
break;
}
case EMPTY_ORDER_DECLARATION: {
EmptyOrderDeclNode node = (EmptyOrderDeclNode) d;
moduleCtx.setEmptyOrderProperty(node.getMode());
break;
}
case COPY_NAMESPACES_DECLARATION: {
CopyNamespacesDeclNode node = (CopyNamespacesDeclNode) d;
moduleCtx.setCopyNamespacesModeProperty(node.getMode());
break;
}
case NAMESPACE_DECLARATION: {
NamespaceDeclNode node = (NamespaceDeclNode) d;
moduleCtx.registerNamespaceUri(node.getPrefix(), unquote(node.getUri()));
break;
}
case SCHEMA_IMPORT: {
SchemaImportNode node = (SchemaImportNode) d;
if (node.isDefaultElementNamespace()) {
moduleCtx.setDefaultElementNamespaceUri(node.getTargetNS());
}
if (node.getPrefix() != null) {
moduleCtx.registerNamespaceUri(node.getPrefix(), unquote(node.getTargetNS()));
}
moduleCtx.registerSchemaImport(node.getTargetNS(), node.getLocations());
break;
}
case MODULE_IMPORT: {
ModuleImportNode node = (ModuleImportNode) d;
if (node.getPrefix() != null) {
moduleCtx.registerNamespaceUri(node.getPrefix(), unquote(node.getTargetNS()));
}
moduleCtx.registerModuleImport(node.getTargetNS(), node.getLocations());
break;
}
case VARIABLE_DECLARATION: {
VarDeclNode node = (VarDeclNode) d;
QName name = createQName(node.getName());
SequenceType type = SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_STAR);
if (node.getType() != null) {
type = createSequenceType(node.getType());
}
LogicalVariable lVar = newLogicalVariable();
XQueryVariable var = new XQueryVariable(name, type, lVar);
moduleCtx.registerVariable(var);
break;
}
case FUNCTION_DECLARATION: {
FunctionDeclNode node = (FunctionDeclNode) d;
boolean external = node.getBody() == null;
QName name = createQName(node.getName(), moduleCtx.getDefaultFunctionNamespaceUri());
String uri = name.getNamespaceURI();
if (XQueryConstants.FN_NSURI.equals(uri) || XQueryConstants.XS_NSURI.equals(uri)
|| XQueryConstants.XSI_NSURI.equals(uri) || XQueryConstants.XML_NSURI.equals(uri)) {
throw new SystemException(ErrorCode.XQST0045, node.getSourceLocation());
}
SequenceType rType = SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_STAR);
if (node.getReturnType() != null) {
rType = createSequenceType(node.getReturnType());
}
Pair<QName, SequenceType> paramTypes[] = new Pair[node.getParameters().size()];
for (int i = 0; i < paramTypes.length; ++i) {
ParamNode pNode = node.getParameters().get(i);
QName pName = createQName(pNode.getName());
SequenceType pType = SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_STAR);
if (pNode.getType() != null) {
pType = createSequenceType(pNode.getType());
}
paramTypes[i] = Pair.<QName, SequenceType> of(pName, pType);
}
Signature sign = new Signature(rType, paramTypes);
Function f = external ? new ExternalFunction(name, sign) : new UserDefinedXQueryFunction(name,
sign, null);
moduleCtx.registerFunction(f);
break;
}
case OPTION_DECLARATION: {
OptionDeclNode node = (OptionDeclNode) d;
QName name = createQName(node.getName());
moduleCtx.setOption(name, node.getValue());
break;
}
default:
throw new IllegalStateException("Unknown node: " + d.getTag());