com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException. 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: XSAllCM.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #2
Source File: XSAllCM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #3
Source File: XSAllCM.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #4
Source File: XSAllCM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #5
Source File: XSAllCM.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #6
Source File: XSAllCM.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #7
Source File: XSAllCM.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #8
Source File: XSAllCM.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #9
Source File: XSAllCM.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #10
Source File: XSAllCM.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #11
Source File: XSAllCM.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // check whether there is conflict between any two leaves
    for (int i = 0; i < fNumElements; i++) {
        for (int j = i+1; j < fNumElements; j++) {
            if (XSConstraints.overlapUPA(fAllElements[i], fAllElements[j], subGroupHandler)) {
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fAllElements[i].toString(),
                                                                          fAllElements[j].toString()});
            }
        }
    }

    return false;
}
 
Example #12
Source File: XSDocumentInfo.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #13
Source File: XSDFACM.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #14
Source File: XSDocumentInfo.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #15
Source File: XSDocumentInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #16
Source File: XSDFACM.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #17
Source File: XSDFACM.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #18
Source File: XSDFACM.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #19
Source File: XSDocumentInfo.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #20
Source File: XSDFACM.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #21
Source File: XSDFACM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #22
Source File: XSDocumentInfo.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #23
Source File: XSDocumentInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #24
Source File: XSDocumentInfo.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #25
Source File: XSDFACM.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #26
Source File: XSDocumentInfo.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #27
Source File: XSDocumentInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example #28
Source File: XSDFACM.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #29
Source File: XSDFACM.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * check whether this content violates UPA constraint.
 *
 * @param subGroupHandler the substitution group handler
 * @return true if this content model contains other or list wildcard
 */
public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException {
    // Unique Particle Attribution
    // store the conflict results between any two elements in fElemMap
    // 0: not compared; -1: no conflict; 1: conflict
    // initialize the conflict table (all 0 initially)
    byte conflictTable[][] = new byte[fElemMapSize][fElemMapSize];

    // for each state, check whether it has overlap transitions
    for (int i = 0; i < fTransTable.length && fTransTable[i] != null; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            for (int k = j+1; k < fElemMapSize; k++) {
                if (fTransTable[i][j] != -1 &&
                    fTransTable[i][k] != -1) {
                    if (conflictTable[j][k] == 0) {
                        if (XSConstraints.overlapUPA
                                (fElemMap[j], fElemMap[k],
                                        subGroupHandler)) {
                            if (fCountingStates != null) {
                                Occurence o = fCountingStates[i];
                                // If "i" is a counting state and exactly one of the transitions
                                // loops back to "i" then the two particles do not overlap if
                                // minOccurs == maxOccurs.
                                if (o != null &&
                                    fTransTable[i][j] == i ^ fTransTable[i][k] == i &&
                                    o.minOccurs == o.maxOccurs) {
                                    conflictTable[j][k] = (byte) -1;
                                    continue;
                                }
                            }
                            conflictTable[j][k] = (byte) 1;
                        }
                        else {
                            conflictTable[j][k] = (byte) -1;
                        }
                    }
                }
            }
        }
    }

    // report all errors
    for (int i = 0; i < fElemMapSize; i++) {
        for (int j = 0; j < fElemMapSize; j++) {
            if (conflictTable[i][j] == 1) {
                //errors.newError("cos-nonambig", new Object[]{fElemMap[i].toString(),
                //                                             fElemMap[j].toString()});
                // REVISIT: do we want to report all errors? or just one?
                throw new XMLSchemaException("cos-nonambig", new Object[]{fElemMap[i].toString(),
                                                                          fElemMap[j].toString()});
            }
        }
    }

    // if there is a other or list wildcard, we need to check this CM
    // again, if this grammar is cached.
    for (int i = 0; i < fElemMapSize; i++) {
        if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
            XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
            if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
                wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
                return true;
            }
        }
    }

    return false;
}
 
Example #30
Source File: XSDocumentInfo.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}