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

The following examples show how to use com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols. 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: XSDComplexTypeTraverser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example #2
Source File: XSDComplexTypeTraverser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example #3
Source File: XSDComplexTypeTraverser.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example #4
Source File: XSDComplexTypeTraverser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example #5
Source File: RootTypeDefinitionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testSettingToOtherSchemaType() {
    try {
        reset();
        ((PSVIElementNSImpl) fRootNode).setAttributeNS(SchemaSymbols.URI_XSI,
            SchemaSymbols.XSI_SCHEMALOCATION,
            "xslt.unittests otherNamespace.xsd");
        fValidator.setProperty(ROOT_TYPE, typeOtherNamespace);
        validateDocument();
    } catch (Exception e) {
        fail("Validation failed: " + e.getMessage());
    }

    assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
    assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
            .getValidationAttempted());
    assertElementNull(fRootNode.getElementDeclaration());
    assertTypeName("W", fRootNode.getTypeDefinition().getName());
    assertTypeNamespace("xslt.unittests", fRootNode.getTypeDefinition()
            .getNamespace());
}
 
Example #6
Source File: XSDComplexTypeTraverser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example #7
Source File: XSDComplexTypeTraverser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static XSParticleDecl getErrorContent() {
    if (fErrorContent == null) {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;
        fErrorContent = errorContent;
    }
    return fErrorContent;
}
 
Example #8
Source File: XSDSimpleTypeTraverser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private String genAnonTypeName(Element simpleTypeDecl) {

        // Generate a unique name for the anonymous type by concatenating together the
        // names of parent nodes
        // The name is quite good for debugging/error purposes, but we may want to
        // revisit how this is done for performance reasons (LM).
        StringBuffer typeName = new StringBuffer("#AnonType_");
        Element node = DOMUtil.getParent(simpleTypeDecl);
        while (node != null && (node != DOMUtil.getRoot(DOMUtil.getDocument(node)))) {
            typeName.append(node.getAttribute(SchemaSymbols.ATT_NAME));
            node = DOMUtil.getParent(node);
        }
        return typeName.toString();
    }
 
Example #9
Source File: XSDFACM.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check which elements are valid to appear at this point. This method also
 * works if the state is in error, in which case it returns what should
 * have been seen.
 *
 * @param state  the current state
 * @return       a Vector whose entries are instances of
 *               either XSWildcardDecl or XSElementDecl.
 */
public Vector whatCanGoHere(int[] state) {
    int curState = state[0];
    if (curState < 0)
        curState = state[1];
    Occurence o = (fCountingStates != null) ?
            fCountingStates[curState] : null;
    int count = state[2];

    Vector ret = new Vector();
    for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
        int nextState = fTransTable[curState][elemIndex];
        if (nextState != -1) {
            if (o != null) {
                if (curState == nextState) {
                    // Do not include transitions which loop back to the
                    // current state if we've looped the maximum number
                    // of times or greater.
                    if (count >= o.maxOccurs &&
                        o.maxOccurs != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
                        continue;
                    }
                }
                // Do not include transitions which advance past the
                // current state if we have not looped enough times.
                else if (count < o.minOccurs) {
                    continue;
                }
            }
            ret.addElement(fElemMap[elemIndex]);
        }
    }
    return ret;
}
 
Example #10
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private void addRelatedType(XSTypeDefinition type, Vector componentList, String namespace, Map<String, Vector> dependencies) {
    if (!type.getAnonymous()) {
        if (!type.getNamespace().equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) { //REVISIT - do we use == instead
            if (!componentList.contains(type)) {
                final Vector importedNamespaces = findDependentNamespaces(namespace, dependencies);
                addNamespaceDependency(namespace, type.getNamespace(), importedNamespaces);
                componentList.add(type);
            }
        }
    }
    else {
        expandRelatedTypeComponents(type, componentList, namespace, dependencies);
    }
}
 
