private BinaryOperation exprFor (PathStep.Axis axis, CombinedNodeTest nodeTest) { NodeTest[] tests = nodeTest.getComponentNodeTests(); BinaryOperation.Operator op = operatorFor(nodeTest.getOperator()); return new BinaryOperation (exprFor(axis, tests[0]), op, exprFor(axis, tests[1])); }
/** * Simplify type so that hierarchy comparison could be accurate. */ private ItemType simplify(ItemType it) { TypeHierarchy th = processor.getUnderlyingConfiguration().getTypeHierarchy(); if (it instanceof CombinedNodeTest) { CombinedNodeTest n = (CombinedNodeTest) it; __log.debug(n.getComponentNodeTests()); return simplify(n.getComponentNodeTests()[1]); } else if (it instanceof NodeTest) { NodeTest n = (NodeTest) it; __log.debug(n); SchemaType t = n.getContentType(); if (t.isSimpleType() || t.equals(AnyType.getInstance())) { AtomicType at = it.getAtomizedItemType(); while (!at.isBuiltInType()) at = at.getSuperType(th).getAtomizedItemType(); return at; } else if (t.isComplexType()) { return n; } else { return AnyItemType.getInstance(); } } else { if (it == null) return null; else return it.getAtomizedItemType(); } }
/** * 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); } } }
((CombinedNodeTest) pattern.getItemType()).getOperator() == Token.UNION) { CombinedNodeTest cnt = (CombinedNodeTest) pattern.getItemType(); NodeTest[] nt = cnt.getComponentNodeTests(); final NodeTestPattern nt0 = new NodeTestPattern(nt[0]); ExpressionTool.copyLocationInfo(pattern, nt0);
((CombinedNodeTest) pattern.getItemType()).getOperator() == Token.UNION) { CombinedNodeTest cnt = (CombinedNodeTest) pattern.getItemType(); NodeTest[] nt = cnt.getComponentNodeTests(); final NodeTestPattern nt0 = new NodeTestPattern(nt[0]); ExpressionTool.copyLocationInfo(pattern, nt0);