Package org.exolab.castor.xml.schema

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


        }

        //-- process all top level complex types
        enumeration = schema.getComplexTypes();
        while (enumeration.hasMoreElements()) {
            ComplexType temp = (ComplexType) enumeration.nextElement();
            boolean found = false;
            //--check if this attributeGroup is not
            //-- included
            Enumeration includedSchemas = schema.getCachedIncludedSchemas();
            while (includedSchemas.hasMoreElements()) {
              Schema tempSchema = (Schema)includedSchemas.nextElement();
              found = (tempSchema.getComplexType(temp.getName())!= null);
            }
            if (!temp.isRedefined() && !found)
                processComplexType(temp, schemaPrefix);
        }

        //-- process all top level groups
        enumeration = schema.getModelGroups();
        while (enumeration.hasMoreElements()) {
          ModelGroup temp = (ModelGroup)enumeration.nextElement();
          boolean found = false;
          //--check if this Group is not
          //-- included
          Enumeration includedSchemas = schema.getCachedIncludedSchemas();
          while (includedSchemas.hasMoreElements()) {
            Schema tempSchema = (Schema)includedSchemas.nextElement();
            found = (tempSchema.getModelGroup(temp.getName())!= null);
          }
         
          if (!temp.isRedefined() && !found)
              processGroup(temp, schemaPrefix);
        }

        //-- process all top level simple types
        enumeration = schema.getSimpleTypes();
        while (enumeration.hasMoreElements()) {
            SimpleType temp = (SimpleType) enumeration.nextElement();
            boolean found = false;
            //--check if this attributeGroup is not
            //-- included
            Enumeration includedSchemas = schema.getCachedIncludedSchemas();
            while (includedSchemas.hasMoreElements()) {
              Schema tempSchema = (Schema)includedSchemas.nextElement();
              found = (tempSchema.getSimpleType(temp.getName())!= null);
            }
            if (!temp.isRedefined() && !found)
                processSimpleType(temp, schemaPrefix);
        }

        _handler.endElement(ELEM_SCHEMA);
