Package org.eclipse.xsd

Examples of org.eclipse.xsd.XSDSimpleTypeDefinition


    assertEquals(uri, loaded.getURI());
  }

  public void testDateTime() {
    String uri = BuiltinDataTypes.TYPE_DATETIME;
    XSDSimpleTypeDefinition loaded = BuiltinDataTypes.getTypeDateTime();
   
    assertNotNull(uri);
    assertNotNull(loaded);
    assertEquals(uri, loaded.getURI());
  }
View Full Code Here


  /**
   * Make sure that we can fail.
   */
  public void testWeCanFail() {
    String uri = BuiltinDataTypes.TYPE_INTEGER;
    XSDSimpleTypeDefinition loaded = BuiltinDataTypes.getTypeString();
   
    assertNotNull(uri);
    assertNotNull(loaded);
    assertFalse(uri.equals(loaded.getURI()));
  }
View Full Code Here

                                            generatePrefix());
            if ( aProperty.getType().isDataType() )
            {
                typeTable.addSimpleSchemaType(aProperty.getType().getName(), attributeSchemaType);
               
                XSDSimpleTypeDefinition simpleType = xsdFactory.createXSDSimpleTypeDefinition();
                simpleType.setName(aProperty.getType().getName());
                simpleType.setTargetNamespace(aProperty.getType().getURI());
                typeTable.addXSDTypeDef(attributeSchemaType.getNamespaceURI(),
                                        attributeSchemaType.getLocalPart(),
                                        simpleType);
            }
            else
View Full Code Here

                                            generatePrefix());
            if ( aProperty.getType().isDataType() )
            {
                typeTable.addSimpleSchemaType(aProperty.getType().getName(), elementSchemaType);
               
                XSDSimpleTypeDefinition simpleType = xsdFactory.createXSDSimpleTypeDefinition();
                simpleType.setName(aProperty.getType().getName());
                simpleType.setTargetNamespace(aProperty.getType().getURI());
                typeTable.addXSDTypeDef(elementSchemaType.getNamespaceURI(),
                                        elementSchemaType.getLocalPart(),
                                        simpleType);
            }
            else
