/** * check whether complex type derived is valid derived from base, * given a subset of {restriction, extension}. */ public boolean checkComplexDerivationOk(XSComplexTypeDecl derived, XSTypeDefinition base, short block) { // if derived is anyType, then it's valid only if base is anyType too if (derived == fAnyType) return derived == base; return checkComplexDerivation((XSComplexTypeDecl)derived, base, block); }
public void checkElementDeclsConsistent(XSComplexTypeDecl type, XSParticleDecl particle, SymbolHash elemDeclHash, SubstitutionGroupHandler sgHandler) throws XMLSchemaException { // check for elements in the tree with the same name and namespace int pType = particle.fType; if (pType == XSParticleDecl.PARTICLE_WILDCARD) return; if (pType == XSParticleDecl.PARTICLE_ELEMENT) { XSElementDecl elem = (XSElementDecl)(particle.fValue); findElemInTable(type, elem, elemDeclHash); if (elem.fScope == XSConstants.SCOPE_GLOBAL) { // Check for subsitution groups. XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem, fSchemaVersion); for (int i = 0; i < subGroup.length; i++) { findElemInTable(type, subGroup[i], elemDeclHash); } } return; } XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue; for (int i = 0; i < group.fParticleCount; i++) checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler); }
/** * check whether simple type derived is valid derived from base, * given a subset of {restriction, extension}. */ public boolean checkSimpleDerivationOk(XSSimpleType derived, XSTypeDefinition base, short block) { // if derived is anySimpleType, then it's valid only if the base // is ur-type if (derived == SchemaGrammar.fAnySimpleType) { return (base == fAnyType || base == SchemaGrammar.fAnySimpleType); } // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation((XSSimpleType)derived, (XSSimpleType)base, block); }
return false; return checkSimpleDerivation((XSSimpleType)derived, (XSSimpleType)base, block); return checkComplexDerivation((XSComplexTypeDecl)derived, base, block);
if(baseMG == null) { if(derivedMG != null) { // can't be a restriction! reportSchemaError(errorReporter, rgLocators[i/2-1], "src-redefine.6.2.2", new Object[]{derivedGrp.fName, "rcase-Recurse.2"}); reportSchemaError(errorReporter, rgLocators[i/2-1], "src-redefine.6.2.2", new Object[]{derivedGrp.fName, "rcase-Recurse.2"}); groupSubsumption(fakeDerived, fakeBase, grammarBucket, SGHandler, cmBuilder, errorReporter, derivedGrp.fName, rgLocators[i/2-1]); elemTable.clear(); try { checkElementDeclsConsistent(types[j], types[j].fParticle, elemTable, SGHandler, grammarBucket, wcList, stack); reportSchemaError(errorReporter, ctLocators[j], e.getKey(), e.getArgs()); reportSchemaError(errorReporter,ctLocators[j], "derivation-ok-restriction.5.3.2", new Object[]{types[j].fName, types[j].fBaseType.getName()}); typeSubsumption(types[j], bType, grammarBucket,
fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport); fValidationState.setDatatypeXMLVersion(schemaDoc.fDatatypeXMLVersion); if (fSchemaHandler.fXSConstraints.ElementDefaultValidImmediate(element.fType, element.fDefault.normalizedValue, fValidationState, element.fDefault) == null) { reportSchemaError ("e-props-correct.2", new Object[]{nameAtt, element.fDefault.normalizedValue}, elmDecl); element.fDefault = null; if (!fSchemaHandler.fXSConstraints.checkTypeDerivationOk(element.fType, element.fSubGroup[i].fType, element.fSubGroup[i].fFinal)) { reportSchemaError ("e-props-correct.4", new Object[]{nameAtt, ((QName)subGroupAtt.get(i)).prefix +":"+((QName)subGroupAtt.get(i)).localpart}, elmDecl);
block |= ((XSComplexTypeDecl) fCurrentType).fBlock; if (!fXSConstraints.checkTypeDerivationOk(type, fCurrentType, block)) { errorList.add("cvc-elt.4.3"); errorList.add(new Object[] { element.rawname, xsiType, XS11TypeHelper.getSchemaTypeName(fCurrentType)});
if (! xsConstraints.checkSimpleDerivationOk(attrDecl.fType, baseAttrDecl.fType, baseAttrDecl.fType.getFinal()) ) { attrUse.fDefault: attrDecl.fDefault); if (!EqualityHelper.isEqual(baseFixedValue, thisFixedValue, xsConstraints.getSchemaVersion())) { errorArgs = new Object[]{typeName, attrDecl.fName, thisFixedValue.stringValue(), baseFixedValue.stringValue(), "derivation-ok-restriction.2.1.3.b"}; return errorArgs; if (! xsConstraints.isSubsetOf(fAttributeWC, baseGroup.fAttributeWC)) { errorArgs = new Object[]{typeName, "derivation-ok-restriction.4.2"}; return errorArgs;
checkSimpleDerivation(directBase, base, block)) { return true; if (checkEmptyFacets(base)) { XSObjectList subUnionMemberDV = base.getMemberTypes(); int subUnionSize = subUnionMemberDV.getLength(); for (int i=0; i<subUnionSize; i++) { base = (XSSimpleType)subUnionMemberDV.item(i); if (checkSimpleDerivation(derived, base, block)) { return true;
if (!xsc.checkTypeDerivationOk(ed.fType, eb.fType, (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) { return false; if (XS11TypeHelper.isTypeTablesComparable(eb.getTypeAlternatives(), ed.getTypeAlternatives()) && !xsc.isTypeTablesEquivalent(eb, ed)) { return false;
findElemInTable(type, elem, elemDeclHash); findElemInTable(type, subGroup[i], elemDeclHash);
.ElementDefaultValidImmediate( fCurrentType, fCurrentElemDecl.fDefault.stringValue(),
!fSchemaHandler.fXSConstraints.checkSimpleDerivationOk(dv, baseValidator, baseValidator.getFinal())) { fAttrChecker.returnAttrArray(simpleContentAttrValues, schemaDoc);
boolean disjoint2sets(String[] one, String[] theOther) { for (int i=0; i<one.length; i++) { if (elementInSet(one[i], theOther)) return false; } return true; }
public void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem, SymbolHash elemDeclHash) throws XMLSchemaException { final XSElementDecl existingElem = findExistingElement(elem, elemDeclHash); // First time or is same element if (existingElem == null || existingElem == elem) { return; } if (elem.fType != existingElem.fType) { // Types are not the same throw new XMLSchemaException("cos-element-consistent", new Object[] {type.fName, elem.fName}); } }
return checkComplexDerivation((XSComplexTypeDecl)directBase, base, block); return false; return checkSimpleDerivation((XSSimpleType)directBase, (XSSimpleType)base, block);
block |= ((XSComplexTypeDecl) fCurrentType).fBlock; if (!fXSConstraints.checkTypeDerivationOk(type, fCurrentType, block)) { reportSchemaError( "cvc-elt.4.3",
boolean subset2sets(String[] subSet, String[] superSet){ for (int i=0; i<subSet.length; i++) { if (!elementInSet(subSet[i], superSet)) return false; } return true; }
block |= ((XSComplexTypeDecl) elemType).fBlock; if (!fXSConstraints.checkTypeDerivationOk(fCurrentType, elemType, block)) { reportSchemaError( "cos-element-consistent.4.a",
/** * Wildcard constraints - helper methods */ boolean areSame(XSWildcardDecl wildcard, XSWildcardDecl otherWildcard) { if (wildcard.fType == otherWildcard.fType) { // ##any, true if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_ANY) { return true; } // ##other, only check the negated value // * when we support not(list), we need to check in the same way // as for NSCONSTRAINT_LIST. // not(list) is supported - no need for that check if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) { return wildcard.fNamespaceList[0] == otherWildcard.fNamespaceList[0]; } // ## list, must have the same length, // and each item in one list must appear in the other one // (we are assuming that there are no duplicate items in a list) if (wildcard.fNamespaceList.length == otherWildcard.fNamespaceList.length) { for (int i=0; i<wildcard.fNamespaceList.length; i++) { if (!elementInSet(wildcard.fNamespaceList[i], otherWildcard.fNamespaceList)) { return false; } } return true; } } return false; } // areSame