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
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 (element.getDefaultTypeDefinition() != null) { element.getDefaultTypeDefinition().setNamespaceContext(new NamespaceSupport(schemaDoc.fNamespaceSupport));