Package org.exolab.castor.xml.schema

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


       // finish converting content of the element

       // start attributes convertion
       Enumeration dtdAttributes = dtdElement.getAttributes();
       Attribute dtdAttribute;
       AttributeDecl schemaAttribute;

       while (dtdAttributes.hasMoreElements()) {
          dtdAttribute = (Attribute)dtdAttributes.nextElement();
          schemaAttribute = convertAttribute(dtdAttribute, schema);
          complexType.addAttributeDecl(schemaAttribute);
View Full Code Here


     */
    public static AttributeDecl convertAttribute(Attribute dtdAttribute,
                                                 Schema schema)
                                                 throws DTDException {

       AttributeDecl schemaAttribute = new AttributeDecl(schema,
                                                         dtdAttribute.getName());

       SimpleType type = null;

       if (dtdAttribute.isStringType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.STRING_TYPE) );
       }
       else if (dtdAttribute.isIDType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ID_TYPE) );
       }
       else if (dtdAttribute.isIDREFType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.IDREF_TYPE) );
       }
       else if (dtdAttribute.isIDREFSType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.IDREFS_TYPE) );
       }
       else if (dtdAttribute.isENTITYType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ENTITY_TYPE) );
       }
      
       else if (dtdAttribute.isENTITIESType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ENTITIES_TYPE) );
       }
       else if (dtdAttribute.isNMTOKENType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKEN_TYPE) );
       }
       else if (dtdAttribute.isNMTOKENSType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKENS_TYPE) );
       }
       else if (dtdAttribute.isNOTATIONType())
       {
          type = schema.createSimpleType(null,
                            schema.getBuiltInTypeName(SimpleTypesFactory.NOTATION_TYPE),
                                                                        "restriction");
           Iterator values = dtdAttribute.getValues();
           FacetFactory facetFactory = FacetFactory.getInstance();
           while (values.hasNext()) {
            Facet facet = facetFactory.createFacet(
                       Facet.ENUMERATION, (String) values.next());
            facet.setOwningType(type);
            type.addFacet(facet);
           }

       }
       else if (dtdAttribute.isEnumerationType())
       {
          type = schema.createSimpleType(null,
                            schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKEN_TYPE),
                                                                        "restriction");
          Iterator values = dtdAttribute.getValues();
          FacetFactory facetFactory = FacetFactory.getInstance();
          while (values.hasNext()) {
            Facet facet = facetFactory.createFacet(
                     Facet.ENUMERATION, (String)values.next());
            facet.setOwningType(type);
            type.addFacet(facet);
          }
       }
       else
       {
          String err = "DTD to Schema converter: DTD attribute \"" + dtdAttribute.getName();
          err += "\" has unspecified type.";
          throw new DTDException(err);
       }

       schemaAttribute.setSimpleType(type);

       if (dtdAttribute.isREQUIRED()) {

          schemaAttribute.setUse(AttributeDecl.USE_REQUIRED);

       } else if (dtdAttribute.isIMPLIED()) {

          schemaAttribute.setUse(AttributeDecl.USE_OPTIONAL);

       } else if (dtdAttribute.isFIXED()) {


       } else { // DTD attribute is of "DEFAULT" type
          schemaAttribute.setDefaultValue(dtdAttribute.getDefaultValue());
       }

       return schemaAttribute;
    } //-- convertAttribute
View Full Code Here

            }
        }

        //-- attribute declarations
        else if (SchemaNames.ATTRIBUTE.equals(name)) {
            AttributeDecl attrDecl =
                ((AttributeUnmarshaller)unmarshaller).getAttribute();

            _complexType.addAttributeDecl(attrDecl);
        }
        //-- attribute groups
View Full Code Here

                throw new IllegalArgumentException(e.getMessage());
            }
        }
    //-- attribute
    else if (SchemaNames.ATTRIBUTE.equals(name)) {
            AttributeDecl attrDecl =
                ((AttributeUnmarshaller)unmarshaller).getAttribute();

             /* TODO: do the validation later*/
            _complexType.addAttributeDecl(attrDecl);
        }
View Full Code Here

        }
        //Note: the attributes are added to the complexType
        //since a simpleType does not contain attributes at all
        //-- attribute
    else if (SchemaNames.ATTRIBUTE.equals(name)) {
            AttributeDecl attrDecl =
                ((AttributeUnmarshaller)unmarshaller).getAttribute();

      /* TODO add the validation code later*/

      /*ComplexType baseType = (ComplexType)_complexType.getBaseType();
View Full Code Here

                throw new IllegalArgumentException(e.getMessage());
            }
        }
        //-- attribute declarations
        if (SchemaNames.ATTRIBUTE.equals(name)) {
            AttributeDecl attrDecl =
                ((AttributeUnmarshaller)unmarshaller).getAttribute();

            _complexType.addAttributeDecl(attrDecl);
        }
        //-- attribute groups
View Full Code Here

        }

        //-- process all top level attribute declarations
        enumeration = schema.getAttributes();
        while (enumeration.hasMoreElements()) {
          AttributeDecl temp = (AttributeDecl) 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.getAttribute(temp.getName())!= null);
          }
         
          if (!found)
                processAttribute(temp,schemaPrefix);
        }

        //-- process all top level element declarations
        enumeration = schema.getElementDecls();
        while (enumeration.hasMoreElements()) {
          ElementDecl temp = (ElementDecl) 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.getElementDecl(temp.getName())!= null);
          }
         
          if (!found)
              processElement(temp,schemaPrefix);
        }

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

            final AttributeSet atts)
    {
        super(schemaContext);
        this._schema = schema;

        _attribute = new AttributeDecl(schema);

        //--@ref
        String attValue = atts.getValue(SchemaNames.REF_ATTR);
        if (attValue != null) {
            _attribute.setReference(attValue);
View Full Code Here

        }


        //-- attribute declarations
        else if (SchemaNames.ATTRIBUTE.equals(name)) {
            AttributeDecl attrDecl =
                ((AttributeUnmarshaller)unmarshaller).getAttribute();

            ((AttributeGroupDecl)_attributeGroup).addAttribute(attrDecl);
        }
        //-- attribute group references
View Full Code Here

                if (elem.isReference()) {
                    return createComment(elem.getReference());
                }
                break;
            case Structure.ATTRIBUTE:
                AttributeDecl att = (AttributeDecl) annotated;
                if (att.isReference()) {
                    return createComment(att.getReference());
                }
                break;
            default:
                break;
        }
View Full Code Here

TOP

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

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.