View Full Code Here

        QName simpleSchemaTypeName = null;
        if ( dataType.isDataType() &&
                (simpleSchemaTypeName = typeTable.getSimpleSchemaTypeName(dataType.getName()) ) == null )
        {
            XSDSchema xmlSchema = getXmlSchema(dataType);
            XSDSimpleTypeDefinition simpleType = xsdFactory.createXSDSimpleTypeDefinition();
            //set the name
            simpleType.setName(dataType.getName());
            simpleType.setTargetNamespace(dataType.getURI());
            //set abstract=true if abstract
            simpleSchemaTypeName = new QName(dataType.getURI(),
                                             dataType.getName(),
                                             (String)targetNamespacePrefixMap.get(dataType.getURI()));
            xmlSchema.getContents().add(simpleType);
            simpleType.updateElement();
           
            addAnnotations(simpleType, dataType);
           
            if ( !dataType.getBaseTypes().isEmpty() )
            {
                Type baseType = (Type)dataType.getBaseTypes().get(0);
               
                QName baseSchemaType = null;
               
                try
                {
                    baseSchemaType = buildSchema(baseType);
                }
                catch ( IllegalArgumentException e )
                {
                    //this means that the base type comes from a original xsd and hence not generated
                    baseSchemaType = new QName(baseType.getURI(),
                                                baseType.getName(),
                                                generatePrefix());
                   
                    typeTable.addSimpleSchemaType(baseType.getName(), baseSchemaType);

                    XSDSimpleTypeDefinition baseTypeDef = xsdFactory.createXSDSimpleTypeDefinition();
                    baseTypeDef.setName(baseType.getName());
                    baseTypeDef.setTargetNamespace(baseType.getURI());
                    typeTable.addXSDTypeDef(baseType.getURI(), baseType.getName(), baseTypeDef);
                       
                    //include external XSD locations
                    includeExtXSD(baseType);
                }
View Full Code Here

                //so include that original XSD
                baseSchemaType = new QName(baseType.getURI(),
                                            baseType.getName(),
                                            generatePrefix());
               
                XSDSimpleTypeDefinition baseTypeDef = xsdFactory.createXSDSimpleTypeDefinition();
                baseTypeDef.setName(baseType.getName());
                baseTypeDef.setTargetNamespace(baseType.getURI());
                typeTable.addXSDTypeDef(baseType.getURI(), baseType.getName(), baseTypeDef);
               
                includeExtXSD(baseType);
            }
           
            complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
           
            if ( baseType.isDataType() )
            {
                XSDSimpleTypeDefinition anonymousSimpleTypeDefinition
                    = xsdFactory.createXSDSimpleTypeDefinition();
                anonymousSimpleTypeDefinition.setBaseTypeDefinition((XSDSimpleTypeDefinition)typeTable.
                        getXSDTypeDef(baseSchemaType.getNamespaceURI(),baseSchemaType.getLocalPart()));
                complexType.setContent(anonymousSimpleTypeDefinition);
            }
            else
            {
View Full Code Here

      {
        return eEnum;
      }
      else
      {
        XSDSimpleTypeDefinition baseTypeDefinition = xsdSimpleTypeDefinition.getBaseTypeDefinition();
        if (baseTypeDefinition != null)
        {
          EDataType eDataType = ecoreFactory.createEDataType();
          setAnnotations(eDataType, xsdSimpleTypeDefinition);

          String name = getEcoreAttribute(xsdSimpleTypeDefinition, "name");
          if (name == null)
          {
            name = validAliasName(xsdSimpleTypeDefinition, true);
          }

          eDataType.setName(name);
          extendedMetaData.setName(eDataType, xsdSimpleTypeDefinition.getAliasName());

          EPackage ePackage = getEPackage(xsdSimpleTypeDefinition);
          addToSortedList(ePackage.getEClassifiers(), eDataType);

          if (baseTypeDefinition.getVariety() != xsdSimpleTypeDefinition.getVariety())
          {
            if (xsdSimpleTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
            {
              EDataType itemEDataType = getEDataType(xsdSimpleTypeDefinition.getItemTypeDefinition());
              extendedMetaData.setItemType(eDataType, itemEDataType);
              eDataType.setInstanceClassName("java.util.List");
            }
            else
            {
              String instanceClassName = null;
              List memberTypes = new ArrayList();
              for (Iterator i = xsdSimpleTypeDefinition.getMemberTypeDefinitions().iterator(); i.hasNext(); )
              {
                XSDSimpleTypeDefinition memberTypeDefinition = (XSDSimpleTypeDefinition)i.next();
                EDataType memberEDataType = getEDataType(memberTypeDefinition);
                memberTypes.add(memberEDataType);
                String memberInstanceClassName = memberEDataType.getInstanceClassName();
                if (memberInstanceClassName == null && memberEDataType instanceof EEnum)
                {
View Full Code Here

             xsdComplexTypeContent,
             false);
        }
        else
        {
          XSDSimpleTypeDefinition xsdSimpleTypeDefinition = xsdComplexTypeDefinition.getSimpleType();
          getEClassifier(xsdSimpleTypeDefinition);
        }
      }
    }
    else
View Full Code Here

    {
      EClassifier referenceClassifier = getEClassifier(referenceType);
      boolean needsHolder = false;
      if (elementTypeDefinition instanceof XSDSimpleTypeDefinition)
      {
        XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition)elementTypeDefinition;
        if (xsdSimpleTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
        {
          needsHolder = true;
         
          EPackage holderPackage = getEPackage(xsdElementDeclaration);
          String holderName = xsdElementDeclaration.getName() + ":holder";
View Full Code Here

  }

  protected EStructuralFeature createFeature
    (EClass eClass, XSDAttributeDeclaration xsdAttributeDeclaration, String name, XSDComponent xsdComponent, boolean isRequired)
  {
    XSDSimpleTypeDefinition attributeTypeDefinition = (XSDSimpleTypeDefinition)getEffectiveTypeDefinition(xsdComponent, xsdAttributeDeclaration);
    if (attributeTypeDefinition == null)
    {
      attributeTypeDefinition = xsdComponent.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("anySimpleType");
    }
 
    XSDTypeDefinition referenceType = getEcoreTypeQNameAttribute(xsdComponent, "reference");
    if (referenceType == null && xsdAttributeDeclaration != null)
    {
      referenceType = getEcoreTypeQNameAttribute(xsdAttributeDeclaration, "reference");
    }
    if (referenceType != null)
    {
      int lowerBound = isRequired ? 1 : 0;
      int upperBound = 1;
      if (attributeTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
      {
        XSDLengthFacet xsdLengthFacet = attributeTypeDefinition.getEffectiveLengthFacet();
        if (isRequired)
        {
          if (xsdLengthFacet != null)
          {
            lowerBound = xsdLengthFacet.getValue();
          }
          else
          {
            XSDMinLengthFacet xsdMinLengthFacet = attributeTypeDefinition.getEffectiveMinLengthFacet();
            if (xsdMinLengthFacet != null)
            {
              lowerBound = xsdMinLengthFacet.getValue();
            }
          }
        }
        if (xsdLengthFacet != null)
        {
          upperBound = xsdLengthFacet.getValue();
        }
        else
        {
          XSDMaxLengthFacet xsdMaxLengthFacet = attributeTypeDefinition.getEffectiveMaxLengthFacet();
          if (xsdMaxLengthFacet != null)
          {
            upperBound = xsdMaxLengthFacet.getValue();
          }
          else
          {
            upperBound = -1;
          }
        }
      }
 
      EClassifier referenceClassifier = getEClassifier(referenceType);
      EStructuralFeature result =
        createFeature
          (eClass,
           name,
           referenceClassifier,
           xsdComponent,
           lowerBound,
           upperBound);
      initialize(result, xsdAttributeDeclaration, xsdComponent);
      return result;
    }
    else
    {
      boolean isMany =
          attributeTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL &&
          xsdComponent instanceof XSDAttributeUse &&
          "true".equals(getEcoreAttribute(xsdComponent, "many"));
      if (isMany)
      {
        EDataType eDataType = getEDataType(attributeTypeDefinition.getItemTypeDefinition());
        XSDLengthFacet xsdLengthFacet = attributeTypeDefinition.getEffectiveLengthFacet();
        int lowerBound = isRequired ? 1 : 0;
        int upperBound = -1;
        if (isRequired)
        {
          if (xsdLengthFacet != null)
          {
            lowerBound = xsdLengthFacet.getValue();
          }
          else
          {
            XSDMinLengthFacet xsdMinLengthFacet = attributeTypeDefinition.getEffectiveMinLengthFacet();
            if (xsdMinLengthFacet != null)
            {
              lowerBound = xsdMinLengthFacet.getValue();
            }
          }
        }
        if (xsdLengthFacet != null)
        {
          upperBound = xsdLengthFacet.getValue();
        }
        else
        {
          XSDMaxLengthFacet xsdMaxLengthFacet = attributeTypeDefinition.getEffectiveMaxLengthFacet();
          if (xsdMaxLengthFacet != null)
          {
            upperBound = xsdMaxLengthFacet.getValue();
          }
        }
View Full Code Here

TOP

Related Classes of org.eclipse.xsd.XSDSimpleTypeDefinition

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.