--- ws-jaxme-0.5.2/src/xs/org/apache/ws/jaxme/xs/impl/XSLogicalParser.java 2006-09-14 04:51:43.000000000 -0400 +++ ws-jaxme-emory-0.5.2/src/xs/org/apache/ws/jaxme/xs/impl/XSLogicalParser.java 2009-04-08 11:17:41.968277200 -0400 @@ -241,38 +241,61 @@ } } + /** + * Create a URL from the given referencing system ID, and the referenced URI + * + * @return + * @throws SAXException + * @throws IOException + */ + protected URL createURL(String pReferencingSystemId, String pURI) + throws SAXException, IOException { + URL url = null; + if (pReferencingSystemId != null) { + // Try to create the new URI based on the old URI; may be its + // relative? + try { + url = new URL(new URL(pReferencingSystemId), pURI); + } catch (MalformedURLException e) { + } + + if (url == null) { + try { + File parent = (new File(pReferencingSystemId)).getParentFile(); + if (parent != null) + { + url = new URL(parent.toURL(),pURI); + } + else + { + url = new URL(pURI); + } + } catch (MalformedURLException e) { + } + } + } + + if (url == null) { + try { + url = new URL(pURI); + } catch (MalformedURLException e) { + try { + url = new File(pURI).toURL(); + } catch (MalformedURLException f) { + throw new SAXException("Failed to parse the URI " + pURI); + } + } + } + return url; + } + /**

Converts the given URI into an instance of InputSource.

*/ protected InputSource getInputSource(String pReferencingSystemId, String pURI) throws SAXException { + URL url = null; - if (pReferencingSystemId != null) { - // Try to create the new URI based on the old URI; may be its relative? - try { - url = new URL(new URL(pReferencingSystemId), pURI); - } catch (MalformedURLException e) { - } - - if (url == null) { - try { - url = new File(new File(pReferencingSystemId).getParentFile(), pURI).toURL(); - } catch (MalformedURLException e) { - } - } - } - - if (url == null) { - try { - url = new URL(pURI); - } catch (MalformedURLException e) { - try { - url = new File(pURI).toURL(); - } catch (MalformedURLException f) { - throw new SAXException("Failed to parse the URI " + pURI); - } - } - } - try { + url = createURL(pReferencingSystemId, pURI); InputSource isource = new InputSource(url.openStream()); isource.setSystemId(url.toString()); return isource; @@ -574,17 +597,19 @@ if (o instanceof XsEInclude) { XsEInclude xsEInclude = (XsEInclude) o; XsAnyURI schemaLocation = xsEInclude.getSchemaLocation(); + URL schemaURL = createURL(pSchemaLocation, schemaLocation.getURI()); includeSchema(pSyntaxSchema, xsEInclude, getImportLocator(xsEInclude, pSchemaLocation), - schemaLocation == null ? null : schemaLocation.toString()); + schemaLocation == null ? null : schemaURL.toString()); } else if (o instanceof XsERedefine) { redefineSchema(pSyntaxSchema, (XsERedefine) o); } else if (o instanceof XsEImport) { XsEImport xsEImport = (XsEImport) o; XsAnyURI namespace = xsEImport.getNamespace(); XsAnyURI schemaLocation = xsEImport.getSchemaLocation(); + URL schemaURL = createURL(pSchemaLocation, schemaLocation.getURI()); importSchema(pSyntaxSchema, namespace == null ? null : namespace.toString(), - schemaLocation == null ? null : schemaLocation.toString(), + schemaLocation == null ? null : schemaURL.toString(), getImportLocator(xsEImport, pSchemaLocation)); } else { add(pSyntaxSchema, childs[i]);