public SchemaType getTypeAttribute(NodeInfo element, String attName) throws XPathException { String val = element.getAttributeValue("", attName); if (val == null) { return null; } // if (val.contains("(")) { // // typically, an extended type such as union(a,b) // IndependentContext env = makeStaticContext(element); // return (SimpleType)parser.parseExtendedItemType(val, env); // } if (val.startsWith("xs:")) { return config.getSchemaType(new StructuredQName("xs", NamespaceConstant.SCHEMA, val.substring(3))); } else { StructuredQName name = getQNameAttribute(element, attName); return config.getSchemaType(name); } }
private void checkNotNamespaceSensitive(Configuration config, final int typeCode) throws XPathException { SchemaType type = config.getSchemaType(typeCode & NamePool.FP_MASK); if (type instanceof SimpleType && ((SimpleType)type).isNamespaceSensitive()) { throw new CopyNamespaceSensitiveException( "Cannot copy QName or NOTATION values without copying namespaces"); // err.setErrorCode((language == Configuration.XSLT ? "XTTE0950" : "XQTY0086")); // throw err; } }
private void checkNotNamespaceSensitive(Configuration config, final int typeCode) throws XPathException { SchemaType type = config.getSchemaType(typeCode & NamePool.FP_MASK); if (type instanceof SimpleType && ((SimpleType)type).isNamespaceSensitive()) { throw new CopyNamespaceSensitiveException( "Cannot copy QName or NOTATION values without copying namespaces"); // err.setErrorCode((language == Configuration.XSLT ? "XTTE0950" : "XQTY0086")); // throw err; } }
private void checkNotNamespaceSensitive(Configuration config, final int typeCode) throws XPathException { SchemaType type = config.getSchemaType(typeCode & NamePool.FP_MASK); if (type instanceof SimpleType && ((SimpleType)type).isNamespaceSensitive()) { throw new CopyNamespaceSensitiveException( "Cannot copy QName or NOTATION values without copying namespaces"); // err.setErrorCode((language == Configuration.XSLT ? "XTTE0950" : "XQTY0086")); // throw err; } }
public SchemaType getTypeAttribute(NodeInfo element, String attName) throws XPathException { String val = element.getAttributeValue("", attName); if (val == null) { return null; } if (val.contains("(")) { // typically, an extended type such as union(a,b) IndependentContext env = makeStaticContext(element); return (SimpleType)parser.parseExtendedItemType(val, env); } if (val.startsWith("xs:")) { return config.getSchemaType(new StructuredQName("xs", NamespaceConstant.SCHEMA, val.substring(3))); } else { StructuredQName name = getQNameAttribute(element, attName); return config.getSchemaType(name); } }
/** * Get the schema type information for this node. * @return the type information. Returns null for an untyped node. */ public TypeInfo getSchemaTypeInfo() { int annotation = node.getTypeAnnotation(); if (annotation == -1) { return null; } final Configuration config = node.getConfiguration(); return new TypeInfoImpl(config, config.getSchemaType(annotation)); }
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 synchronized void init(Configuration config, boolean schemaAware) throws XPathException { resultName = new FingerprintedQName("", NamespaceConstant.FN, "analyze-string-result"); nonMatchName = new FingerprintedQName("", NamespaceConstant.FN, "non-match"); matchName = new FingerprintedQName("", NamespaceConstant.FN, "match"); groupName = new FingerprintedQName("", NamespaceConstant.FN, "group"); groupNrName = new NoNamespaceName("nr"); if (schemaAware) { resultType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "analyze-string-result-type")); nonMatchType = BuiltInAtomicType.STRING; matchType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "match-type")); groupType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "group-type")); groupNrType = BuiltInAtomicType.POSITIVE_INTEGER; if (resultType == null || matchType == null || groupType == null) { throw new XPathException("Schema for analyze-string has not been successfully loaded"); } } }
private synchronized void init(Configuration config, boolean schemaAware) throws XPathException { resultName = new FingerprintedQName("", NamespaceConstant.FN, "analyze-string-result"); nonMatchName = new FingerprintedQName("", NamespaceConstant.FN, "non-match"); matchName = new FingerprintedQName("", NamespaceConstant.FN, "match"); groupName = new FingerprintedQName("", NamespaceConstant.FN, "group"); groupNrName = new NoNamespaceName("nr"); if (schemaAware) { resultType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "analyze-string-result-type")); nonMatchType = BuiltInAtomicType.STRING; matchType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "match-type")); groupType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "group-type")); groupNrType = BuiltInAtomicType.POSITIVE_INTEGER; if (resultType == null || matchType == null || groupType == null) { throw new XPathException("Schema for analyze-string has not been successfully loaded"); } } }
/** * Get the schema type information for this node. Returns null for an untyped node. */ public TypeInfo getSchemaTypeInfo() { int annotation = node.getTypeAnnotation(); if (annotation == -1 || ((annotation & NodeInfo.IS_DTD_TYPE) != 0)) { return null; } return new TypeInfoImpl(node.getConfiguration(), node.getConfiguration().getSchemaType(annotation)); }
/** * Set the name of the required type of the top-level element of the document to be validated. * If no value is supplied, there is no constraint on the required type * @param name the name of the type of the document element, as a QName; * or null to remove a previously-specified value. This must be the name of a type in the * schema (typically but not necessarily a complex type). * @throws SaxonApiException if there is no known type with this name */ public void setDocumentElementTypeName(QName name) throws SaxonApiException { int fp = config.getNamePool().allocate( "", name.getNamespaceURI(), name.getLocalName()); documentElementType = config.getSchemaType(fp); if (documentElementType == null) { throw new SaxonApiException("Unknown type " + name.getClarkName()); } }
/** * 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()); } }
/** * Output element start tag */ public void startElement(int nameCode, int typeCode, int locationId, int properties) throws XPathException { if (afterStartTag || afterEndTag) { indent(); } nextReceiver.startElement(nameCode, typeCode, locationId, properties); level++; sameline = true; afterStartTag = true; afterEndTag = false; allWhite = true; line = 0; SchemaType type; if (suppressedElements != null && suppressedElements.contains(nameCode&NamePool.FP_MASK)) { suppressedAtLevel = level; } if (typeCode >= 1024 && suppressedAtLevel < 0 && ((type = getConfiguration().getSchemaType(typeCode)).isComplexType() && ((ComplexType)type).isMixedContent())) { // suppress indentation for elements with mixed content. (Note this also suppresses // indentation for all descendants of such elements. We could be smarter than this.) suppressedAtLevel = level; } }
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; }
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(); }
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute, as held in the name pool * @param typeCode The type of the attribute, as held in the name pool * @param properties Bit significant value. The following bits are defined: * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } ItemType type = new CombinedNodeTest( new NameTest(Type.ATTRIBUTE, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ATTRIBUTE, getConfiguration().getSchemaType(typeCode), getConfiguration())); checkItemType(type, locationId); } nextReceiver.attribute(nameCode, typeCode, value, locationId, properties); }
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute, as held in the name pool * @param typeCode The type of the attribute, as held in the name pool * @param properties Bit significant value. The following bits are defined: * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } ItemType type = new CombinedNodeTest( new NameTest(Type.ATTRIBUTE, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ATTRIBUTE, getConfiguration().getSchemaType(typeCode), getConfiguration())); checkItemType(type, locationId); } nextReceiver.attribute(nameCode, typeCode, value, locationId, properties); }