Examples of XSDSchema


Examples of org.eclipse.xsd.XSDSchema

  protected String getEcoreAttribute(XSDConcreteComponent xsdConcreteComponent, String attribute)
  {
    String value = super.getEcoreAttribute(xsdConcreteComponent, attribute);
    if ("package".equals(attribute) && value == null)
    {
      XSDSchema xsdSchema = (XSDSchema)xsdConcreteComponent;
      value = getDefaultPackageName(xsdSchema.getTargetNamespace());
    }
    return value;
  }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

  public static String getSchemaNamespace(String xsdFileName)
  {
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    File inputFile = new File(xsdFileName).getAbsoluteFile();
    Resource model = resourceSet.getResource(URI.createURI(inputFile.toURI().toString()), true);
    XSDSchema schema = (XSDSchema)model.getContents().get(0);
    return schema.getTargetNamespace();
  }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

      ((XSDResourceImpl)model).load(inputSource, null);
     
      List newTypes = new ArrayList();
      for (Iterator schemaIter = model.getContents().iterator(); schemaIter.hasNext(); )
      {
        XSDSchema schema = (XSDSchema)schemaIter.next();   

        EPackage ePackage = extendedMetaData.getPackage(schema.getTargetNamespace());
        if (ePackage == null)
        {
          Collection originalEPackages = new HashSet(ecoreBuilder.getTargetNamespaceToEPackageMap().values());
          ecoreBuilder.generate(schema);
          Collection newEPackages = ecoreBuilder.getTargetNamespaceToEPackageMap().values();
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

  public static String getSchemaNamespace(String xsdFileName)
  {
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    File inputFile = new File(xsdFileName).getAbsoluteFile();
    Resource model = resourceSet.getResource(URI.createURI(inputFile.toURI().toString()), true);
    XSDSchema schema = (XSDSchema)model.getContents().get(0);
    return schema.getTargetNamespace();
  }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

  public static String getSchemaNamespace(String xsdFileName)
  {
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    File inputFile = new File(xsdFileName).getAbsoluteFile();
    Resource model = resourceSet.getResource(URI.createURI(inputFile.toURI().toString()), true);
    XSDSchema schema = (XSDSchema)model.getContents().get(0);
    return schema.getTargetNamespace();
  }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

  public static String getSchemaNamespace(String xsdFileName)
  {
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    File inputFile = new File(xsdFileName).getAbsoluteFile();
    Resource model = resourceSet.getResource(URI.createURI(inputFile.toURI().toString()), true);
    XSDSchema schema = (XSDSchema)model.getContents().get(0);
    return schema.getTargetNamespace();
  }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

        //this is called from buildSchema only if isXSD(dataType) is false
        QName complexSchemaTypeName = null ;
        if ( !dataType.isDataType() &&
                (complexSchemaTypeName = typeTable.getComplexSchemaTypeName(dataType.getURI(), dataType.getName())) == null )
        {
            XSDSchema xmlSchema = getXmlSchema(dataType);
            String targetNamespace = dataType.getURI();
            String targetNamespacePrefix = (String)targetNamespacePrefixMap.get(targetNamespace);
           
            complexSchemaTypeName = new QName(targetNamespace,
                                                dataType.getName(),
                                                targetNamespacePrefix);
           
            XSDComplexTypeDefinition complexType = xsdFactory.createXSDComplexTypeDefinition();
            complexType.setName(dataType.getName());
            complexType.setTargetNamespace(targetNamespace);    
            complexType.setAbstract(dataType.isAbstract());
           
            xmlSchema.getTypeDefinitions().add(complexType);
            xmlSchema.getContents().add(complexType);
           
            complexType.updateElement();
           
            addAnnotations(complexType, dataType);
           
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

    {
        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() )
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

    private void includeExtXSD(Type dataType)
    {
        //now we know there is a type for which the xsd must come from outside
        //create a schema for the namespace of this type and add an include in it for
        //the xsd that is defined externally
        XSDSchema xmlSchema = getXmlSchema(dataType);
       
        //ideally there could  be more than one external schema defintions for a namespace
        //and hence schemalocations will be a list of locations
        //List schemaLocations = (List)schemaLocationMap.get(dataType.getURI());
       
        //since as per the specs the input to XSDHelper is a map of <String, String> allowing
        //only one schemalocation for a namespace.  So for now this single location will be
        //picked up and put into a list
        List schemaLocations = new Vector();
        if ( schemaLocationMap.get(dataType.getURI()) != null )
        {
            schemaLocations.add(schemaLocationMap.get(dataType.getURI()));
        }
       
        if ( schemaLocations.size() <= 0 )
        {
            schemaLocations.add(DEFAULT_SCHEMA_LOCATION);
        }
       
        Object schemaContent = null;
        Iterator includesIterator = xmlSchema.getContents().iterator();
        Iterator schemaLocIterator = schemaLocations.iterator();
        String aSchemaLocation = null;
        boolean includeExists = false;
        //include all external schema locations
        while ( schemaLocIterator.hasNext() )
        {
            aSchemaLocation = (String)schemaLocIterator.next();
            while ( includesIterator.hasNext() )
            {
                schemaContent = includesIterator.next();
                if ( schemaContent instanceof XSDInclude )
                {
                    if ( !includeExists && aSchemaLocation.equals(
                            ((XSDInclude)schemaContent).getSchemaLocation()
                                 ))
                    {
                        includeExists = true;
                    }
                }
            }
           
            if ( !includeExists )
            {
                XSDInclude includeElement = xsdFactory.createXSDInclude();
                includeElement.setSchemaLocation(aSchemaLocation);
                xmlSchema.getContents().add(0, includeElement);
            }
        }
    }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

    }
   
   
    private XSDSchema getXmlSchema(Type dataType)
    {
        XSDSchema xmlSchema = null;
       
        if ((xmlSchema = (XSDSchema) schemaMap.get(dataType.getURI())) == null)
        {
            String targetNamespacePrefix = generatePrefix();
           
            xmlSchema = xsdFactory.createXSDSchema();
            xmlSchema.setTargetNamespace(dataType.getURI());
            xmlSchema.setAttributeFormDefault(XSDForm.QUALIFIED_LITERAL);
            xmlSchema.setElementFormDefault(XSDForm.QUALIFIED_LITERAL);
           
            targetNamespacePrefixMap.put(dataType.getURI(), targetNamespacePrefix);
            schemaMap.put(dataType.getURI(), xmlSchema);
           
            xmlSchema.getQNamePrefixToNamespaceMap().put(TypeTable.XS_URI_PREFIX, TypeTable.XML_SCHEMA_URI);
            xmlSchema.setSchemaForSchemaQNamePrefix(TypeTable.XS_URI_PREFIX);

            xmlSchema.getQNamePrefixToNamespaceMap().put(targetNamespacePrefix, dataType.getURI());
            //xmlSchema.setSchemaForSchemaQNamePrefix(targetNamespacePrefix);
           
            addSDONamespaces(xmlSchema);
            addPackageAnnotation(xmlSchema, dataType);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.