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

The following examples show how to use com.sun.org.apache.xerces.internal.xs.XSConstants#VC_FIXED . 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: XMLSchemaValidator.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: XMLSchemaValidator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: XMLSchemaValidator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 4
Source File: XMLSchemaValidator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 5
Source File: XMLSchemaValidator.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 6
Source File: XMLSchemaValidator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 7
Source File: XMLSchemaValidator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 8
Source File: XMLSchemaValidator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 9
Source File: XMLSchemaValidator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example 10
Source File: XSConstraints.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 11
Source File: XSConstraints.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 12
Source File: XSConstraints.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 13
Source File: XSConstraints.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 14
Source File: XSConstraints.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 15
Source File: XSConstraints.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 16
Source File: XSConstraints.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 17
Source File: XSConstraints.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 18
Source File: XSConstraints.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 19
Source File: XSConstraints.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}
 
Example 20
Source File: XSConstraints.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
        XSElementDecl bElement, int bMin, int bMax)
    throws XMLSchemaException {


    //
    // Check that the names are the same
    //
    if (dElement.fName != bElement.fName ||
            dElement.fTargetNamespace != bElement.fTargetNamespace) {
        throw new XMLSchemaException(
                "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
                        dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
    }

    //
    // Check nillable
    //
    if (!bElement.getNillable() && dElement.getNillable()) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.2",
                new Object[]{dElement.fName});
    }

    //
    // Check occurrence range
    //
    if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.3",
                new Object[]{
                dElement.fName,
                Integer.toString(dMin),
                dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
                        Integer.toString(bMin),
                        bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
    }

    //
    // Check for consistent fixed values
    //
    if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
        // derived one has to have a fixed value
        if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
                    new Object[]{dElement.fName, bElement.fDefault.stringValue()});
        }

        // get simple type
        boolean isSimple = false;
        if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
                ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
            isSimple = true;
        }

        // if there is no simple type, then compare based on string
        if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
                isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
                    new Object[]{dElement.fName,
                    dElement.fDefault.stringValue(),
                    bElement.fDefault.stringValue()});
        }
    }

    //
    // Check identity constraints
    //
    checkIDConstraintRestriction(dElement, bElement);

    //
    // Check for disallowed substitutions
    //
    int blockSet1 = dElement.fBlock;
    int blockSet2 = bElement.fBlock;
    if (((blockSet1 & blockSet2)!=blockSet2) ||
            (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
        throw new XMLSchemaException("rcase-NameAndTypeOK.6",
                new Object[]{dElement.fName});


    //
    // Check that the derived element's type is derived from the base's.
    //
    if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
            (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
        throw new XMLSchemaException("rcase-NameAndTypeOK.7",
                new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
    }

}