Package org.exolab.castor.xml.schema

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


            XMLType baseType= _schema.getType(base);
            if (baseType == null) {
                _complexType.setBase(base); //the base type has not been read
                if (_complexType.isSimpleContent()) {
                    _complexType.setContentType(new SimpleContent(_schema, base));
                }
            }
        else {
         //--we cannot extend a simpleType in <complexContent>
         if ( (baseType.isSimpleType()) &&
            (_complexType.isComplexContent()) ) {
          String err = "In a 'complexContent', the base attribute "+
                    "must be a complexType but "+ base+" is a simpleType.\n";
                    error(err);
         }
         _complexType.setBase(base);
                 _complexType.setBaseType(baseType);
                if (_complexType.isSimpleContent()) {
                    //--set the content type
                    if (baseType.isSimpleType()) {
                        SimpleType simpleType = (SimpleType)baseType;
                      _complexType.setContentType(new SimpleContent(simpleType));
                    }
                    else {
                        ComplexType temp = (ComplexType)baseType;
                        SimpleContent simpleContent = (SimpleContent) temp.getContentType();
                        _complexType.setContentType(simpleContent.copy());
                    }
                }
                  
        }
View Full Code Here


        if ((base != null) && (base.length() > 0)) {

            XMLType baseType= _schema.getType(base);
            if (baseType == null) {
                _complexType.setBase(base);
                _complexType.setContentType(new SimpleContent(_schema, base));
            }
            else if (baseType.isSimpleType()) {
                String err ="complexType: ";
                String name = _complexType.getName();
                if (name != null) {
                    err += name;
                } else {
                    err += "#anonymous-complexType#";
                }
               
                err += "A complex type cannot be a restriction"+
                    " of a simpleType:";
                err += baseType.getName();
                throw new IllegalStateException(err);
            }
      //we are now sure that the base is a ComplexType
            //but is the base of this complexType a simpleType? (see 4.3.3->simpleContent->content type)
            else {
                ComplexType temp = (ComplexType) baseType;
               
                if ( ! temp.isSimpleContent() ) {
                    // UPO - base type may have complex content if
                    // 1. content model is emptiable
                    // 2. it has mixed content
                    // See bug report http://jira.codehaus.org/browse/CASTOR-1238
                    if ( (temp.getContentType().getType() == ContentType.MIXED&&  temp.isEmptiable() ) {
                      // OK
                    }
                    else {
                      String err ="complexType: ";
                      String name = _complexType.getName();
                      if (name != null) {
                          err += name;
                      } else {
                          err += "#anonymous-complexType#";
                      }
                   
                      err += ": In a simpleContent when using restriction the base type"+
                          " must be a complexType with a simple content model or it must" +
                          " be a complex content model which is mixed and emptiable.";
                      throw new IllegalStateException(err);
                    }
                }
                else {
            //retrieve the base type of this complexType
                    //the base type is the complexType but we have to
                    //work with the simple type of the content type.
                    SimpleContent contentType = (SimpleContent)temp.getContentType();
                    _complexType.setBaseType(temp);
                    _complexType.setBase(temp.getName());
              _simpleTypeDef = new SimpleTypeDefinition(_schema, temp.getName(),_id);
              SimpleType simpleType = contentType.getSimpleType();
              if (simpleType != null) {
                        _simpleTypeDef.setBaseType(simpleType);
                    }
                    else {
                        _simpleTypeDef.setBaseTypeName(contentType.getTypeName());
                    }
                }
            }
    }
View Full Code Here

               error("A 'facet', as a child of 'restriction' "+
                    "elements, must appear before any attribute elements.");

      unmarshaller = new FacetUnmarshaller(getSchemaContext(), name, atts);
      if (_simpleTypeDef == null) {
          SimpleContent content = (SimpleContent)_complexType.getContentType();
          _simpleTypeDef = new SimpleTypeDefinition(_schema, content.getTypeName(),_id);
      }
        }
        else if (SchemaNames.ATTRIBUTE.equals(name)) {
             foundAttribute = true;
             unmarshaller = new AttributeUnmarshaller(getSchemaContext(), _schema, atts);
View Full Code Here

            _complexType.addAttributeGroupReference(attrGroupRef);
        }
        //-- simpleType
    else if (SchemaNames.SIMPLE_TYPE.equals(name)) {
            SimpleType type = (SimpleType) unmarshaller.getObject();
            _complexType.setContentType(new SimpleContent(type));
        }
        //--facet
    else {
           _simpleTypeDef.addFacet((Facet)unmarshaller.getObject());
           foundFacets = true;
View Full Code Here

     */
    public void finish() {

        if (_simpleTypeDef != null) {
            SimpleType baseType = _simpleTypeDef.createSimpleType();
            _complexType.setContentType(new SimpleContent(baseType));
        }
    //the restriction was properly handle
    //we can set the flag
    _complexType.setRestriction(true);
    }
View Full Code Here

            _handler.startElement(ELEM_DERIVATION, _atts);
            //--Any Facets to process?
            //--only relevant for the simpleContent with restriction
            if (complexType.isSimpleContent() && complexType.isRestricted()) {
                if (complexType.getContentType().getType() == ContentType.SIMPLE) {
                    SimpleContent simpleContent = (SimpleContent)complexType.getContentType();
                    SimpleType simpleType = simpleContent.getSimpleType();
                    //-- process facets
                    Enumeration enumeration = simpleType.getLocalFacets();
                    while (enumeration.hasMoreElements()) {
                        Facet facet = (Facet) enumeration.nextElement();
                        _atts.clear();
View Full Code Here

                        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());
                            handleField(fieldInfo, state, component);
View Full Code Here

                state.getJClass().setSuperClass(baseClassName);
            } //--complexType

            //--if the content type is a simpleType create a field info for it.
            if (complexType.getContentType().getType() == ContentType.SIMPLE) {
                SimpleContent simpleContent = (SimpleContent) complexType.getContentType();
                SimpleType temp = simpleContent.getSimpleType();
                SimpleType baseType = (SimpleType) temp.getBaseType();
                XSType xsType = _typeConversion.convertType(
                        temp, state.getPackageName(), getConfig().useJava50());

                FieldInfo fieldInfo = null;
View Full Code Here

        if ((base != null) && (base.length() > 0)) {

            XMLType baseType= _schema.getType(base);
            if (baseType == null) {
                _complexType.setBase(base);
                _complexType.setContentType(new SimpleContent(_schema, base));
            }
            else if (baseType.isSimpleType()) {
                String err ="complexType: ";
                String name = _complexType.getName();
                if (name != null) {
                    err += name;
                } else {
                    err += "#anonymous-complexType#";
                }
               
                err += "A complex type cannot be a restriction"+
                    " of a simpleType:";
                err += baseType.getName();
                throw new IllegalStateException(err);
            }
      //we are now sure that the base is a ComplexType
            //but is the base of this complexType a simpleType? (see 4.3.3->simpleContent->content type)
            else {
                ComplexType temp = (ComplexType) baseType;
               
                if ( ! temp.isSimpleContent() ) {
                    String err ="complexType: ";
                    String name = _complexType.getName();
                    if (name != null) {
                        err += name;
                    } else {
                        err += "#anonymous-complexType#";
                    }
                   
                    err += "In a simpleContent when using restriction the base type"+
                        " must be a complexType whose base is a simpleType.";
                    throw new IllegalStateException(err);
                }
                else {
            //retrieve the base type of this complexType
                    //the base type is the complexType but we have to
                    //work with the simple type of the content type.
                    SimpleContent contentType = (SimpleContent)temp.getContentType();
                    _complexType.setBaseType(temp);
                    _complexType.setBase(temp.getName());
              _simpleTypeDef = new SimpleTypeDefinition(_schema, temp.getName(),_id);
              SimpleType simpleType = contentType.getSimpleType();
              if (simpleType != null) {
                        _simpleTypeDef.setBaseType(simpleType);
                    }
                    else {
                        _simpleTypeDef.setBaseTypeName(contentType.getTypeName());
                    }
                }
            }
    }
View Full Code Here

               error("A 'facet', as a child of 'restriction' "+
                    "elements, must appear before any attribute elements.");

      unmarshaller = new FacetUnmarshaller(name, atts);
      if (_simpleTypeDef == null) {
          SimpleContent content = (SimpleContent)_complexType.getContentType();
          _simpleTypeDef = new SimpleTypeDefinition(_schema, content.getTypeName(),_id);
      }
        }
        else if (SchemaNames.ATTRIBUTE.equals(name)) {
             foundAttribute = true;
             unmarshaller = new AttributeUnmarshaller(_schema,atts, getResolver());
View Full Code Here

TOP

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

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.