Package org.eclipse.xsd

Examples of org.eclipse.xsd.XSDImport


            }
        }
       
        //the following lines are executed only if a prefix was not found which implies that the
        //schemaTypeName was not imported earlier and also it does not belong to the targetnamespace
        XSDImport importElement = xsdFactory.createXSDImport();
        importElement.setNamespace(schemaTypeName.getNamespaceURI());
        xmlSchema.getContents().add(0, importElement);
        prefix = schemaTypeName.getPrefix();
        if ( prefix == null || prefix.length() <= 0 )
        {
            prefix = generatePrefix();
View Full Code Here


       
//        String schemaLocation = ResponseUtils.appendQueryString(ResponseUtils.appendPath( baseURL, "wfs"),
//            "service=wfs&request=DescribeFeatureType&version=" + wfs.getVersion() + "&namespace=");
       
        for ( NamespaceInfo namespace : namespaces ) {
            XSDImport imprt = factory.createXSDImport();
            imprt.setNamespace(namespace.getURI());
            params.put("namespace", namespace.getPrefix());
            imprt.setSchemaLocation(buildURL(baseURL, "wfs", params, URLType.SERVICE));

            schema.getContents().add(imprt);
        }
    }
View Full Code Here

                        + "'. Building the schema manually instead.");
            }

            // user didn't define schema location
            // import gml schema
            XSDImport imprt = factory.createXSDImport();
            imprt.setNamespace(gmlNamespace);

            imprt.setSchemaLocation(ResponseUtils.buildSchemaURL(baseUrl, gmlSchemaLocation));

            XSDSchema gmlSchema = gmlSchema();
            imprt.setResolvedSchema(gmlSchema);

            schema.getContents().add(imprt);
            schema.getQNamePrefixToNamespaceMap().put(gmlPrefix, gmlNamespace);
            schema.getQNamePrefixToNamespaceMap().put("gml", "http://www.opengis.net/gml");
            // then manually build schema
            for (int i = 0; i < featureTypeInfos.length; i++) {
                try {
                    buildSchemaContent(featureTypeInfos[i], schema, factory, baseUrl);
                } catch (Exception e) {
                    logger.log(Level.WARNING, "Could not build xml schema for type: "
                            + featureTypeInfos[i].getName(), e);
                }
            }
        } else {
            //different namespaces, write out import statements
            ArrayList<String> importedNamespaces = new ArrayList<String>(
                    ns2featureTypeInfos.size() + 1);
            for (Iterator i = ns2featureTypeInfos.entrySet().iterator(); i.hasNext();) {
                Map.Entry entry = (Map.Entry) i.next();
                String prefix = (String) entry.getKey();
                List types = (List) entry.getValue();

                StringBuffer typeNames = new StringBuffer();
                String namespaceURI;
                for (Iterator t = types.iterator(); t.hasNext();) {
                    FeatureTypeInfo info = (FeatureTypeInfo) t.next();
                    FeatureType featureType = info.getFeatureType();
                    Object schemaUri = featureType.getUserData().get("schemaURI");
                    if (schemaUri != null) {
                        // should always be a string.. set in AppSchemaDataAccessConfigurator
                        assert schemaUri instanceof String;
                        // schema is supplied by the user.. just import the top level schema instead of
                        // building
                        // the type
                        namespaceURI = featureType.getName().getNamespaceURI();

                        addImport(schema, factory, namespaceURI,
                                (String) schemaUri, importedNamespaces);

                        // ensure there's only 1 import per namespace
                        importedNamespaces.add(namespaceURI);

                    } else {
                        typeNames.append(info.getPrefixedName()).append(",");
                    }
                }
                if (typeNames.length() > 0) {
                    typeNames.setLength(typeNames.length()-1);
                   
                    // schema not found, encode describe feature type URL
                    Map<String, String> params = new LinkedHashMap<String, String>(describeFeatureTypeParams);
                    params.put("typeName", typeNames.toString().trim());
   
                    String schemaLocation = buildURL(baseUrl, "wfs", params, URLType.RESOURCE);
                    String namespace = catalog.getNamespaceByPrefix(prefix).getURI();
   
                    XSDImport imprt = factory.createXSDImport();
                    imprt.setNamespace(namespace);
                    imprt.setSchemaLocation(schemaLocation);
   
                    schema.getContents().add(imprt);
                }
            }
        }
