/** * Check that this type is validly derived from a given type * * @param type the type from which this type is derived * @param block the derivations that are blocked by the relevant element declaration * @throws net.sf.saxon.type.SchemaException if the derivation is not allowed */ public void checkTypeDerivationIsOK( /*@NotNull*/ SchemaType type, int block) throws SchemaException { if (type == this || type == AnySimpleType.getInstance()) { return; } throw new SchemaException("Type xs:error is not validly derived from " + type.getDescription()); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((contentType == null) ? 0 : contentType.hashCode()); result = prime * result + ((nameTest == null) ? 0 : nameTest.hashCode()); result = prime * result + (nilled ? 1231 : 1237); return result; }
/** * @param schemaTypeSystem * @param operation * @param elementName * @return * @throws MojoExecutionException */ private SchemaType getSchemaType( SchemaTypeSystem schemaTypeSystem, String operation, String elementName) throws MojoExecutionException { for (SchemaType elem : schemaTypeSystem.documentTypes()) { if (elem.getContentModel().getName().getLocalPart().equals(elementName)) { return elem; } } throw new MojoExecutionException( "Unable to find schema type declaration '" + elementName + "'" + " for WSDL operation '" + operation + "'"); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ElementType other = (ElementType) obj; if (contentType == null) { if (other.contentType != null) return false; } else if (!contentType.equals(other.contentType)) return false; if (nameTest == null) { if (other.nameTest != null) return false; } else if (!nameTest.equals(other.nameTest)) return false; if (nilled != other.nilled) return false; return true; }
/** * Check that any elements and attributes constructed or returned by this expression are * acceptable in the content model of a given complex type. It's always OK to say yes, since the * check will be repeated at run-time. The process of checking element and attribute constructors * against the content model of a complex type also registers the type of content expected of * those constructors, so the static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException { int fp = nameCode & NamePool.FP_MASK; if (fp == StandardNames.XSI_TYPE || fp == StandardNames.XSI_SCHEMA_LOCATION || fp == StandardNames.XSI_NIL || fp == StandardNames.XSI_NO_NAMESPACE_SCHEMA_LOCATION) { return; } if (parentType instanceof SimpleType) { StaticError err = new StaticError( "Attribute " + env.getNamePool().getDisplayName(nameCode) + " is not permitted in the content model of the simple type " + parentType.getDescription()); err.setIsTypeError(true); err.setLocator(this); if (getHostLanguage() == Configuration.XSLT) { err.setErrorCode("XTTE1510"); } else { err.setErrorCode("XQDY0027"); } throw err; } SchemaType type; try { type = ((ComplexType) parentType).getAttributeUseType(fp); } catch (SchemaException e) { throw new StaticError(e); } if (type == null) { StaticError err = new StaticError( "Attribute " + env.getNamePool().getDisplayName(nameCode) + " is not permitted in the content model of the complex type " + parentType.getDescription()); err.setIsTypeError(true); err.setLocator(this); if (getHostLanguage() == Configuration.XSLT) { err.setErrorCode("XTTE1510"); } else { err.setErrorCode("XQDY0027"); } throw err; } if (type instanceof AnyType) { return; } try { select.checkPermittedContents(type, env, true); // TODO: does this allow for the fact that the content will be atomized? } catch (XPathException e) { if (e.getLocator() == null || e.getLocator() == e) { e.setLocator(this); } throw e; } }
/** * Test whether this is the same type as another type. They are considered to be the same type if * they are derived from the same type definition in the original XML representation (which can * happen when there are multiple includes of the same file) */ public boolean isSameType(SchemaType other) { return other.getFingerprint() == getFingerprint(); }
/* Logical boolean "XOR" function, if values are different then result is true, otherwise false. */ public static SchemaBoolean logicalXor(SchemaType value1, SchemaType value2) { return new SchemaBoolean(value1.booleanValue() ^ value2.booleanValue()); }