Package org.exolab.castor.xml.schema

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


       ElementDecl schemaElement = new ElementDecl(schema, name);

       // start converting content of the element
       ComplexType complexType = schema.createComplexType();
       ContentType contentType = null;
       Group group = null; // auxiliary
       Iterator mixedChildrenIterator = null; // auxiliary
       String elementRef = null; // auxiliary
       ElementDecl elem = null// auxiliary

       if (dtdElement.isEmptyContent()) {

          // mixed="false"
          contentType = ContentType.elemOnly;
          //-- mixed="false"

       } else if (dtdElement.isAnyContent()) {

          // mixed="true"
          contentType = ContentType.mixed;
          //-- mixed="true"

          group = new Group();
          group.setOrder(Order.sequence);
          group.setMinOccurs(0);
          group.setMaxOccurs(-1);
          Wildcard any = new Wildcard(group);
          group.addWildcard(any);
          complexType.addGroup(group);

       } else if (dtdElement.isElemOnlyContent()) {

          // mixed="false"
          contentType = ContentType.elemOnly;
          //-- mixed="false"

          ContentParticle dtdContent = dtdElement.getContent();
          if (dtdContent == null) { // content is not specified
             String err = "DTD to Schema converter: element \"" + dtdElement.getName();
             err += "\" has no content.";
             throw new DTDException(err);
          }

          Particle content = null;
          try {
             content = convertContentParticle(dtdContent, schema);
          }
          catch (DTDException e) {
             String err = "DTD to Schema converter: content of DTD element \"" + dtdElement.getName();
             err += "\", represented by a Content Particle, is malformed.";
             throw new DTDException(err);
          }

          if (content instanceof ElementDecl) {
             group = new Group();
             group.setOrder(Order.sequence);
             group.addElementDecl((ElementDecl)content);
             complexType.addGroup(group);
          } else {
             complexType.addGroup((Group)content);
          }

       } else if (dtdElement.isMixedContent()) {

          // mixed="true"
          contentType = ContentType.mixed;
          //-- mixed="true"

          mixedChildrenIterator = dtdElement.getMixedContentChildren();
          if ((mixedChildrenIterator != null) && (mixedChildrenIterator.hasNext())) {
             group = new Group();
             group.setOrder(Order.choice);
             group.setMinOccurs(0);
             group.setMaxOccurs(-1);
             while (mixedChildrenIterator.hasNext()) {
                elementRef = (String)mixedChildrenIterator.next();
                elem = new ElementDecl(schema);
                elem.setReferenceName(elementRef);
                group.addElementDecl(elem);
             }
             complexType.addGroup(group);
          }

       } else { // the type of the element has not been specified
View Full Code Here


          elem.setReferenceName(dtdContent.getReference());
          returnValue = elem;

       } else if (dtdContent.isSeqType() || dtdContent.isChoiceType()) {

          Group group = new Group();
          if (dtdContent.isSeqType()) group.setOrder(Order.sequence);
          else group.setOrder(Order.choice);

          Enumeration children = dtdContent.getChildren();
          ContentParticle child;
          Particle contentParticle;

          while(children.hasMoreElements()) {
             child = (ContentParticle)children.nextElement();
             contentParticle = convertContentParticle(child, schema);

             if (contentParticle instanceof ElementDecl) {
                group.addElementDecl((ElementDecl)contentParticle);
             } else {
                group.addGroup((Group)contentParticle);
             }
          }

          returnValue = group;
View Full Code Here

        }

        //-- group declarations (all, choice, sequence)
        else if ( (SchemaNames.isGroupName(name)) && (name != SchemaNames.GROUP) )
        {
            Group group = ((GroupUnmarshaller)unmarshaller).getGroup();
            _complexType.addGroup(group);
        }
        //-- annotation
        else if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation ann = ((AnnotationUnmarshaller)unmarshaller).getAnnotation();
View Full Code Here

            final AttributeSet atts) {
        super(schemaContext);

        this._schema = schema;

        _group = new Group();
        //-- handle attributes
        String attValue = null;


        if (SchemaNames.SEQUENCE.equals(element)) {
View Full Code Here

            ModelGroup group = (ModelGroup) unmarshaller.getObject();
            _group.addGroup(group);
        }
        else if ( (SchemaNames.isGroupName(name)) && (name != SchemaNames.GROUP) )
        {
            Group group = ((GroupUnmarshaller)unmarshaller).getGroup();
            _group.addGroup(group);
        }

        unmarshaller = null;
    } //-- endElement
View Full Code Here

            Annotation ann = (Annotation)unmarshaller.getObject();
            _group.addAnnotation(ann);
        }

         else if (SchemaNames.isGroupName(name)) {
            Group group = ((GroupUnmarshaller)unmarshaller).getGroup();
            _group.addGroup(group);
        }

        //-- have unmarshaller perform any necessary clean up
        unmarshaller.finish();
View Full Code Here

          String err = "When redefining a group, the group must have a name.\n";
          error(err);
        }
       
        //1-- the group must exist in the imported schema
        Group original = _importedSchema.getModelGroup(structureName);
        if (original == null) {
          String err = "When redefining a group, the group must be present in the imported XML schema.\n"
            +"Group: "+structureName+" is not defined in XML Schema:" + _importedSchema.getSchemaLocation();
          error(err);
        }
View Full Code Here

                (AttributeGroupReference) unmarshaller.getObject();
            _complexType.addAttributeGroupReference(attrGroupRef);
        }
    //-- group declarations (all, choice, group, sequence)
        else if (SchemaNames.isGroupName(name)) {
            Group group = ((GroupUnmarshaller)unmarshaller).getGroup();
            _complexType.addGroup(group);
        }
        unmarshaller = null;
    } //-- endElement
View Full Code Here

        }

        //-- group declarations (all, choice, sequence)
        else if ( (SchemaNames.isGroupName(name)) && (name != SchemaNames.GROUP) )
        {
            Group group = ((GroupUnmarshaller)unmarshaller).getGroup();
            _complexType.addGroup(group);
        }
        //-- annotation
        else if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation ann = ((AnnotationUnmarshaller)unmarshaller).getAnnotation();
View Full Code Here

                    result = true;
                }
                break;
            case Structure.MODELGROUP:
            case Structure.GROUP:
                Group group = (Group) _annotated;
                maxOccurs = group.getMaxOccurs();
                if ((maxOccurs > 1) || (maxOccurs < 0)) {
                    result = true;
                }
                break;
            case Structure.ATTRIBUTE:
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.