Example #11
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected void storeKeyRef (Element keyrefToStore, XSDocumentInfo schemaDoc,
        XSElementDecl currElemDecl) {
    String keyrefName = DOMUtil.getAttrValue(keyrefToStore, SchemaSymbols.ATT_NAME);
    if (keyrefName.length() != 0) {
        String keyrefQName = schemaDoc.fTargetNamespace == null?
                "," + keyrefName: schemaDoc.fTargetNamespace+","+keyrefName;
        checkForDuplicateNames(keyrefQName, IDENTITYCONSTRAINT_TYPE, fUnparsedIdentityConstraintRegistry, fUnparsedIdentityConstraintRegistrySub, keyrefToStore, schemaDoc);
    }
    // now set up all the registries we'll need...

    // check array sizes
    if (fKeyrefStackPos == fKeyrefs.length) {
        Element [] elemArray = new Element [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefs, 0, elemArray, 0, fKeyrefStackPos);
        fKeyrefs = elemArray;
        XSElementDecl [] declArray = new XSElementDecl [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefElems, 0, declArray, 0, fKeyrefStackPos);
        fKeyrefElems = declArray;
        String[][] stringArray = new String [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT][];
        System.arraycopy(fKeyrefNamespaceContext, 0, stringArray, 0, fKeyrefStackPos);
        fKeyrefNamespaceContext = stringArray;

        XSDocumentInfo [] xsDocumentInfo = new XSDocumentInfo [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefsMapXSDocumentInfo, 0, xsDocumentInfo, 0, fKeyrefStackPos);
        fKeyrefsMapXSDocumentInfo = xsDocumentInfo;

    }
    fKeyrefs[fKeyrefStackPos] = keyrefToStore;
    fKeyrefElems[fKeyrefStackPos] = currElemDecl;
    fKeyrefNamespaceContext[fKeyrefStackPos] = schemaDoc.fNamespaceSupport.getEffectiveLocalContext();

    fKeyrefsMapXSDocumentInfo[fKeyrefStackPos++] = schemaDoc;
}
 
Example #12
Source File: XSDSimpleTypeTraverser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private String genAnonTypeName(Element simpleTypeDecl) {

        // Generate a unique name for the anonymous type by concatenating together the
        // names of parent nodes
        // The name is quite good for debugging/error purposes, but we may want to
        // revisit how this is done for performance reasons (LM).
        StringBuffer typeName = new StringBuffer("#AnonType_");
        Element node = DOMUtil.getParent(simpleTypeDecl);
        while (node != null && (node != DOMUtil.getRoot(DOMUtil.getDocument(node)))) {
            typeName.append(node.getAttribute(SchemaSymbols.ATT_NAME));
            node = DOMUtil.getParent(node);
        }
        return typeName.toString();
    }
 
Example #13
Source File: XSDComplexTypeTraverser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example #14
Source File: XSDSimpleTypeTraverser.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private String genAnonTypeName(Element simpleTypeDecl) {

        // Generate a unique name for the anonymous type by concatenating together the
        // names of parent nodes
        // The name is quite good for debugging/error purposes, but we may want to
        // revisit how this is done for performance reasons (LM).
        StringBuffer typeName = new StringBuffer("#AnonType_");
        Element node = DOMUtil.getParent(simpleTypeDecl);
        while (node != null && (node != DOMUtil.getRoot(DOMUtil.getDocument(node)))) {
            typeName.append(node.getAttribute(SchemaSymbols.ATT_NAME));
            node = DOMUtil.getParent(node);
        }
        return typeName.toString();
    }
 
Example #15
Source File: XSDHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void addRelatedType(XSTypeDefinition type, Vector componentList, String namespace, Map<String, Vector> dependencies) {
    if (!type.getAnonymous()) {
        if (!type.getNamespace().equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) { //REVISIT - do we use == instead
            if (!componentList.contains(type)) {
                final Vector importedNamespaces = findDependentNamespaces(namespace, dependencies);
                addNamespaceDependency(namespace, type.getNamespace(), importedNamespaces);
                componentList.add(type);
            }
        }
    }
    else {
        expandRelatedTypeComponents(type, componentList, namespace, dependencies);
    }
}
 
Example #16
Source File: XSDHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private int changeRedefineGroup(String originalQName, String elementSought,
        String newName, Element curr, XSDocumentInfo schemaDoc) {
    int result = 0;
    for (Element child = DOMUtil.getFirstChildElement(curr);
    child != null; child = DOMUtil.getNextSiblingElement(child)) {
        String name = DOMUtil.getLocalName(child);
        if (!name.equals(elementSought))
            result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
        else {
            String ref = child.getAttribute( SchemaSymbols.ATT_REF );
            if (ref.length() != 0) {
                String processedRef = findQName(ref, schemaDoc);
                if (originalQName.equals(processedRef)) {
                    String prefix = XMLSymbols.EMPTY_STRING;
                    int colonptr = ref.indexOf(":");
                    if (colonptr > 0) {
                        prefix = ref.substring(0,colonptr);
                        child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
                    }
                    else
                        child.setAttribute(SchemaSymbols.ATT_REF, newName);
                    result++;
                    if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
                        String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
                        String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
                        if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
                                && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
                            reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
                        }
                    }
                }
            } // if ref was null some other stage of processing will flag the error
        }
    }
    return result;
}
 
