Package org.exolab.castor.xml.schema

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


                return ((ElementDecl) annotated).getMinOccurs();
            case Structure.COMPLEX_TYPE:
                return ((ComplexType) annotated).getMinOccurs();
            case Structure.MODELGROUP:
            case Structure.GROUP:
                Group group = (Group) annotated;
                //-- if the group is top-level, then we always return 0
                Structure parent = group.getParent();
                if (parent != null && parent.getStructureType() == Structure.SCHEMA) {
                    return 0;
                }
                int minOccurs = group.getMinOccurs();
                //-- if minOccurs == 1, then check to see if all elements inside group are
                //-- optional, if so, we return 0, not 1.
                if (minOccurs == 1) {
                    Enumeration<Annotated> enumeration = group.enumerate();
                    while (enumeration.hasMoreElements()) {
                        if (getLowerBound(enumeration.nextElement()) != 0) {
                            return 1;
                        }
                    }
View Full Code Here


            ElementDecl element = (ElementDecl) annotated;
            String typexPath = XPathHelper.getSchemaLocation(element.getType());
            xPath += "[" + typexPath  + "]";
            typedLocalName += "[" + typexPath  + "]";
        } else if (annotated instanceof Group) {
            Group group = (Group) annotated;
            if (group.getOrder() == Order.choice
                    && !_globalElements.contains("/" + localXPath)) {
                xPath += "/#choice";
            }
        }
       
        ExtendedBinding binding = component.getBinding();
        if (binding != null) {
            // deal with explicit exclusions
            if (binding.existsExclusion(typedLocalName)) {
                Exclude exclusion = binding.getExclusion(typedLocalName);
                if (exclusion.getClassName() != null) {
                    LOG.info("Dealing with exclusion for local element " + xPath
                            + " as per binding file.");
                    jClass.changeLocalName(exclusion.getClassName());
                }
                return;
            }

            // deal with explicit forces
            if (binding.existsForce(localName)) {

                List<String> localNamesList = _localNames.get(localName);
                memorizeCollision(xPath, localName, localNamesList);

                LOG.info("Changing class name for local element " + xPath
                        + " as per binding file (force).");
                checkAndChange(jClass, annotated, untypedXPath, typedLocalName);
                return;
            }
        }
               
       
        String jClassLocalName = jClass.getLocalName();
        String expectedClassNameDerivedFromXPath = _javaNaming.toJavaClassName(localName);
        if (!jClassLocalName.equals(expectedClassNameDerivedFromXPath)) {
            if (component.createGroupItem()) {
                xPath += "/#item";
            }
            _xpathToJClass.put(xPath, jClass);
            return;
        }

        if (mode.equals("field")) {
            if (annotated instanceof ModelGroup) {
                ModelGroup group = (ModelGroup) annotated;
                final boolean isReference = group.isReference();
                if (isReference) {
                    return;
                }
            }
               
View Full Code Here

        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);
        subgroup.setMaxOccurs(Particle.UNBOUNDED);
        group.addGroup(subgroup);

        // create an element for choice
        ElementDecl elem = new ElementDecl(_schema);
        elem.setName("myStringType");
        elem.setTypeReference("string");
        subgroup.addElementDecl(elem);

        elem = new ElementDecl(_schema);
        elem.setName("myStringType2");
        elem.setTypeReference("string");
        group.addElementDecl(elem);
View Full Code Here

        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);
        subgroup.setMaxOccurs(Particle.UNBOUNDED);
        group.addGroup(subgroup);

        // create an element for choice
        ElementDecl elem = new ElementDecl(_schema);
        elem.setName("myStringType");
        elem.setTypeReference("string");
        subgroup.addElementDecl(elem);

        // create a choice element for sequence element
        subgroup = new Group();
        subgroup.setOrder(Order.choice);
        subgroup.setMinOccurs(0);
        subgroup.setMaxOccurs(Particle.UNBOUNDED);
        group.addGroup(subgroup);

        // create an element for choice
        elem = new ElementDecl(_schema);
        elem.setName("myStringType2");
        elem.setTypeReference("string");
        subgroup.addElementDecl(elem);
        // compare
        TestResult result = doTest("group_2subgroups.xsd");
        assertEquals("single attribute test failed", TestResult.IDENTICAL,
                result);
    }
View Full Code Here

    }

    private boolean processSchemaGroup(final XMLBindingComponent component,
                                       final FactoryState state, final ClassInfo classInfo) {
        try {
            Group group = (Group) component.getAnnotated();
            processContentModel(group, state);
            component.setView(group);

            //-- Check Group Type
            Order order = group.getOrder();
            GroupInfo groupInfo = new XMLInfoNature(classInfo).getGroupInfo();
            if (order == Order.choice) {
                groupInfo.setAsChoice();
            } else if (order == Order.sequence) {
                groupInfo.setAsSequence();
            } else {
                groupInfo.setAsAll();
            }

            return group.getMaxOccurs() == 1;
        } catch (ClassCastException ce) {
            //--Should not happen
            throw new IllegalArgumentException("Illegal binding component: " + ce.getMessage());
        }
    }
View Full Code Here

            //-- 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();
                    }
                }
            }
            Annotated saved = component.getAnnotated();
View Full Code Here

                    }

                    handleField(fieldInfo, state, component);
                    break;
                case Structure.GROUP: //-- handle groups
                    Group group = (Group) annotated;
                    //set the compositor
                    if ((contentModel instanceof ComplexType)
                            || (contentModel instanceof ModelGroup)) {
                        if (group.getOrder() == Order.choice) {
                            new XMLInfoNature(state.getClassInfo()).getGroupInfo().setAsChoice();
                        } else if (group.getOrder() == Order.all) {
                            new XMLInfoNature(state.getClassInfo()).getGroupInfo().setAsAll();
                        } else if (group.getOrder() == Order.sequence) {
                            new XMLInfoNature(state.getClassInfo()).getGroupInfo().setAsSequence();
                        }
                    }

                    //-- create class member,if necessary
View Full Code Here

        // 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);

        // compare
        TestResult result = doTest("complextype_singleattribute.xsd");
        assertEquals("single attribute test failed", TestResult.IDENTICAL,
                result);
View Full Code Here

        // 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);

        ElementDecl e2 = new ElementDecl(_schema);
        e2.setName("myAttr2");
        group.addElementDecl(e2);

        ElementDecl e3 = new ElementDecl(_schema);
        e3.setName("myAttr3");
        group.addElementDecl(e3);

        // compare
        TestResult result = doTest("complextype_sequenceattribute.xsd");
        assertEquals("sequence multiple attributes test failed",
                TestResult.IDENTICAL, result);
View Full Code Here

        // 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);

        ElementDecl e2 = new ElementDecl(_schema);
        e2.setName("myAttr2");
        group.addElementDecl(e2);

        ElementDecl e3 = new ElementDecl(_schema);
        e3.setName("myAttr3");
        group.addElementDecl(e3);

        // compare
        TestResult result = doTest("complextype_allorder.xsd");
        assertEquals("all order attributes test failed", TestResult.IDENTICAL,
                result);
View Full Code Here

TOP

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

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.