Package org.eclipse.xsd

Examples of org.eclipse.xsd.XSDSimpleTypeDefinition


                                            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

  private static void addEMFXSDDataTypes(InternetApplication app) throws ModelInitializationException {
    initialiseEMFXSDDataTypes();
   
    for (XSDTypeDefinition type : xsdSchemaInstance.getTypeDefinitions()) {
      if (type instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition xs = (XSDSimpleTypeDefinition) type;
       
        // for now, we will only initialise with a few builtin types
        if (INCLUDED_DATA_TYPES.contains(xs.getName())) {
          EXSDDataType dt = ModelFactory.eINSTANCE.createEXSDDataType();
          dt.setId("xsd_" + xs.getName());
          dt.setDefinition(xs);
          dt.setName("xsd:" + xs.getName());
          app.getXsdDataTypes().add(dt);
        }
      }
    }
  }
View Full Code Here

  private static void addBuiltinXSDDataTypes(InternetApplication app) throws ModelInitializationException {
    initialiseBuiltinXSDDataTypes();
   
    for (XSDTypeDefinition type : builtinXsdTypes.getTypeDefinitions()) {
      if (type instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition xs = (XSDSimpleTypeDefinition) type;
       
        EXSDDataType dt = ModelFactory.eINSTANCE.createEXSDDataType();
        dt.setId("builtin_" + xs.getName());
        dt.setDefinition(xs);
        dt.setName("builtin:" + xs.getName());
        app.getXsdDataTypes().add(dt);
      }
    }
  }
View Full Code Here

    }
   
    XSDSchema schema = (XSDSchema) root;
    for (XSDTypeDefinition type : schema.getTypeDefinitions()) {
      if (type instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition stype = (XSDSimpleTypeDefinition) type;
        String u = stype.getURI();
       
        // for every type
        if (TYPE_INTEGER.equals(u)) {
          xsdInteger = stype;
        } else if (TYPE_STRING.equals(u)) {
View Full Code Here

*/
public class BuiltinDataTypesTests extends TestCase {
 
  public void testInteger() {
    String uri = BuiltinDataTypes.TYPE_INTEGER;
    XSDSimpleTypeDefinition loaded = BuiltinDataTypes.getTypeInteger();
   
    assertNotNull(uri);
    assertNotNull(loaded);
    assertEquals(uri, loaded.getURI());
  }
View Full Code Here

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

  public void testString() {
    String uri = BuiltinDataTypes.TYPE_STRING;
    XSDSimpleTypeDefinition loaded = BuiltinDataTypes.getTypeString();
   
    assertNotNull(uri);
    assertNotNull(loaded);
    assertEquals(uri, loaded.getURI());
  }
View Full Code Here

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

  public void testEmail() {
    String uri = BuiltinDataTypes.TYPE_EMAIL;
    XSDSimpleTypeDefinition loaded = BuiltinDataTypes.getTypeEmail();
   
    assertNotNull(uri);
    assertNotNull(loaded);
    assertEquals(uri, loaded.getURI());
  }
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.