private void computeSingleValued(TypeHierarchy th) { singleValued = untyped; if (!singleValued) { ItemType nodeType = operand.getItemType(th); if (nodeType instanceof NodeTest) { SchemaType st = ((NodeTest)nodeType).getContentType(); if (st == AnyType.getInstance() || st.isAtomicType()) { singleValued = true; } } } }
private void computeSingleValued(TypeHierarchy th) { singleValued = untyped; if (!singleValued) { ItemType nodeType = operand.getItemType(th); if (nodeType instanceof NodeTest) { SchemaType st = ((NodeTest)nodeType).getContentType(); if (st == AnyType.getInstance() || st.isAtomicType()) { singleValued = true; } } } }
public Value convertSimpleTypeToSaxon(QName type, String value) { int fp = _config.getNamePool().allocate("", type.getNamespaceURI(), type.getLocalPart()); SchemaType type2 = _config.getSchemaType(fp); if (type2 == null || !type2.isAtomicType()) { __log.warn("Can't find simple type " + type + " value " + value + " result: " + null); return null; } else { try { AtomicValue value2 = StringValue.convertStringToAtomicType(value, (AtomicType) type2, null).asAtomic(); if (__log.isDebugEnabled()) { __log.debug("converting " + type + " value " + value + " result: " + value2); } return value2; } catch (ValidationException e) { __log.debug("Can't convert " + value + " to " + type + " returning empty sequence"); return EmptySequence.getInstance(); } } }
private void computeSingleValued(TypeHierarchy th) { singleValued = untyped; if (!singleValued) { ItemType nodeType = operand.getItemType(th); if (nodeType instanceof NodeTest) { SchemaType st = ((NodeTest)nodeType).getContentType(); if (st == AnyType.getInstance() || st.isAtomicType()) { singleValued = true; } } } }
/** * Test whether a system function with a given name and arity is available. This supports * the function-available() function in XSLT. This method may be called either at compile time * or at run time. * @param functionName * @param arity The number of arguments. This is set to -1 in the case of the single-argument * function-available() function; in this case the method should return true if there is some */ public boolean isAvailable(StructuredQName functionName, int arity) { if (arity != 1 && arity != -1) { return false; } String uri = functionName.getNamespaceURI(); String local = functionName.getLocalName(); if (uri.equals(NamespaceConstant.SCHEMA)) { AtomicType type = (AtomicType)Type.getBuiltInItemType(uri, local); return type != null && type.getFingerprint() != StandardNames.XS_NOTATION; } int fingerprint = config.getNamePool().getFingerprint(uri, local); if (fingerprint == -1) { return false; } else { SchemaType st = config.getSchemaType(fingerprint); return (st != null && st.isAtomicType()); } }
/** * Test whether a system function with a given name and arity is available. This supports * the function-available() function in XSLT. This method may be called either at compile time * or at run time. * @param functionName * @param arity The number of arguments. This is set to -1 in the case of the single-argument * function-available() function; in this case the method should return true if there is some */ public boolean isAvailable(StructuredQName functionName, int arity) { if (arity != 1 && arity != -1) { return false; } String uri = functionName.getNamespaceURI(); String local = functionName.getLocalName(); if (uri.equals(NamespaceConstant.SCHEMA)) { AtomicType type = (AtomicType)Type.getBuiltInItemType(uri, local); return type != null && type.getFingerprint() != StandardNames.XS_NOTATION; } int fingerprint = config.getNamePool().getFingerprint(uri, local); if (fingerprint == -1) { return false; } else { SchemaType st = config.getSchemaType(fingerprint); return (st != null && st.isAtomicType()); } }
/** * Check whether the content of an element is namespace-sensitive * * * @param type the type annotation of the node * @param nodeNr the the node number of the elemente * @throws XPathException if an error occurs */ protected void checkNotNamespaceSensitiveElement(SchemaType type, int nodeNr) throws XPathException { if (type instanceof SimpleType && ((SimpleType) type).isNamespaceSensitive()) { if (type.isAtomicType()) { throw new CopyNamespaceSensitiveException( "Cannot copy QName or NOTATION values without copying namespaces"); } else { // For a union or list type, we need to check whether the actual value is namespace-sensitive AtomicSequence value = tree.getTypedValueOfElement(nodeNr); for (AtomicValue val : value) { if (val.getPrimitiveType().isNamespaceSensitive()) { throw new CopyNamespaceSensitiveException( "Cannot copy QName or NOTATION values without copying namespaces"); } } } } }
/** * Test whether a type annotation code represents the type xs:ID or one of its subtypes * @param typeCode the type annotation to be tested * @return true if the type annotation represents an xs:ID */ public boolean isIdCode(int typeCode) { typeCode &= NamePool.FP_MASK; if (typeCode == StandardNames.XS_ID) { return true; } else if (typeCode < 1024) { // No other built-in type is an ID return false; } else { SchemaType type = config.getSchemaType(typeCode); if (type == null) { return false; // this shouldn't happen, but there's no need to crash right here } if (type.isAtomicType()) { return isSubType((AtomicType)type, BuiltInAtomicType.ID); } if (type instanceof ComplexType && ((ComplexType)type).isSimpleContent()) { SimpleType contentType = ((ComplexType)type).getSimpleContentType(); if (contentType.isAtomicType()) { return isSubType((AtomicType)contentType, BuiltInAtomicType.ID); } } return false; } }
/** * Check whether the content of an element is namespace-sensitive * * * @param type the type annotation of the node * @param nodeNr the the node number of the elemente * @throws XPathException if an error occurs */ protected void checkNotNamespaceSensitiveElement(SchemaType type, int nodeNr) throws XPathException { if (type instanceof SimpleType && ((SimpleType) type).isNamespaceSensitive()) { if (type.isAtomicType()) { throw new CopyNamespaceSensitiveException( "Cannot copy QName or NOTATION values without copying namespaces"); } else { // For a union or list type, we need to check whether the actual value is namespace-sensitive AtomicSequence value = tree.getTypedValueOfElement(nodeNr); for (AtomicValue val : value) { if (val.getPrimitiveType().isNamespaceSensitive()) { throw new CopyNamespaceSensitiveException( "Cannot copy QName or NOTATION values without copying namespaces"); } } } } }
SchemaType type = schemaType; try { if (type.isAtomicType()) { return (AtomicType) type; } else if (type instanceof ListType) {
public boolean isAvailable(SymbolicName.F functionName) { if (functionName.getArity() != 1) { return false; } final String uri = functionName.getComponentName().getURI(); final String localName = functionName.getComponentName().getLocalPart(); final SchemaType type = config.getSchemaType(new StructuredQName("", uri, localName)); if (type == null || type.isComplexType()) { return false; } if (type.isAtomicType() && ((AtomicType) type).isAbstract()) { return false; } return type != AnySimpleType.getInstance(); }
public boolean isAvailable(SymbolicName.F functionName) { if (functionName.getArity() != 1) { return false; } final String uri = functionName.getComponentName().getURI(); final String localName = functionName.getComponentName().getLocalPart(); final SchemaType type = config.getSchemaType(new StructuredQName("", uri, localName)); if (type == null || type.isComplexType()) { return false; } if (type.isAtomicType() && ((AtomicType) type).isAbstract()) { return false; } return type != AnySimpleType.getInstance(); }
/** * Get the item type of the atomic values that will be produced when an item * of this type is atomized (assuming that atomization succeeds) */ public AtomicType getAtomizedItemType() { SchemaType type = config.getSchemaType(requiredType); if (type.isAtomicType()) { return (AtomicType)type; } else if (type instanceof ListType) { SimpleType mem = ((ListType)type).getItemType(); if (mem.isAtomicType()) { return (AtomicType)mem; } } else if (type instanceof ComplexType && ((ComplexType)type).isSimpleContent()) { SimpleType ctype = ((ComplexType)type).getSimpleContentType(); if (ctype.isAtomicType()) { return (AtomicType)ctype; } else if (ctype instanceof ListType) { SimpleType mem = ((ListType)ctype).getItemType(); if (mem.isAtomicType()) { return (AtomicType)mem; } } } return BuiltInAtomicType.ANY_ATOMIC; }
/** * Get the item type of the atomic values that will be produced when an item * of this type is atomized (assuming that atomization succeeds) */ public AtomicType getAtomizedItemType() { SchemaType type = config.getSchemaType(requiredType); if (type.isAtomicType()) { return (AtomicType)type; } else if (type instanceof ListType) { SimpleType mem = ((ListType)type).getItemType(); if (mem.isAtomicType()) { return (AtomicType)mem; } } else if (type instanceof ComplexType && ((ComplexType)type).isSimpleContent()) { SimpleType ctype = ((ComplexType)type).getSimpleContentType(); if (ctype.isAtomicType()) { return (AtomicType)ctype; } else if (ctype instanceof ListType) { SimpleType mem = ((ListType)ctype).getItemType(); if (mem.isAtomicType()) { return (AtomicType)mem; } } } return BuiltInAtomicType.ANY_ATOMIC; }
/** * Determine the static cardinality of the expression */ public int computeCardinality() { ItemType in = getOperandItemType(); Expression operand = getBaseExpression(); if (singleValued) { return operand.getCardinality(); } else if (untyped && in instanceof NodeTest) { return operand.getCardinality(); } else if (Cardinality.allowsMany(operand.getCardinality())) { return StaticProperty.ALLOWS_ZERO_OR_MORE; } else if (in.isPlainType()) { return operand.getCardinality(); } else if (in instanceof NodeTest) { SchemaType schemaType = ((NodeTest) in).getContentType(); if (schemaType.isAtomicType()) { // can return at most one atomic value per node return operand.getCardinality(); } } return StaticProperty.ALLOWS_ZERO_OR_MORE; }
private void computeSingleValued(TypeHierarchy th) { ItemType operandType = getOperandItemType(); if (th.relationship(operandType, ArrayItemType.ANY_ARRAY_TYPE) != TypeHierarchy.DISJOINT) { singleValued = false; } else { singleValued = untyped; if (!singleValued) { ItemType nodeType = getBaseExpression().getItemType(); if (nodeType instanceof NodeTest) { SchemaType st = ((NodeTest) nodeType).getContentType(); if (st == Untyped.getInstance() || st.isAtomicType() || (st.isComplexType() && st != AnyType.getInstance())) { singleValued = true; } if (!nodeType.getUType().overlaps(UType.ELEMENT.union(UType.ATTRIBUTE))) { singleValued = true; } } } } }
/** * Determine the static cardinality of the expression */ public int computeCardinality() { ItemType in = getOperandItemType(); Expression operand = getBaseExpression(); if (singleValued) { return operand.getCardinality(); } else if (untyped && in instanceof NodeTest) { return operand.getCardinality(); } else if (Cardinality.allowsMany(operand.getCardinality())) { return StaticProperty.ALLOWS_ZERO_OR_MORE; } else if (in.isPlainType()) { return operand.getCardinality(); } else if (in instanceof NodeTest) { SchemaType schemaType = ((NodeTest) in).getContentType(); if (schemaType.isAtomicType()) { // can return at most one atomic value per node return operand.getCardinality(); } } return StaticProperty.ALLOWS_ZERO_OR_MORE; }
private void computeSingleValued(TypeHierarchy th) { ItemType operandType = getOperandItemType(); if (th.relationship(operandType, ArrayItemType.ANY_ARRAY_TYPE) != TypeHierarchy.DISJOINT) { singleValued = false; } else { singleValued = untyped; if (!singleValued) { ItemType nodeType = getBaseExpression().getItemType(); if (nodeType instanceof NodeTest) { SchemaType st = ((NodeTest) nodeType).getContentType(); if (st == Untyped.getInstance() || st.isAtomicType() || (st.isComplexType() && st != AnyType.getInstance())) { singleValued = true; } if (!nodeType.getUType().overlaps(UType.ELEMENT.union(UType.ATTRIBUTE))) { singleValued = true; } } } } }
Configuration config = processor.getUnderlyingConfiguration(); SchemaType type = config.getSchemaType(new StructuredQName("", name.getNamespaceURI(), local)); if (type == null || !type.isAtomicType()) { throw new SaxonApiException("Unknown atomic type " + name.getClarkName());
/** * Register a user-defined XQuery function. * <p/> * This method is intended for internal use only. * @param function the function being declared */ public void declareFunction(XQueryFunction function) throws XPathException { Configuration config = getConfiguration(); if (function.getNumberOfArguments() == 1) { StructuredQName name = function.getFunctionName(); int fingerprint = config.getNamePool().getFingerprint(name.getNamespaceURI(), name.getLocalName()); if (fingerprint != -1) { SchemaType t = config.getSchemaType(fingerprint); if (t != null && t.isAtomicType()) { XPathException err = new XPathException("Function name " + function.getDisplayName() + " clashes with the name of the constructor function for an atomic type"); err.setErrorCode("XQST0034"); err.setIsStaticError(true); throw err; } } } XQueryFunctionLibrary local = getLocalFunctionLibrary(); local.declareFunction(function); QueryModule main = getTopLevelModule(); main.globalFunctionLibrary.declareFunction(function); }