Example #17
Source File: XSDComplexTypeTraverser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example #18
Source File: XSDComplexTypeTraverser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private String genAnonTypeName(Element complexTypeDecl) {

        // Generate a unique name for the anonymous type by concatenating together the
        // names of parent nodes
        // The name is quite good for debugging/error purposes, but we may want to
        // revisit how this is done for performance reasons (LM).
        StringBuffer typeName = new StringBuffer("#AnonType_");
        Element node = DOMUtil.getParent(complexTypeDecl);
        while (node != null && (node != DOMUtil.getRoot(DOMUtil.getDocument(node)))) {
            typeName.append(node.getAttribute(SchemaSymbols.ATT_NAME));
            node = DOMUtil.getParent(node);
        }
        return typeName.toString();
    }
 
Example #19
Source File: XSDHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void storeKeyRef (Element keyrefToStore, XSDocumentInfo schemaDoc,
        XSElementDecl currElemDecl) {
    String keyrefName = DOMUtil.getAttrValue(keyrefToStore, SchemaSymbols.ATT_NAME);
    if (keyrefName.length() != 0) {
        String keyrefQName = schemaDoc.fTargetNamespace == null?
                "," + keyrefName: schemaDoc.fTargetNamespace+","+keyrefName;
        checkForDuplicateNames(keyrefQName, IDENTITYCONSTRAINT_TYPE, fUnparsedIdentityConstraintRegistry, fUnparsedIdentityConstraintRegistrySub, keyrefToStore, schemaDoc);
    }
    // now set up all the registries we'll need...

    // check array sizes
    if (fKeyrefStackPos == fKeyrefs.length) {
        Element [] elemArray = new Element [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefs, 0, elemArray, 0, fKeyrefStackPos);
        fKeyrefs = elemArray;
        XSElementDecl [] declArray = new XSElementDecl [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefElems, 0, declArray, 0, fKeyrefStackPos);
        fKeyrefElems = declArray;
        String[][] stringArray = new String [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT][];
        System.arraycopy(fKeyrefNamespaceContext, 0, stringArray, 0, fKeyrefStackPos);
        fKeyrefNamespaceContext = stringArray;

        XSDocumentInfo [] xsDocumentInfo = new XSDocumentInfo [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefsMapXSDocumentInfo, 0, xsDocumentInfo, 0, fKeyrefStackPos);
        fKeyrefsMapXSDocumentInfo = xsDocumentInfo;

    }
    fKeyrefs[fKeyrefStackPos] = keyrefToStore;
    fKeyrefElems[fKeyrefStackPos] = currElemDecl;
    fKeyrefNamespaceContext[fKeyrefStackPos] = schemaDoc.fNamespaceSupport.getEffectiveLocalContext();

    fKeyrefsMapXSDocumentInfo[fKeyrefStackPos++] = schemaDoc;
}
 
Example #20
Source File: XSDComplexTypeTraverser.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example #21
Source File: XSDHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void addRelatedType(XSTypeDefinition type, Vector componentList, String namespace, Map<String, Vector> dependencies) {
    if (!type.getAnonymous()) {
        if (!type.getNamespace().equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) { //REVISIT - do we use == instead
            if (!componentList.contains(type)) {
                final Vector importedNamespaces = findDependentNamespaces(namespace, dependencies);
                addNamespaceDependency(namespace, type.getNamespace(), importedNamespaces);
                componentList.add(type);
            }
        }
    }
    else {
        expandRelatedTypeComponents(type, componentList, namespace, dependencies);
    }
}
 
