Examples of XSDSchema


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

             {
                 dataType = (Type)iterator.next();
                 schemaBuilder.buildSchema(dataType);
             }
            
             XSDSchema xmlSchema = null;
             iterator = schemaMap.values().iterator();
             StringWriter writer = new StringWriter();
            
             TransformerFactory transformerFactory = TransformerFactory.newInstance();
             Transformer transformer = transformerFactory.newTransformer();
             transformer.setOutputProperty(OutputKeys.INDENT, "yes");
             transformer.setOutputProperty(OutputKeys.METHOD, "xml");
             transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            
             while ( iterator.hasNext() )
             {
                 xmlSchema = (XSDSchema)iterator.next();

                 if(xmlSchema.getElement() == null)
                 {
                     xmlSchema.updateElement();
                 }

                 transformer.transform(new DOMSource(xmlSchema.getElement().getOwnerDocument()),
                         new StreamResult(writer));
             }
             writer.close();
             return writer.getBuffer().toString();
         }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

      root = ModelLoader.load(uri);
    } catch (ModelLoadException e) {
      throw new BuiltinTypeInitializationException("Could not load URI " + uri, e);
    }
   
    XSDSchema schema = (XSDSchema) root;
    for (XSDTypeDefinition type : schema.getTypeDefinitions()) {
      if (type instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition stype = (XSDSimpleTypeDefinition) type;
        String u = stype.getURI();
       
        // for every type
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

    /**
     * Suplements the schema built by the parent by adding hte aplication schema
     * feature typs defined in GeoServer.
     */
    protected XSDSchema buildSchema() throws IOException {
        XSDSchema wfsSchema = super.buildSchema();
        wfsSchema = schemaBuilder.addApplicationTypes(wfsSchema);
        return wfsSchema;
    }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

            //look for a FeatureType
            FeatureTypeInfo meta = catalog.getFeatureTypeByName( namespaceURI, name.getLocalPart() );

            if (meta != null) {
                //found it
                XSDSchema schema = schemaBuilder.build(meta, null);

                for (Iterator e = schema.getElementDeclarations().iterator(); e.hasNext();) {
                    XSDElementDeclaration element = (XSDElementDeclaration) e.next();

                    if (name.getLocalPart().equals(element.getName())) {
                        return new ElementHandlerImpl(element, parent, parser);
                    }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

    /**
     * Suplements the schema built by the parent by adding hte aplication schema
     * feature typs defined in GeoServer.
     */
    protected XSDSchema buildSchema() throws IOException {
        XSDSchema wfsSchema = super.buildSchema();
        wfsSchema = schemaBuilder.addApplicationTypes(wfsSchema);
        return wfsSchema;
    }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

        Operation describeFeatureType) throws IOException {
       
        GeoServerInfo global = wfs.getGeoServer().getGlobal();
        //create the schema
        DescribeFeatureTypeType req = (DescribeFeatureTypeType)describeFeatureType.getParameters()[0];
        XSDSchema schema = schemaBuilder.build(featureTypeInfos, req.getBaseUrl());

        //serialize
        schema.updateElement();
        final String encoding = global.getCharset();
        XSDResourceImpl.serialize(output, schema.getElement(), encoding);
    }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

    }
   
    @Override
    protected XSDSchema buildSchema() throws IOException {
        XSDFactory factory = XSDFactory.eINSTANCE;
        XSDSchema schema = factory.createXSDSchema();
       
        schema.setSchemaForSchemaQNamePrefix("xsd");
        schema.getQNamePrefixToNamespaceMap().put("xsd", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
        schema.setElementFormDefault(XSDForm.get(XSDForm.QUALIFIED));

        if ( ns == null ) {
            //there must be types from different namespaces included, build a schema
            // with imports
            if ( types.isEmpty() ) {
                //build for all namespaces
                buildSchemaImports( catalog.getNamespaces(), schema, factory );
            }
            else {
                Set<NamespaceInfo> namespaces = new HashSet<NamespaceInfo>();
                for ( FeatureTypeInfo type : types ) {
                    namespaces.add( type.getNamespace() );
                }
                buildSchemaImports( namespaces, schema, factory );
            }
        }
        else {
            schema.setTargetNamespace(ns.getURI());
            schema.getQNamePrefixToNamespaceMap().put(ns.getPrefix(), ns.getURI());
           
            schema.getQNamePrefixToNamespaceMap().put("wfs", WFS.NAMESPACE);
            schema.getQNamePrefixToNamespaceMap().put("gml", GML.NAMESPACE);
           
            //import wfs schema
            Schemas.importSchema( schema ,wfs.getSchema() );
            schema.resolveElementDeclaration( WFS.NAMESPACE, "FeatureCollection" );
            /*
            XSDImport imprt = factory.createXSDImport();
            imprt.setNamespace(WFS.NAMESPACE);
           
            String location = ResponseUtils.appendPath( baseURL, "schemas/wfs/");
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

       
        if (schemaFile != null) {
            //TODO: farm this schema loading stuff to some utility class
            //parse the schema + generate attributes from that
            List locators = Arrays.asList( GML.getInstance().createSchemaLocator() );
            XSDSchema schema = null;
            try {
                schema = Schemas.parse( schemaFile.getAbsolutePath(), locators, null );
            }
            catch( Exception e ) {
                LOGGER.warning( "Unable to parse " + schemaFile.getAbsolutePath() + "." +
                    " Falling back on native feature type");
            }
            if ( schema != null ) {
                XSDTypeDefinition type = null;
                for ( Iterator e = schema.getElementDeclarations().iterator(); e.hasNext(); ) {
                    XSDElementDeclaration element = (XSDElementDeclaration) e.next();
                    if ( ft.getName().equals( element.getName() ) ) {
                        type = element.getTypeDefinition();
                        break;
                    }
                }
                if ( type == null ) {
                    for ( Iterator t = schema.getTypeDefinitions().iterator(); t.hasNext(); ) {
                        XSDTypeDefinition typedef = (XSDTypeDefinition) t.next();
                        if ( (ft.getName() + "_Type").equals( typedef.getName() ) ) {
                            type = typedef;
                            break;
                        }
View Full Code Here

Examples of org.eclipse.xsd.XSDSchema

    }

    public XSDSchema build(FeatureTypeInfo[] featureTypeInfos, String baseUrl)
        throws IOException {
        XSDFactory factory = XSDFactory.eINSTANCE;
        XSDSchema schema = factory.createXSDSchema();
        schema.setSchemaForSchemaQNamePrefix("xsd");
        schema.getQNamePrefixToNamespaceMap().put("xsd", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
        schema.setElementFormDefault(XSDForm.get(XSDForm.QUALIFIED));

        //group the feature types by namespace
        HashMap ns2featureTypeInfos = new HashMap();

        for (int i = 0; i < featureTypeInfos.length; i++) {
            String prefix = featureTypeInfos[i].getNamespace().getPrefix();
            List l = (List) ns2featureTypeInfos.get(prefix);

            if (l == null) {
                l = new ArrayList();
            }

            l.add(featureTypeInfos[i]);

            ns2featureTypeInfos.put(prefix, l);
        }
       
        if (baseUrl == null)
            baseUrl = wfs.getSchemaBaseURL();
               
        if (ns2featureTypeInfos.entrySet().size() == 1) {
            // only 1 namespace, write target namespace out
            String targetPrefix = (String) ns2featureTypeInfos.keySet().iterator().next();
            String targetNamespace = catalog.getNamespaceByPrefix(targetPrefix).getURI();
            schema.setTargetNamespace(targetNamespace);
            schema.getQNamePrefixToNamespaceMap().put(targetPrefix, targetNamespace);
            // add secondary namespaces from catalog
            for (NamespaceInfo nameSpaceinfo : catalog.getNamespaces()) {
                if (!schema.getQNamePrefixToNamespaceMap().containsKey(nameSpaceinfo.getPrefix())) {
                    schema.getQNamePrefixToNamespaceMap().put(nameSpaceinfo.getPrefix(),
                            nameSpaceinfo.getURI());
                }
            }
            // would result in 1 xsd:include if schema location is specified
            try {
                FeatureType featureType = featureTypeInfos[0].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 include the top level schema instead of
                    // building the type
                    if (!findTypeInSchema(featureTypeInfos[0], schema, factory)) {
                        addInclude(schema, factory, targetNamespace, (String) schemaUri);
                    }
                    return schema;
                }
            } catch (IOException e) {
                logger.warning("Unable to get schema location for feature type '"
                        + featureTypeInfos[0].getPrefixedName() + "'. Reason: '" + e.getMessage()
                        + "'. 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");
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.