Java Code Examples for com.sun.org.apache.xerces.internal.xs.XSConstants#DERIVATION_SUBSTITUTION

The following examples show how to use com.sun.org.apache.xerces.internal.xs.XSConstants#DERIVATION_SUBSTITUTION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubstitutionGroupHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint) {
    // 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:
    // 1. D and C are the same element declaration.
    if (element == exemplar)
        return true;

    // 2 All of the following must be true:
    // 2.1 The blocking constraint does not contain substitution.
    if ((blockingConstraint & XSConstants.DERIVATION_SUBSTITUTION) != 0)
        return false;

    // 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 . . .
    XSElementDecl subGroup = element.fSubGroup;
    while (subGroup != null && subGroup != exemplar) {
        subGroup = subGroup.fSubGroup;
    }

    if (subGroup == null)
        return false;

    // 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}.
    // prepare the combination of {derivation method} and
    // {disallowed substitution}
    return typeDerivationOK(element.fType, exemplar.fType, blockingConstraint);
}
 
Example 2
Source File: SubstitutionGroupHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint) {
    // 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:
    // 1. D and C are the same element declaration.
    if (element == exemplar)
        return true;

    // 2 All of the following must be true:
    // 2.1 The blocking constraint does not contain substitution.
    if ((blockingConstraint & XSConstants.DERIVATION_SUBSTITUTION) != 0)
        return false;

    // 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 . . .
    XSElementDecl subGroup = element.fSubGroup;
    while (subGroup != null && subGroup != exemplar) {
        subGroup = subGroup.fSubGroup;
    }

    if (subGroup == null)
        return false;

    // 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}.
    // prepare the combination of {derivation method} and
    // {disallowed substitution}
    return typeDerivationOK(element.fType, exemplar.fType, blockingConstraint);
}
 
Example 3
Source File: SubstitutionGroupHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint) {
    // 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:
    // 1. D and C are the same element declaration.
    if (element == exemplar)
        return true;

    // 2 All of the following must be true:
    // 2.1 The blocking constraint does not contain substitution.
    if ((blockingConstraint & XSConstants.DERIVATION_SUBSTITUTION) != 0)
        return false;

    // 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 . . .
    XSElementDecl subGroup = element.fSubGroup;
    while (subGroup != null && subGroup != exemplar) {
        subGroup = subGroup.fSubGroup;
    }

    if (subGroup == null)
        return false;

    // 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}.
    // prepare the combination of {derivation method} and
    // {disallowed substitution}
    return typeDerivationOK(element.fType, exemplar.fType, blockingConstraint);
}
 
Example 4
Source File: SubstitutionGroupHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint) {
    // 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:
    // 1. D and C are the same element declaration.
    if (element == exemplar)
        return true;

    // 2 All of the following must be true:
    // 2.1 The blocking constraint does not contain substitution.
    if ((blockingConstraint & XSConstants.DERIVATION_SUBSTITUTION) != 0)
        return false;

    // 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 . . .
    XSElementDecl subGroup = element.fSubGroup;
    while (subGroup != null && subGroup != exemplar) {
        subGroup = subGroup.fSubGroup;
    }

    if (subGroup == null)
        return false;

    // 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}.
    // prepare the combination of {derivation method} and
    // {disallowed substitution}
    return typeDerivationOK(element.fType, exemplar.fType, blockingConstraint);
}
 
Example 5
Source File: SubstitutionGroupHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * get all elements that can substitute the given element,
 * according to the spec, we shouldn't consider the {block} constraints.
 *
 * from the spec, substitution group of a given element decl also contains
 * the element itself. but the array returned from this method doesn't
 * containt this element.
 */
public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
    // If we already have sub group for this element, just return it.
    Object subGroup = fSubGroups.get(element);
    if (subGroup != null)
        return (XSElementDecl[])subGroup;

    if ((element.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        fSubGroups.put(element, EMPTY_GROUP);
        return EMPTY_GROUP;
    }

    // Otherwise, get all potential sub group elements
    // (without considering "block" on this element
    OneSubGroup[] groupB = getSubGroupB(element, new OneSubGroup());
    int len = groupB.length, rlen = 0;
    XSElementDecl[] ret = new XSElementDecl[len];
    // For each of such elements, check whether the derivation methods
    // overlap with "block". If not, add it to the sub group
    for (int i = 0 ; i < len; i++) {
        if ((element.fBlock & groupB[i].dMethod) == 0)
            ret[rlen++] = groupB[i].sub;
    }
    // Resize the array if necessary
    if (rlen < len) {
        XSElementDecl[] ret1 = new XSElementDecl[rlen];
        System.arraycopy(ret, 0, ret1, 0, rlen);
        ret = ret1;
    }
    // Store the subgroup
    fSubGroups.put(element, ret);

    return ret;
}
 