Example #22
Source File: XSDHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void storeKeyRef (Element keyrefToStore, XSDocumentInfo schemaDoc,
        XSElementDecl currElemDecl) {
    String keyrefName = DOMUtil.getAttrValue(keyrefToStore, SchemaSymbols.ATT_NAME);
    if (keyrefName.length() != 0) {
        String keyrefQName = schemaDoc.fTargetNamespace == null?
                "," + keyrefName: schemaDoc.fTargetNamespace+","+keyrefName;
        checkForDuplicateNames(keyrefQName, IDENTITYCONSTRAINT_TYPE, fUnparsedIdentityConstraintRegistry, fUnparsedIdentityConstraintRegistrySub, keyrefToStore, schemaDoc);
    }
    // now set up all the registries we'll need...

    // check array sizes
    if (fKeyrefStackPos == fKeyrefs.length) {
        Element [] elemArray = new Element [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefs, 0, elemArray, 0, fKeyrefStackPos);
        fKeyrefs = elemArray;
        XSElementDecl [] declArray = new XSElementDecl [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefElems, 0, declArray, 0, fKeyrefStackPos);
        fKeyrefElems = declArray;
        String[][] stringArray = new String [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT][];
        System.arraycopy(fKeyrefNamespaceContext, 0, stringArray, 0, fKeyrefStackPos);
        fKeyrefNamespaceContext = stringArray;

        XSDocumentInfo [] xsDocumentInfo = new XSDocumentInfo [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefsMapXSDocumentInfo, 0, xsDocumentInfo, 0, fKeyrefStackPos);
        fKeyrefsMapXSDocumentInfo = xsDocumentInfo;

    }
    fKeyrefs[fKeyrefStackPos] = keyrefToStore;
    fKeyrefElems[fKeyrefStackPos] = currElemDecl;
    fKeyrefNamespaceContext[fKeyrefStackPos] = schemaDoc.fNamespaceSupport.getEffectiveLocalContext();

    fKeyrefsMapXSDocumentInfo[fKeyrefStackPos++] = schemaDoc;
}
 
Example #23
Source File: CMBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private CMNode buildCompactSyntaxTree2(XSParticleDecl particle, int minOccurs, int maxOccurs) {
    // Convert element and wildcard particles to leaf nodes. Wrap repeating particles in a CMUniOpNode.
    CMNode nodeRet = null;
    if (minOccurs == 1 && maxOccurs == 1) {
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
    }
    else if (minOccurs == 0 && maxOccurs == 1) {
        // zero or one
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // zero or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // one or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
    }
    else {
        // {n,m}: Instead of expanding this out, create a compound leaf node which carries the
        // occurence information and wrap it in the appropriate CMUniOpNode.
        nodeRet = fNodeFactory.getCMRepeatingLeafNode(particle.fType, particle.fValue, minOccurs, maxOccurs, fParticleCount++, fLeafCount++);
        if (minOccurs == 0) {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
        }
        else {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
        }
    }
    return nodeRet;
}
 
Example #24
Source File: XSDHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void storeKeyRef (Element keyrefToStore, XSDocumentInfo schemaDoc,
        XSElementDecl currElemDecl) {
    String keyrefName = DOMUtil.getAttrValue(keyrefToStore, SchemaSymbols.ATT_NAME);
    if (keyrefName.length() != 0) {
        String keyrefQName = schemaDoc.fTargetNamespace == null?
                "," + keyrefName: schemaDoc.fTargetNamespace+","+keyrefName;
        checkForDuplicateNames(keyrefQName, IDENTITYCONSTRAINT_TYPE, fUnparsedIdentityConstraintRegistry, fUnparsedIdentityConstraintRegistrySub, keyrefToStore, schemaDoc);
    }
    // now set up all the registries we'll need...

    // check array sizes
    if (fKeyrefStackPos == fKeyrefs.length) {
        Element [] elemArray = new Element [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefs, 0, elemArray, 0, fKeyrefStackPos);
        fKeyrefs = elemArray;
        XSElementDecl [] declArray = new XSElementDecl [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefElems, 0, declArray, 0, fKeyrefStackPos);
        fKeyrefElems = declArray;
        String[][] stringArray = new String [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT][];
        System.arraycopy(fKeyrefNamespaceContext, 0, stringArray, 0, fKeyrefStackPos);
        fKeyrefNamespaceContext = stringArray;

        XSDocumentInfo [] xsDocumentInfo = new XSDocumentInfo [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
        System.arraycopy(fKeyrefsMapXSDocumentInfo, 0, xsDocumentInfo, 0, fKeyrefStackPos);
        fKeyrefsMapXSDocumentInfo = xsDocumentInfo;

    }
    fKeyrefs[fKeyrefStackPos] = keyrefToStore;
    fKeyrefElems[fKeyrefStackPos] = currElemDecl;
    fKeyrefNamespaceContext[fKeyrefStackPos] = schemaDoc.fNamespaceSupport.getEffectiveLocalContext();

    fKeyrefsMapXSDocumentInfo[fKeyrefStackPos++] = schemaDoc;
}
 
Example #25
Source File: CMBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private CMNode buildCompactSyntaxTree2(XSParticleDecl particle, int minOccurs, int maxOccurs) {
    // Convert element and wildcard particles to leaf nodes. Wrap repeating particles in a CMUniOpNode.
    CMNode nodeRet = null;
    if (minOccurs == 1 && maxOccurs == 1) {
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
    }
    else if (minOccurs == 0 && maxOccurs == 1) {
        // zero or one
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
    }
    else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // zero or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
    }
    else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
        // one or more
        nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
        nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
    }
    else {
        // {n,m}: Instead of expanding this out, create a compound leaf node which carries the
        // occurence information and wrap it in the appropriate CMUniOpNode.
        nodeRet = fNodeFactory.getCMRepeatingLeafNode(particle.fType, particle.fValue, minOccurs, maxOccurs, fParticleCount++, fLeafCount++);
        if (minOccurs == 0) {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, nodeRet);
        }
        else {
            nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
        }
    }
    return nodeRet;
}
 