View Full Code Here


      if (schemaLoc != "") {
        Enumeration enumeration = null;
        //--process complexTypes
          enumeration = schema.enumerateComplexTypes();
          while (enumeration.hasMoreElements()) {
            ComplexType type = (ComplexType)enumeration.nextElement();
            processComplexType(type, schemaPrefix);
          }
        //--process simpleTypes
          enumeration = schema.enumerateSimpleTypes();
          while (enumeration.hasMoreElements()) {
View Full Code Here

     * Create simple type
     */
    public void testSubgroupWithAnElement() throws Exception {

        // create targeted schema
        ComplexType ctype = _schema.createComplexType();
        ctype.setName("myType");
        _schema.addComplexType(ctype);

        // create a sequence element
        Group group = new Group();
        group.setOrder(Order.sequence);
        ctype.addGroup(group);

        // create a choice element for sequence element
        Group subgroup = new Group();
        subgroup.setOrder(Order.choice);
        subgroup.setMinOccurs(0);
View Full Code Here

     * Create simple type
     */
    public void test2Subgroups() throws Exception {

        // create targeted schema
        ComplexType ctype = _schema.createComplexType();
        ctype.setName("myType");
        _schema.addComplexType(ctype);

        // create a sequence element
        Group group = new Group();
        group.setOrder(Order.sequence);
        ctype.addGroup(group);

        // create a choice element for sequence element
        Group subgroup = new Group();
        subgroup.setOrder(Order.choice);
        subgroup.setMinOccurs(0);
View Full Code Here

                state = new FactoryState(newClassName, sgState, packageName, component);
                classInfo = state.getClassInfo();
                jClass    = state.getJClass();
                initialize(jClass);
                if (type != null && type.isComplexType()) {
                    ComplexType complexType = (ComplexType) type;
                    if (complexType.isTopLevel() ^ creatingForAnElement) {
                        //process attributes and content type since it has not be performed before
                        Annotated saved = component.getAnnotated();
                        processAttributes(component.getBinding(), complexType, state);
                        component.setView(saved);
                        if (complexType.getContentType() == ContentType.mixed) {
                            FieldInfo fieldInfo = _memberFactory.createFieldInfoForContent(
                                    component, new XSString(), getConfig().useJava50());
                            handleField(fieldInfo, state, component);
                        } else if (complexType.getContentType().getType() == ContentType.SIMPLE) {
                            SimpleContent simpleContent = (SimpleContent) complexType.getContentType();
                            SimpleType temp = simpleContent.getSimpleType();
                            XSType xsType = _typeConversion.convertType(
                                    temp, packageName, getConfig().useJava50());
                            FieldInfo fieldInfo = _memberFactory.createFieldInfoForContent(
                                    component, xsType, getConfig().useJava50());
View Full Code Here

        ClassInfo classInfo = state.getClassInfo();
        JClass    jClass    = state.getJClass();
        boolean creatingForAnElement =
            (component.getAnnotated().getStructureType() == Structure.ELEMENT);

        ComplexType complexType = (ComplexType) type;
        if (complexType.isTopLevel() && creatingForAnElement) {
             //--move the view and keep the structure
             Annotated saved = component.getAnnotated();
             String previousPackage = component.getJavaPackage();
             XMLBindingComponent baseComponent = new XMLBindingComponent(
                     getConfig(), getGroupNaming());
             baseComponent.setBinding(component.getBinding());
             baseComponent.setView(complexType);
             //-- call createSourceCode to pre-process the complexType
             createSourceCode(baseComponent, sgState);
             String baseClassName = null;
             String basePackage = baseComponent.getJavaPackage();
             //--if the base class is not in the same package
             //--of the current class then we have to qualify the base
             //--class
             if (basePackage != null && !basePackage.equals(previousPackage)) {
                 baseClassName = baseComponent.getQualifiedName();
                 if (baseClassName.indexOf('.') == -1) {
                     //--be sure it is a valid className
                     baseClassName = getJavaNaming().toJavaClassName(baseClassName);
                 }
             } else {
                 baseClassName = baseComponent.getJavaClassName();
             }
             jClass.setSuperClass(baseClassName);
             basePackage = null;
             baseClassName = null;
             component.setView(saved);
             saved = null;
        } else if (complexType.isTopLevel() || creatingForAnElement) {
            //generate class if the complexType is anonymous and we create classes
            //for an element OR if the complexType is top-level and we create
            //classes for it.

            //-- check Group type
            if (complexType.getParticleCount() == 1) {
                Particle particle = complexType.getParticle(0);
                if (particle.getStructureType() == Structure.GROUP) {
                    Group group = (Group) particle;
                    if (group.getOrder() == Order.choice) {
                        new XMLInfoNature(classInfo).getGroupInfo().setAsChoice();
                    }
View Full Code Here

                    break;
                }

                // There's a base complexType; get the attribute with the same name
                // as this attribute (=attr) from it
                final ComplexType baseComplexType = (ComplexType) baseXMLType;
                AttributeDecl baseAttribute = baseComplexType.getAttributeDecl(attr.getName());

                if (baseAttribute != null) {
                    // See if this one has a simple-type...
                    sType = baseAttribute.getSimpleType();
                    if (sType != null) {
View Full Code Here

     * @throws Exception
     */
    public void testSingleAttribute() throws Exception {
        // create targeted schema
        _schema.addNamespace("pre", "my.namespace.org");
        ComplexType cType = _schema.createComplexType("myType");
        _schema.addComplexType(cType);

        Group group = new Group();
        cType.addGroup(group);

        ElementDecl e = new ElementDecl(_schema);
        e.setName("myAttr");
        group.addElementDecl(e);

View Full Code Here

     * @throws Exception
     */
    public void testSequenceAttribute() throws Exception {
        // create targeted schema
        _schema.addNamespace("pre", "my.namespace.org");
        ComplexType cType = _schema.createComplexType("myType");
        _schema.addComplexType(cType);

        Group group = new Group();
        cType.addGroup(group);

        ElementDecl e = new ElementDecl(_schema);
        e.setName("myAttr");
        group.addElementDecl(e);

View Full Code Here

    public void testAllOrderAttribute() throws Exception {

        // TODO it seems the XMLDiff does not detect order of attributes
        // create targeted schema
        _schema.addNamespace("pre", "my.namespace.org");
        ComplexType cType = _schema.createComplexType("myType");
        _schema.addComplexType(cType);

        Group group = new Group();
        group.setOrder(Order.all);
        cType.addGroup(group);

        ElementDecl e = new ElementDecl(_schema);
        e.setName("myAttr");
        group.addElementDecl(e);
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.schema.ComplexType

Copyright © 2018 www.massapicom. 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.