final 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}); } if (XS11TypeHelper.isTypeTablesComparable(elem.getTypeAlternatives(), existingElem.getTypeAlternatives()) && !isTypeTablesEquivalent(elem, existingElem)) { // Type tables are not equivalent throw new XMLSchemaException("cos-element-consistent.4.b", new Object[] {type.fName, elem.fName}); } }
final public boolean isTypeTablesEquivalent(XSElementDecl elementDecl1, XSElementDecl elementDecl2) { boolean typeTablesEquivalent = true; final XSTypeAlternativeImpl[] typeTable1 = elementDecl1.getTypeAlternatives(); final XSTypeAlternativeImpl[] typeTable2 = elementDecl2.getTypeAlternatives(); // if two type tables have different length if (typeTable1.length != typeTable2.length) { typeTablesEquivalent = false; } if (typeTablesEquivalent) { for (int typeAltIdx = 0; typeAltIdx < typeTable1.length; typeAltIdx++) { final XSTypeAlternativeImpl typeAlt1 = typeTable1[typeAltIdx]; final XSTypeAlternativeImpl typeAlt2 = typeTable2[typeAltIdx]; if (!isTypeAlternativesEquivalent(typeAlt1, typeAlt2)) { typeTablesEquivalent = false; break; } } } if (typeTablesEquivalent && !elementDecl1.isTypeTableOK()) { typeTablesEquivalent = isTypeAlternativesEquivalent(elementDecl1.getDefaultTypeDefinition(), elementDecl2.getDefaultTypeDefinition()); } return typeTablesEquivalent; } // isTypeTablesEquivalent
final XSElementDecl gElem = grammar.getGlobalElementDecl(elem.fName); if (gElem != null) { if (gElem != elem && XS11TypeHelper.isTypeTablesComparable(elem.getTypeAlternatives(), gElem.getTypeAlternatives()) && !isTypeTablesEquivalent(elem, gElem)) {
public XSTypeAlternative getTypeAlternative(XSElementDecl currentElemDecl, QName element, XMLAttributes attributes, Vector inheritableAttrList, NamespaceContext instanceNamespaceContext, String expandedSystemId) { XSTypeAlternative selectedTypeAlternative = null; XSTypeAlternativeImpl[] typeAlternatives = currentElemDecl.getTypeAlternatives(); if (typeAlternatives != null) { // Construct a list of attributes needed for CTA processing. This includes inherited attributes as well. XMLAttributes ctaAttributes = getAttributesForCTA(attributes, inheritableAttrList); for (int typeAltIdx = 0; typeAltIdx < typeAlternatives.length; typeAltIdx++) { Test ctaTest = typeAlternatives[typeAltIdx].getTest(); if (ctaTest != null && ctaTest.evaluateTest(element, ctaAttributes, instanceNamespaceContext, expandedSystemId)) { selectedTypeAlternative = typeAlternatives[typeAltIdx]; break; } } //if a type alternative is not selected by xs:alternative components, try to assign the default type if (selectedTypeAlternative == null) { selectedTypeAlternative = currentElemDecl.getDefaultTypeDefinition(); } } return selectedTypeAlternative; } // getTypeAlternative
if (XS11TypeHelper.isTypeTablesComparable(eb.getTypeAlternatives(), ed.getTypeAlternatives()) && !xsc.isTypeTablesEquivalent(eb, ed)) { return false;