protected void addImportedSchemas(Schema schema) throws WSDLException, IOException, TransformerException, TransformerFactoryConfigurationError {
        for (Object imports : schema.getImports().values()) {
            for (SchemaImport schemaImport : (Vector<SchemaImport>)imports) {
                // Prevent duplicate imports
                if (!importedSchemas.contains(schemaImport.getNamespaceURI())) {
                    importedSchemas.add(schemaImport.getNamespaceURI());
                    Schema referencedSchema = schemaImport.getReferencedSchema();

                    if (referencedSchema != null) {
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        Source source = new DOMSource(referencedSchema.getElement());
                        Result result = new StreamResult(bos);

                        TransformerFactory.newInstance().newTransformer().transform(source, result);
                        Resource schemaResource = new ByteArrayResource(bos.toByteArray());

                        addImportedSchemas(referencedSchema);
                        schemaResources.add(schemaResource);
                    }
                }
            }
        }
    }
protected void addImportedSchemas ( Schema schema ) throws WSDLException , IOException , TransformerException , TransformerFactoryConfigurationError { for ( Object imports : schema . getImports ( ) . values ( ) ) { for ( SchemaImport schemaImport : ( Vector < SchemaImport > ) imports ) { if ( ! importedSchemas . contains ( schemaImport . getNamespaceURI ( ) ) ) { importedSchemas . add ( schemaImport . getNamespaceURI ( ) ) ; Schema referencedSchema = schemaImport . getReferencedSchema ( ) ; if ( referencedSchema != null ) { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; Source source = new DOMSource ( referencedSchema . getElement ( ) ) ; Result result = new StreamResult ( bos ) ; TransformerFactory . newInstance ( ) . newTransformer ( ) . transform ( source , result ) ; Resource schemaResource = new ByteArrayResource ( bos . toByteArray ( ) ) ; addImportedSchemas ( referencedSchema ) ; schemaResources . add ( schemaResource ) ; } } } } }
Recursively add all imported schemas as schema resource.
This is necessary when schema import are located in jar files. If they are not added immediately the reference to them is lost.

@param schema