View Full Code Here

     *            List of already imported name spaces
     */
    private void addImport(XSDSchema schema, XSDFactory factory, String nsURI, String schemaURI,
            List<String> importedNamespaces) {
        if (!importedNamespaces.contains(nsURI)) {
            XSDImport xsdImport = factory.createXSDImport();
            xsdImport.setNamespace(nsURI);
            xsdImport.setSchemaLocation((String) schemaURI);
            schema.getContents().add(xsdImport);
            importedNamespaces.add(nsURI);
        }
    }
View Full Code Here

                    XSDSchemaContent content = (XSDSchemaContent) i.next();
                    content.setElement(null);
                   
                    //check for import of gml, skip over since we already imported it
                    if ( content instanceof XSDImport ) {
                        XSDImport imprt = (XSDImport) content;
                        if ( gmlNamespace.equals( imprt.getNamespace() ) ) {
                            i.remove();
                        }
                    }
                   
                    //check for duplicated elements and types
View Full Code Here

        while (schemaContentsIterator.hasNext())
        {
          Object component = schemaContentsIterator.next();
          if (component instanceof XSDImport)
          {
            XSDImport theImport = (XSDImport)component;
            String importNamespace = theImport.getNamespace();
            if (WSDLConstants.isMatchingNamespace(namespace, importNamespace))
            {
              ((XSDImportImpl)theImport).importSchema();
              XSDSchema importedSchema = theImport.getResolvedSchema();
              if (importedSchema != null)
              {
                list.add(importedSchema);
              }
            }
View Full Code Here

            }
        }
       
        //the following lines are executed only if a prefix was not found which implies that the
        //schemaTypeName was not imported earlier and also it does not belong to the targetnamespace
        XSDImport importElement = xsdFactory.createXSDImport();
        importElement.setNamespace(schemaTypeName.getNamespaceURI());
        xmlSchema.getContents().add(0, importElement);
        prefix = schemaTypeName.getPrefix();
        if ( prefix == null || prefix.length() <= 0 )
        {
            prefix = generatePrefix();
View Full Code Here

  void addSchemaImports(XSDSchema schema){       
    java.util.Map<String, String> qNamePrefixToNamespaceMap = schema.getQNamePrefixToNamespaceMap();
    HashSet<XSDSchema> dependencies = schemaDependencies.get(schema);
    for (XSDSchema s : dependencies){
      qNamePrefixToNamespaceMap.put(schemaNsPrefixMap.get(s.getTargetNamespace()), s.getTargetNamespace());
      XSDImport imp = XSDFactory.eINSTANCE.createXSDImport();     
      imp.setSchemaLocation(s.getSchemaLocation());
      imp.setNamespace(s.getTargetNamespace());
      schema.getReferencingDirectives().add(imp);   
      schema.getContents().add(0,imp);
    }   
  }
View Full Code Here

        Types types = wsdl.getETypes();
        List<XSDSchema> schemas = types.getSchemas();
        if (schemas.size() == 1){
          java.util.Map qNamePrefixToNamespaceMap = schemas.get(0).getQNamePrefixToNamespaceMap();
          qNamePrefixToNamespaceMap.put(schemaNsPrefixMap.get(schema.getTargetNamespace()),schema.getTargetNamespace());         
          XSDImport imp = XSDFactory.eINSTANCE.createXSDImport();
          imp.setSchemaLocation(fileName);
          imp.setNamespace(schema.getTargetNamespace());         
          schemas.get(0).getReferencingDirectives().add(imp);
          schemas.get(0).getContents().add(0,imp);
        }       
      }
    }
View Full Code Here

                }
               
                List imports = Schemas.getImports(schemas[i]);

                for (Iterator im = imports.iterator(); im.hasNext();) {
                    XSDImport imprt = (XSDImport) im.next();

                    if (config.getNamespaceURI().equals(imprt.getNamespace())) {
                        found = true;

                        break O;
                    }
                }
View Full Code Here

TOP

Related Classes of org.eclipse.xsd.XSDImport

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.