/** * Add an import to this LightWeightSchema * * @param importSchema the import to be added */ public void addImport(SchemaImport importSchema) { String namespaceURI = importSchema.getNamespaceURI(); List importList = (List) this.imports.get(namespaceURI); if (importList == null) { importList = new Vector(); this.imports.put(namespaceURI, importList); } importList.add(importSchema); }
/** * Add an import to this LightWeightSchema * * @param importSchema the import to be added */ public void addImport(SchemaImport importSchema) { String namespaceURI = importSchema.getNamespaceURI(); List importList = (List) this.imports.get(namespaceURI); if (importList == null) { importList = new Vector(); this.imports.put(namespaceURI, importList); } importList.add(importSchema); }
private void processSchema(javax.wsdl.extensions.schema.Schema schema, Collection<String> namespaceList) throws Exception { for (Iterator itImp = schema.getImports().values().iterator(); itImp.hasNext();) { Collection imps = (Collection) itImp.next(); for (Iterator itSi = imps.iterator(); itSi.hasNext();) { SchemaImport imp = (SchemaImport) itSi.next(); String namespaceUri = imp.getNamespaceURI(); namespaceList.add(namespaceUri); processSchema(imp.getReferencedSchema(), namespaceList); } } } }
/** * 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 */ 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); } } } } }