Example #26
Source File: SchemaDOMParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The end of an element.
 *
 * @param element The name of the element.
 * @param augs    Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void endElement(QName element, Augmentations augs) throws XNIException {

    // when we reach the endElement of xs:appinfo or xs:documentation,
    // change fInnerAnnotationDepth to -1
    if(fAnnotationDepth > -1) {
        if (fInnerAnnotationDepth == fDepth) {
            fInnerAnnotationDepth = -1;
            schemaDOM.endAnnotationElement(element);
            schemaDOM.endElement();
        } else if (fAnnotationDepth == fDepth) {
            fAnnotationDepth = -1;
            schemaDOM.endAnnotation(element, fCurrentAnnotationElement);
            schemaDOM.endElement();
        } else { // inside a child of annotation
            schemaDOM.endAnnotationElement(element);
        }
    } else { // not in an annotation at all
        if(element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            boolean value = fHasNonSchemaAttributes.pop();
            boolean sawann = fSawAnnotation.pop();
            if (value && !sawann) {
                String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
                final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
                schemaDOM.startAnnotation(annRawName, fEmptyAttr, fNamespaceContext);
                final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
                schemaDOM.startAnnotationElement(elemRawName, fEmptyAttr);
                schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
                schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
                schemaDOM.endSyntheticAnnotationElement(annRawName, true);
            }
        }
        schemaDOM.endElement();
    }
    fDepth--;

}
 
Example #27
Source File: SchemaDOMParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
Example #28
Source File: XSDHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Grammar retrieveGrammar(XMLGrammarDescription desc) {
    if (desc.getGrammarType() == XMLGrammarDescription.XML_SCHEMA) {
        final String tns = ((XMLSchemaDescription) desc).getTargetNamespace();
        if (fGrammarBucket != null) {
            Grammar grammar = fGrammarBucket.getGrammar(tns);
            if (grammar != null) {
                return grammar;
            }
        }
        if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(tns)) {
            return SchemaGrammar.Schema4Annotations.INSTANCE;
        }
    }
    return null;
}
 
Example #29
Source File: SchemaDOMParser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The end of an element.
 *
 * @param element The name of the element.
 * @param augs    Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void endElement(QName element, Augmentations augs) throws XNIException {

    // when we reach the endElement of xs:appinfo or xs:documentation,
    // change fInnerAnnotationDepth to -1
    if(fAnnotationDepth > -1) {
        if (fInnerAnnotationDepth == fDepth) {
            fInnerAnnotationDepth = -1;
            schemaDOM.endAnnotationElement(element);
            schemaDOM.endElement();
        } else if (fAnnotationDepth == fDepth) {
            fAnnotationDepth = -1;
            schemaDOM.endAnnotation(element, fCurrentAnnotationElement);
            schemaDOM.endElement();
        } else { // inside a child of annotation
            schemaDOM.endAnnotationElement(element);
        }
    } else { // not in an annotation at all
        if(element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            boolean value = fHasNonSchemaAttributes.pop();
            boolean sawann = fSawAnnotation.pop();
            if (value && !sawann) {
                String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
                final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
                schemaDOM.startAnnotation(annRawName, fEmptyAttr, fNamespaceContext);
                final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
                schemaDOM.startAnnotationElement(elemRawName, fEmptyAttr);
                schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
                schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
                schemaDOM.endSyntheticAnnotationElement(annRawName, true);
            }
        }
        schemaDOM.endElement();
    }
    fDepth--;

}
 
Example #30
Source File: XSDHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Grammar retrieveGrammar(XMLGrammarDescription desc) {
    if (desc.getGrammarType() == XMLGrammarDescription.XML_SCHEMA) {
        final String tns = ((XMLSchemaDescription) desc).getTargetNamespace();
        if (fGrammarBucket != null) {
            Grammar grammar = fGrammarBucket.getGrammar(tns);
            if (grammar != null) {
                return grammar;
            }
        }
        if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(tns)) {
            return SchemaGrammar.Schema4Annotations.INSTANCE;
        }
    }
    return null;
}