Examples of ElementDecl


Examples of org.exolab.castor.xml.schema.ElementDecl

    throws XMLException {
        super(schemaContext);

        this._schema = schema;

        _element = new ElementDecl(schema);
       
        String attValue = null;
       
        //-- @ref
        attValue = atts.getValue(SchemaNames.REF_ATTR);
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

            }
            else {
                group = (Group) type.getParticle(0);
                //-- check for another element declaration with
                //-- same name ...
                ElementDecl element = group.getElementDecl(name);
                boolean checkGroupType = false;
                if (element != null) {
                    //-- if complex...merge definition
                    if (sInfo.complex) {
                        try {
                            merge(element, sInfo.element);
                        }
                        catch(SchemaException sx) {
                            throw new SAXException(sx);
                        }
                    }
                    element.setMaxOccurs(Particle.UNBOUNDED);
                    checkGroupType = true;
                }
                else {
                    try {
                        group.addElementDecl(sInfo.element);
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

        sInfo = new StateInfo();
        sInfo.topLevel = topLevel;
        _siStack.push(sInfo);
       
        //-- create element definition
        sInfo.element = new ElementDecl(_schema, name);
       
        //-- create attributes
        for (int i = 0; i < atts.getLength(); i++) {
           
            String attName = atts.getName(i);
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

       
        Enumeration enumeration = e2Group.enumerate();
        while (enumeration.hasMoreElements()) {
            Particle particle = (Particle)enumeration.nextElement();
            if (particle.getStructureType() == Structure.ELEMENT) {
                ElementDecl element = (ElementDecl)particle;
                ElementDecl main = e1Group.getElementDecl(element.getName());
                if (main == null) {
                    e1Group.addElementDecl(element);
                    element.setMinOccurs(0);
                }
                else {
                    merge(main, element);
                }
            }
        }
        //-- add all attributes from type2
        enumeration = cType2.getAttributeDecls();
       
        while (enumeration.hasMoreElements()) {
            //-- check for attribute with same name
            AttributeDecl attNew =  (AttributeDecl)enumeration.nextElement();
                   
            String attName = attNew.getName();
            AttributeDecl attPrev = cType1.getAttributeDecl(attName);
            if (attPrev == null) {
                attNew.setUse(AttributeDecl.USE_OPTIONAL);
                cType1.addAttributeDecl(attNew);
            }
            else {
                String type1 = attPrev.getSimpleType().getName();
                String type2 = attNew.getSimpleType().getName();
                if (!type1.equals(type2)) {
                    String typeName = _nsPrefix + ':' +
                        DatatypeHandler.whichType(type1, type2);
                    attPrev.setSimpleTypeReference(typeName);                        }
            }
        }
       
        //-- loop through all element/attribute declarations
        //-- of e1 and if they do not exist in e2, simply
        //-- mark them as optional
        enumeration = e1Group.enumerate();
        while (enumeration.hasMoreElements()) {
            Particle particle = (Particle)enumeration.nextElement();
            if (particle.getStructureType() == Structure.ELEMENT) {
                ElementDecl element = (ElementDecl)particle;
                if (e2Group.getElementDecl(element.getName()) == null) {
                    element.setMinOccurs(0);
                }
            }
        }
       
       
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

                    if (!attribute.hasXMLType()) {
                        xsType = new XSClass(SGTypes.OBJECT);
                    }
                    break;               
                case Structure.ELEMENT:
                    ElementDecl element = (ElementDecl) component.getAnnotated();
                    if (!element.hasXMLType()) {
                        xsType = new XSClass(SGTypes.OBJECT);
                    }
                    break;
                default:
                    // probably a model-group
                    break;
                }
            }
        }

        // is the XSType found?
        if (xsType == null) {
            String className = component.getQualifiedName();
            JClass jClass = new JClass(className);
            if (component.isAbstract()) {
                jClass.getModifiers().setAbstract(true);
            }
            if (getConfig().isAutomaticConflictResolution()) {
                getSourceGenerator().getXMLInfoRegistry().bind(jClass,
                        component, "field");
            }
            xsType = new XSClass(jClass);
            if (xmlType != null && xmlType.isComplexType()) {
                ComplexType complexType = (ComplexType) xmlType;
                if (complexType.isAbstract() || getConfig().mappingSchemaElement2Java()) {
                    jClass.getModifiers().setAbstract(true);
                }
            }
            className = null;
        }

        // create the fieldInfo
        // check whether this should be a collection or not
        int maxOccurs = component.getUpperBound();
        int minOccurs = component.getLowerBound();
        if (simpleTypeCollection
                || ((maxOccurs < 0 || maxOccurs > 1) && !this.isChoice(component))) {
            String vName = memberName + "List";

            // if xmlName is null it means that
            // we are processing a container object (group)
            // so we need to adjust the name of the members of the collection
            CollectionInfo cInfo;
            cInfo = this.getInfoFactory().createCollection(xsType, vName, memberName,
                                                       component.getCollectionType(), getJavaNaming(), useJava50);

            XSListType xsList = cInfo.getXSList();
            if (!simpleTypeCollection) {
                xsList.setMaximumSize(maxOccurs);
                xsList.setMinimumSize(minOccurs);
            } else {
                if (xsList instanceof XSList) {
                    ((XSList) xsList).setDerivedFromXSList(true);
                }
            }
            fieldInfo = cInfo;
        } else  {
            switch (xsType.getType()) {
                case XSType.ID_TYPE:
                     fieldInfo = this.getInfoFactory().createIdentity(memberName);
                     break;
                case XSType.COLLECTION:
                case XSType.IDREFS_TYPE:
                case XSType.NMTOKENS_TYPE:
                    String collectionName = component.getCollectionType();
                    XSType contentType = ((XSListType) xsType).getContentType();
                    fieldInfo = this.getInfoFactory().createCollection(contentType,
                                                                   memberName, memberName,
                                                                   collectionName, getJavaNaming(), useJava50);
                    break;
                default:
                    fieldInfo = this.getInfoFactory().createFieldInfo(xsType, memberName);
                    break;
            }
        }

        // initialize the field
        XMLInfoNature xmlNature = new XMLInfoNature(fieldInfo);
        xmlNature.setNodeName(xmlName);
        xmlNature.setRequired(minOccurs > 0);
        switch (component.getAnnotated().getStructureType()) {
            case Structure.ELEMENT:
                xmlNature.setNodeType(NodeType.ELEMENT);
                 break;
            case Structure.ATTRIBUTE:
                xmlNature.setNodeType(NodeType.ATTRIBUTE);
                break;
            case Structure.MODELGROUP:
            case Structure.GROUP:
                xmlNature.setNodeName(XMLInfo.CHOICE_NODE_NAME_ERROR_INDICATION);
                fieldInfo.setContainer(true);
                break;
            default:
                break;
        }

        //-- handle namespace URI / prefix
        String nsURI = component.getTargetNamespace();
        if ((nsURI != null) && (nsURI.length() > 0)) {
            xmlNature.setNamespaceURI(nsURI);
            // TODO set the prefix used in the XML Schema
            //      in order to use it inside the Marshaling Framework
        }

        // handle default value (if any is set)
        handleDefaultValue(component, classInfo, xsType, fieldInfo, enumeration);

        //-- handle nillable values
        if (component.isNillable()) {
            fieldInfo.setNillable(true);
        }

        //-- add annotated comments
        String comment = createComment(component.getAnnotated());
        if (comment != null) {
             fieldInfo.setComment(comment);
        }

        //--specific field handler or validator?
        if (component.getXMLFieldHandler() != null) {
            fieldInfo.setXMLFieldHandler(component.getXMLFieldHandler());
        }

        if (component.getValidator() != null) {
            fieldInfo.setValidator(component.getValidator());
        }

        if (component.getVisiblity() != null) {
            String visibility = component.getVisiblity();
            fieldInfo.setVisibility(visibility);
        }
       
        // deal with substitution groups
        switch (component.getAnnotated().getStructureType()) {
        case Structure.ELEMENT:
            ElementDecl elementDeclaration = (ElementDecl) component.getAnnotated();
            if (elementDeclaration.isReference()) {
                elementDeclaration = elementDeclaration.getReference();
            }
            Enumeration<ElementDecl> possibleSubstitutes = elementDeclaration.getSubstitutionGroupMembers();
            if (possibleSubstitutes.hasMoreElements()) {
                List<String> substitutionGroupMembers = new ArrayList<String>();
                while (possibleSubstitutes.hasMoreElements()) {
                    ElementDecl substitute = possibleSubstitutes.nextElement();
                    substitutionGroupMembers.add(substitute.getName());
                }
                fieldInfo.setSubstitutionGroupMembers(substitutionGroupMembers);
            }
        default:
        }
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

                }
                //-- use targetNamespace of schema
                break;
            case Structure.ELEMENT:
                //--resolve reference?
                ElementDecl element = (ElementDecl) _annotated;
                if (element.isReference()) {
                    element = element.getReference();
                }

                schema = element.getSchema();
                //-- top-level (use targetNamespace of schema)
                if (element.getParent() == schema) {
                    break;
                }

                //-- check form (qualified or unqualified)
                form = element.getForm();
                if (form == null) {
                    form = schema.getElementFormDefault();
                }

                //-- no targetNamespace by default
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

                _schema = attribute.getSchema();
                attribute = null;
                break;
            case Structure.ELEMENT:
                //--resolve reference?
                ElementDecl element = (ElementDecl) _annotated;
                if (element.isReference()) {
                    element = element.getReference();
                }
                _schema = element.getSchema();
                element = null;
                break;
            case Structure.COMPLEX_TYPE:
                _schema = ((ComplexType) _annotated).getSchema();
                break;
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

        //-- ** Generate code for all TOP-LEVEL structures **

        //-- register all global element names for name conflict resolution
        for (Enumeration<ElementDecl> structures = schema.getElementDecls(); structures.hasMoreElements(); ) {
            ElementDecl element = structures.nextElement();
            _xmlInfoRegistry.prebindGlobalElement(XPathHelper.getSchemaLocation(element));
        }
        for (Enumeration<ModelGroup> structures = schema.getModelGroups(); structures.hasMoreElements(); ) {
            ModelGroup modelGroup = structures.nextElement();
            _xmlInfoRegistry.prebindGlobalElement(XPathHelper.getSchemaLocation(modelGroup));
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

        while (enumeration.hasMoreElements()) {
            Structure struct = enumeration.nextElement();
            switch(struct.getStructureType()) {
                case Structure.ELEMENT:
                    ElementDecl eDecl = (ElementDecl) struct;
                    if (eDecl.isReference()) {
                        continue;
                    }
                    createClasses(eDecl, sInfo);
                    break;
                case Structure.GROUP:
View Full Code Here

Examples of org.exolab.castor.xml.schema.ElementDecl

            }

            if (result == null || result.length() <= 0) {
                //--is there a reference?
                if (_annotated != null && _annotated.getStructureType() == Structure.ELEMENT) {
                    ElementDecl element = (ElementDecl) _annotated;
                    if (element.isReference()) {
                        Annotated temp = _annotated;
                        setView(element.getReference());
                        result = getJavaClassName();
                        setView(temp);
                        temp = null;
                    } else if (_config.mappingSchemaType2Java()) {
                        // deal with (global) element declarations in type mode,
                        // where no Java class will be generated per definition;
                        // in this case, the class name to be used should be taken from the
                        // underlying (complex) type
                        XMLType xmlType = element.getType();
                        if (xmlType != null && xmlType.isComplexType()) {
                            ComplexType complexType = (ComplexType) xmlType;
                            Annotated temp = _annotated;
                            setView(complexType);
                            result = getJavaClassName();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.