286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 2001-2005 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * To store and validate information about substitutionGroup 286N/A * @author Sandy Gao, IBM 286N/A // 3.9.4 Element Sequence Locally Valid (Particle) 2.3.3 286N/A // check whether one element decl matches an element with the given qname 286N/A // if the exemplar is not a global element decl, then it's not possible 286N/A // to be substituted by another element. 286N/A // if the decl blocks substitution, return false 286N/A // get grammar of the element 286N/A // get the decl for the element 286N/A // and check by using substitutionGroup information 286N/A // 3.3.6 Substitution Group OK (Transitive) 286N/A // check whether element can substitute exemplar 286N/A // For an element declaration (call it D) to be validly substitutable for another element declaration (call it C) subject to a blocking constraint (a subset of {substitution, extension, restriction}, the value of a {disallowed substitutions}) one of the following must be true: 286N/A // 1. D and C are the same element declaration. 286N/A // 2 All of the following must be true: 286N/A // 2.1 The blocking constraint does not contain substitution. 286N/A // 2.2 There is a chain of {substitution group affiliation}s from D to C, that is, either D's {substitution group affiliation} is C, or D's {substitution group affiliation}'s {substitution group affiliation} is C, or . . . 286N/A // 2.3 The set of all {derivation method}s involved in the derivation of D's {type definition} from C's {type definition} does not intersect with the union of the blocking constraint, C's {prohibited substitutions} (if C is complex, otherwise the empty set) and the {prohibited substitutions} (respectively the empty set) of any intermediate {type definition}s in the derivation of D's {type definition} from C's {type definition}. 286N/A // prepare the combination of {derivation method} and 286N/A // {disallowed substitution} 286N/A // "derived" should be derived from "base" 286N/A // add derivation methods of derived types to devMethod; 286N/A // add block of base types to blockConstraint. 286N/A // type == null means the current type is anySimpleType, 286N/A // whose base type should be anyType 286N/A // If the base is a union, check if "derived" is allowed through any of the member types. 286N/A // check whether element is in exemplar's substitution group 286N/A // [Definition:] Every element declaration (call this HEAD) in the {element declarations} of a schema defines a substitution group, a subset of those {element declarations}, as follows: 286N/A // Define PSG, the potential substitution group for HEAD, as follows: 286N/A // 1 The element declaration itself is in PSG; 286N/A // 2 PSG is closed with respect to {substitution group affiliation}, that is, if any element declaration in the {element declarations} has a {substitution group affiliation} in PSG, then it is also in PSG itself. 286N/A // HEAD's actual substitution group is then the set consisting of each member of PSG such that all of the following must be true: 286N/A // 1 Its {abstract} is false. 286N/A // 2 It is validly substitutable for HEAD subject to an empty blocking constraint, as defined in Substitution Group OK (Transitive) (3.3.6). 286N/A // to store substitution group information 286N/A // the key to the hashtable is an element decl, and the value is 286N/A // - a Vector, which contains all elements that has this element as their 286N/A // substitution group affilication 286N/A // - an array of OneSubGroup, which contains its substitution group before block. 286N/A // The real substitution groups (after "block") 286N/A * clear the internal registry of substitutionGroup information 286N/A * add a list of substitution group information. 286N/A // for all elements with substitution group affiliation 286N/A // check whether this an entry for this element 286N/A // if not, create a new one 286N/A * get all elements that can substitute the given element, 286N/A * according to the spec, we shouldn't consider the {block} constraints. 286N/A * from the spec, substitution group of a given element decl also contains 286N/A * the element itself. but the array returned from this method doesn't 286N/A * containt this element. 286N/A // If we already have sub group for this element, just return it. 286N/A // Otherwise, get all potential sub group elements 286N/A // (without considering "block" on this element 286N/A // For each of such elements, check whether the derivation methods 286N/A // overlap with "block". If not, add it to the sub group 286N/A // Resize the array if necessary 286N/A // Get potential sub group element (without considering "block") 286N/A // substitution group for this one is empty 286N/A // we've already calculated the element, just return. 286N/A // we only have the *direct* substitutions 286N/A // then for each of the direct substitutions, get its substitution 286N/A // group, and combine the groups together. 286N/A // Check whether this element is blocked. If so, ignore it. 286N/A // Remember derivation methods and blocks from the types 286N/A // Add this one to potential group 286N/A // Get potential group for this element 286N/A // For each of them, check whether it's blocked (by type) 286N/A // Ignore it if it's blocked 286N/A // Store the potential sub group 286N/A // type == null means the current type is anySimpleType, 286N/A // whose base type should be anyType 286N/A // No derivation relation, or blocked, return false 286N/A // Remember the derivation methods and blocks, return true. 286N/A // Record the information about how one element substitute another one 286N/A // The element that substitutes another one 286N/A // The combination of all derivation methods from sub's type to 286N/A // The combination of {block} of the types in the derivation chain 286N/A // excluding sub's type 286N/A}
// class SubstitutionGroupHandler