com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl

Here are the examples of the java api class com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl taken from open source projects.

1. XSDElementTraverser#traverseGlobal()

Project: openjdk
Source File: XSDElementTraverser.java
View license
/**
     * Traverse a globally declared element.
     *
     * @param  elmDecl
     * @param  schemaDoc
     * @param  grammar
     * @return the element declaration
     */
XSElementDecl traverseGlobal(Element elmDecl, XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
    // General Attribute Checking'
    Object[] attrValues = fAttrChecker.checkAttributes(elmDecl, true, schemaDoc);
    XSElementDecl element = traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, true, null);
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);
    return element;
}

2. XSDElementTraverser#traverseLocal()

Project: openjdk
Source File: XSDElementTraverser.java
View license
/**
     * Traverse a locally declared element (or an element reference).
     *
     * This is the real traversal method. It's called after we've done with
     * all the global declarations.
     *
     * @param  index
     */
protected void traverseLocal(XSParticleDecl particle, Element elmDecl, XSDocumentInfo schemaDoc, SchemaGrammar grammar, int allContextFlags, XSObject parent, String[] localNSDecls) {
    if (localNSDecls != null) {
        schemaDoc.fNamespaceSupport.setEffectiveContext(localNSDecls);
    }
    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(elmDecl, false, schemaDoc);
    QName refAtt = (QName) attrValues[XSAttributeChecker.ATTIDX_REF];
    XInt minAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_MINOCCURS];
    XInt maxAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS];
    XSElementDecl element = null;
    XSAnnotationImpl annotation = null;
    if (elmDecl.getAttributeNode(SchemaSymbols.ATT_REF) != null) {
        if (refAtt != null) {
            element = (XSElementDecl) fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.ELEMENT_TYPE, refAtt, elmDecl);
            Element child = DOMUtil.getFirstChildElement(elmDecl);
            if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
                annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
                child = DOMUtil.getNextSiblingElement(child);
            } else {
                String text = DOMUtil.getSyntheticAnnotation(elmDecl);
                if (text != null) {
                    annotation = traverseSyntheticAnnotation(elmDecl, text, attrValues, false, schemaDoc);
                }
            }
            // 2.2 If ref is present, then all of <complexType>, <simpleType>, <key>, <keyref>, <unique>, nillable, default, fixed, form, block and type must be absent, i.e. only minOccurs, maxOccurs, id are allowed in addition to ref, along with <annotation>.
            if (child != null) {
                reportSchemaError("src-element.2.2", new Object[] { refAtt.rawname, DOMUtil.getLocalName(child) }, child);
            }
        } else {
            element = null;
        }
    } else {
        element = traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, false, parent);
    }
    particle.fMinOccurs = minAtt.intValue();
    particle.fMaxOccurs = maxAtt.intValue();
    if (element != null) {
        particle.fType = XSParticleDecl.PARTICLE_ELEMENT;
        particle.fValue = element;
    } else {
        particle.fType = XSParticleDecl.PARTICLE_EMPTY;
    }
    if (refAtt != null) {
        XSObjectList annotations;
        if (annotation != null) {
            annotations = new XSObjectListImpl();
            ((XSObjectListImpl) annotations).addXSObject(annotation);
        } else {
            annotations = XSObjectListImpl.EMPTY_LIST;
        }
        particle.fAnnotations = annotations;
    } else {
        particle.fAnnotations = ((element != null) ? element.fAnnotations : XSObjectListImpl.EMPTY_LIST);
    }
    Long defaultVals = (Long) attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
    checkOccurrences(particle, SchemaSymbols.ELT_ELEMENT, (Element) elmDecl.getParentNode(), allContextFlags, defaultVals.longValue());
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);
}

3. XSDHandler#addGlobalElementDecls()

Project: openjdk
Source File: XSDHandler.java
View license
private void addGlobalElementDecls(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
    XSNamedMap components = srcGrammar.getComponents(XSConstants.ELEMENT_DECLARATION);
    int len = components.getLength();
    XSElementDecl srcDecl, dstDecl;
    // add global components
    for (int i = 0; i < len; i++) {
        srcDecl = (XSElementDecl) components.item(i);
        dstDecl = dstGrammar.getGlobalElementDecl(srcDecl.getName());
        if (dstDecl == null) {
            dstGrammar.addGlobalElementDecl(srcDecl);
        } else if (dstDecl != srcDecl) {
        // TODO: if not tolerating duplicate, generate an error message
        }
    }
    // add any extended (duplicate) global components
    ObjectList componentsExt = srcGrammar.getComponentsExt(XSConstants.ELEMENT_DECLARATION);
    len = componentsExt.getLength();
    for (int i = 0; i < len; i += 2) {
        final String key = (String) componentsExt.item(i);
        final int index = key.indexOf(',');
        final String location = key.substring(0, index);
        final String name = key.substring(index + 1, key.length());
        srcDecl = (XSElementDecl) componentsExt.item(i + 1);
        dstDecl = dstGrammar.getGlobalElementDecl(name, location);
        if (dstDecl == null) {
            dstGrammar.addGlobalElementDecl(srcDecl, location);
        } else if (dstDecl != srcDecl) {
        // TODO: if not tolerating duplicate, generate an error message
        }
    }
}