Example 6
Source File: SchemaGrammar.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private XSElementDecl createAnnotationElementDecl(String localName) {
    XSElementDecl eDecl = new XSElementDecl();
    eDecl.fName = localName;
    eDecl.fTargetNamespace = fTargetNamespace;
    eDecl.setIsGlobal();
    eDecl.fBlock = (XSConstants.DERIVATION_EXTENSION |
            XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
    eDecl.setConstraintType(XSConstants.VC_NONE);
    return eDecl;
}
 
Example 7
Source File: SubstitutionGroupHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * get all elements that can substitute the given element,
 * according to the spec, we shouldn't consider the {block} constraints.
 *
 * from the spec, substitution group of a given element decl also contains
 * the element itself. but the array returned from this method doesn't
 * containt this element.
 */
public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
    // If we already have sub group for this element, just return it.
    XSElementDecl[] subGroup = fSubGroups.get(element);
    if (subGroup != null)
        return subGroup;

    if ((element.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        fSubGroups.put(element, EMPTY_GROUP);
        return EMPTY_GROUP;
    }

    // Otherwise, get all potential sub group elements
    // (without considering "block" on this element
    OneSubGroup[] groupB = getSubGroupB(element, new OneSubGroup());
    int len = groupB.length, rlen = 0;
    XSElementDecl[] ret = new XSElementDecl[len];
    // For each of such elements, check whether the derivation methods
    // overlap with "block". If not, add it to the sub group
    for (int i = 0 ; i < len; i++) {
        if ((element.fBlock & groupB[i].dMethod) == 0)
            ret[rlen++] = groupB[i].sub;
    }
    // Resize the array if necessary
    if (rlen < len) {
        XSElementDecl[] ret1 = new XSElementDecl[rlen];
        System.arraycopy(ret, 0, ret1, 0, rlen);
        ret = ret1;
    }
    // Store the subgroup
    fSubGroups.put(element, ret);

    return ret;
}
 
Example 8
Source File: SchemaGrammar.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private XSElementDecl createAnnotationElementDecl(String localName) {
    XSElementDecl eDecl = new XSElementDecl();
    eDecl.fName = localName;
    eDecl.fTargetNamespace = fTargetNamespace;
    eDecl.setIsGlobal();
    eDecl.fBlock = (XSConstants.DERIVATION_EXTENSION |
            XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
    eDecl.setConstraintType(XSConstants.VC_NONE);
    return eDecl;
}
 
Example 9
Source File: SubstitutionGroupHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar) {
    if (element.localpart == exemplar.fName &&
        element.uri == exemplar.fTargetNamespace) {
        return exemplar;
    }

    // if the exemplar is not a global element decl, then it's not possible
    // to be substituted by another element.
    if (exemplar.fScope != XSConstants.SCOPE_GLOBAL)
        return null;

    // if the decl blocks substitution, return false
    if ((exemplar.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0)
        return null;

    // get grammar of the element
    SchemaGrammar sGrammar = fGrammarBucket.getGrammar(element.uri);
    if (sGrammar == null)
        return null;

    // get the decl for the element
    XSElementDecl eDecl = sGrammar.getGlobalElementDecl(element.localpart);
    if (eDecl == null)
        return null;

    // and check by using substitutionGroup information
    if (substitutionGroupOK(eDecl, exemplar, exemplar.fBlock))
        return eDecl;

    return null;
}
 
Example 10
Source File: SchemaGrammar.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private XSElementDecl createAnnotationElementDecl(String localName) {
    XSElementDecl eDecl = new XSElementDecl();
    eDecl.fName = localName;
    eDecl.fTargetNamespace = fTargetNamespace;
    eDecl.setIsGlobal();
    eDecl.fBlock = (XSConstants.DERIVATION_EXTENSION |
            XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
    eDecl.setConstraintType(XSConstants.VC_NONE);
    return eDecl;
}
 
Example 11
Source File: SubstitutionGroupHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar) {
    if (element.localpart == exemplar.fName &&
        element.uri == exemplar.fTargetNamespace) {
        return exemplar;
    }

    // if the exemplar is not a global element decl, then it's not possible
    // to be substituted by another element.
    if (exemplar.fScope != XSConstants.SCOPE_GLOBAL)
        return null;

    // if the decl blocks substitution, return false
    if ((exemplar.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0)
        return null;

    // get grammar of the element
    SchemaGrammar sGrammar = fGrammarBucket.getGrammar(element.uri);
    if (sGrammar == null)
        return null;

    // get the decl for the element
    XSElementDecl eDecl = sGrammar.getGlobalElementDecl(element.localpart);
    if (eDecl == null)
        return null;

    // and check by using substitutionGroup information
    if (substitutionGroupOK(eDecl, exemplar, exemplar.fBlock))
        return eDecl;

    return null;
}
 
Example 12
Source File: SubstitutionGroupHandler.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint) {
    // 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:
    // 1. D and C are the same element declaration.
    if (element == exemplar) {
        return true;
    }

    // 2 All of the following must be true:
    // 2.1 The blocking constraint does not contain substitution.
    if ((blockingConstraint & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        return false;
    }

    // 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 . . .
    XSElementDecl subGroup = element.fSubGroup;
    while (subGroup != null && subGroup != exemplar) {
        subGroup = subGroup.fSubGroup;
    }

    if (subGroup == null) {
        return false;
    }

    // 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}.
    // prepare the combination of {derivation method} and
    // {disallowed substitution}
    return typeDerivationOK(element.fType, exemplar.fType, blockingConstraint);
}
 
Example 13
Source File: SubstitutionGroupHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar) {
    if (element.localpart == exemplar.fName &&
        element.uri == exemplar.fTargetNamespace) {
        return exemplar;
    }

    // if the exemplar is not a global element decl, then it's not possible
    // to be substituted by another element.
    if (exemplar.fScope != XSConstants.SCOPE_GLOBAL)
        return null;

    // if the decl blocks substitution, return false
    if ((exemplar.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0)
        return null;

    // get grammar of the element
    SchemaGrammar sGrammar = fGrammarBucket.getGrammar(element.uri);
    if (sGrammar == null)
        return null;

    // get the decl for the element
    XSElementDecl eDecl = sGrammar.getGlobalElementDecl(element.localpart);
    if (eDecl == null)
        return null;

    // and check by using substitutionGroup information
    if (substitutionGroupOK(eDecl, exemplar, exemplar.fBlock))
        return eDecl;

    return null;
}
 
Example 14
Source File: SubstitutionGroupHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * get all elements that can substitute the given element,
 * according to the spec, we shouldn't consider the {block} constraints.
 *
 * from the spec, substitution group of a given element decl also contains
 * the element itself. but the array returned from this method doesn't
 * containt this element.
 */
public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
    // If we already have sub group for this element, just return it.
    XSElementDecl[] subGroup = fSubGroups.get(element);
    if (subGroup != null)
        return subGroup;

    if ((element.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        fSubGroups.put(element, EMPTY_GROUP);
        return EMPTY_GROUP;
    }

    // Otherwise, get all potential sub group elements
    // (without considering "block" on this element
    OneSubGroup[] groupB = getSubGroupB(element, new OneSubGroup());
    int len = groupB.length, rlen = 0;
    XSElementDecl[] ret = new XSElementDecl[len];
    // For each of such elements, check whether the derivation methods
    // overlap with "block". If not, add it to the sub group
    for (int i = 0 ; i < len; i++) {
        if ((element.fBlock & groupB[i].dMethod) == 0)
            ret[rlen++] = groupB[i].sub;
    }
    // Resize the array if necessary
    if (rlen < len) {
        XSElementDecl[] ret1 = new XSElementDecl[rlen];
        System.arraycopy(ret, 0, ret1, 0, rlen);
        ret = ret1;
    }
    // Store the subgroup
    fSubGroups.put(element, ret);

    return ret;
}
 
Example 15
Source File: SubstitutionGroupHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * get all elements that can substitute the given element,
 * according to the spec, we shouldn't consider the {block} constraints.
 *
 * from the spec, substitution group of a given element decl also contains
 * the element itself. but the array returned from this method doesn't
 * containt this element.
 */
public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
    // If we already have sub group for this element, just return it.
    XSElementDecl[] subGroup = fSubGroups.get(element);
    if (subGroup != null)
        return subGroup;

    if ((element.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        fSubGroups.put(element, EMPTY_GROUP);
        return EMPTY_GROUP;
    }

    // Otherwise, get all potential sub group elements
    // (without considering "block" on this element
    OneSubGroup[] groupB = getSubGroupB(element, new OneSubGroup());
    int len = groupB.length, rlen = 0;
    XSElementDecl[] ret = new XSElementDecl[len];
    // For each of such elements, check whether the derivation methods
    // overlap with "block". If not, add it to the sub group
    for (int i = 0 ; i < len; i++) {
        if ((element.fBlock & groupB[i].dMethod) == 0)
            ret[rlen++] = groupB[i].sub;
    }
    // Resize the array if necessary
    if (rlen < len) {
        XSElementDecl[] ret1 = new XSElementDecl[rlen];
        System.arraycopy(ret, 0, ret1, 0, rlen);
        ret = ret1;
    }
    // Store the subgroup
    fSubGroups.put(element, ret);

    return ret;
}
 
Example 16
Source File: SubstitutionGroupHandler.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar) {
    if (Objects.equals(element.localpart, exemplar.fName) &&
        Objects.equals(element.uri, exemplar.fTargetNamespace)) {
        return exemplar;
    }

    // if the exemplar is not a global element decl, then it's not possible
    // to be substituted by another element.
    if (exemplar.fScope != XSConstants.SCOPE_GLOBAL) {
        return null;
    }

    // if the decl blocks substitution, return false
    if ((exemplar.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        return null;
    }

    // get the decl for the element
    XSElementDecl eDecl = fXSElementDeclHelper.getGlobalElementDecl(element);
    if (eDecl == null) {
        return null;
    }

    // and check by using substitutionGroup information
    if (substitutionGroupOK(eDecl, exemplar, exemplar.fBlock)) {
        return eDecl;
    }

    return null;
}
 
Example 17
Source File: SubstitutionGroupHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * get all elements that can substitute the given element,
 * according to the spec, we shouldn't consider the {block} constraints.
 *
 * from the spec, substitution group of a given element decl also contains
 * the element itself. but the array returned from this method doesn't
 * containt this element.
 */
public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
    // If we already have sub group for this element, just return it.
    Object subGroup = fSubGroups.get(element);
    if (subGroup != null)
        return (XSElementDecl[])subGroup;

    if ((element.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        fSubGroups.put(element, EMPTY_GROUP);
        return EMPTY_GROUP;
    }

    // Otherwise, get all potential sub group elements
    // (without considering "block" on this element
    OneSubGroup[] groupB = getSubGroupB(element, new OneSubGroup());
    int len = groupB.length, rlen = 0;
    XSElementDecl[] ret = new XSElementDecl[len];
    // For each of such elements, check whether the derivation methods
    // overlap with "block". If not, add it to the sub group
    for (int i = 0 ; i < len; i++) {
        if ((element.fBlock & groupB[i].dMethod) == 0)
            ret[rlen++] = groupB[i].sub;
    }
    // Resize the array if necessary
    if (rlen < len) {
        XSElementDecl[] ret1 = new XSElementDecl[rlen];
        System.arraycopy(ret, 0, ret1, 0, rlen);
        ret = ret1;
    }
    // Store the subgroup
    fSubGroups.put(element, ret);

    return ret;
}
 
Example 18
Source File: SchemaGrammar.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private XSElementDecl createAnnotationElementDecl(String localName) {
    XSElementDecl eDecl = new XSElementDecl();
    eDecl.fName = localName;
    eDecl.fTargetNamespace = fTargetNamespace;
    eDecl.setIsGlobal();
    eDecl.fBlock = (XSConstants.DERIVATION_EXTENSION |
            XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
    eDecl.setConstraintType(XSConstants.VC_NONE);
    return eDecl;
}
 
Example 19
Source File: SubstitutionGroupHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * get all elements that can substitute the given element,
 * according to the spec, we shouldn't consider the {block} constraints.
 *
 * from the spec, substitution group of a given element decl also contains
 * the element itself. but the array returned from this method doesn't
 * containt this element.
 */
public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
    // If we already have sub group for this element, just return it.
    XSElementDecl[] subGroup = fSubGroups.get(element);
    if (subGroup != null)
        return subGroup;

    if ((element.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        fSubGroups.put(element, EMPTY_GROUP);
        return EMPTY_GROUP;
    }

    // Otherwise, get all potential sub group elements
    // (without considering "block" on this element
    OneSubGroup[] groupB = getSubGroupB(element, new OneSubGroup());
    int len = groupB.length, rlen = 0;
    XSElementDecl[] ret = new XSElementDecl[len];
    // For each of such elements, check whether the derivation methods
    // overlap with "block". If not, add it to the sub group
    for (int i = 0 ; i < len; i++) {
        if ((element.fBlock & groupB[i].dMethod) == 0)
            ret[rlen++] = groupB[i].sub;
    }
    // Resize the array if necessary
    if (rlen < len) {
        XSElementDecl[] ret1 = new XSElementDecl[rlen];
        System.arraycopy(ret, 0, ret1, 0, rlen);
        ret = ret1;
    }
    // Store the subgroup
    fSubGroups.put(element, ret);

    return ret;
}
 
Example 20
Source File: SubstitutionGroupHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar) {
    if (element.localpart == exemplar.fName &&
        element.uri == exemplar.fTargetNamespace) {
        return exemplar;
    }

    // if the exemplar is not a global element decl, then it's not possible
    // to be substituted by another element.
    if (exemplar.fScope != XSConstants.SCOPE_GLOBAL) {
        return null;
    }

    // if the decl blocks substitution, return false
    if ((exemplar.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        return null;
    }

    // get the decl for the element
    XSElementDecl eDecl = fXSElementDeclHelper.getGlobalElementDecl(element);
    if (eDecl == null) {
        return null;
    }

    // and check by using substitutionGroup information
    if (substitutionGroupOK(eDecl, exemplar, exemplar.fBlock)) {
        return eDecl;
    }

    return null;
}