@Test public void testResolveResource_In_BaseURI_Two_Upper_Levels() { pathMap.put("base.xsd", BASE_PATH+"c/d/"); LSInput input = sut.resolveResource("type", "namespaceURI", "publicId", "../../x/new.xsd", "a/b/base.xsd"); assertEquals(BASE_PATH+"x/",pathMap.get("new.xsd")); assertNotNull(input); }
@Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { String baseResourceName = null; String baseResourcePath = null; String currentResourceName = systemId.substring(systemId .lastIndexOf("/") + 1); if (!pathMap.containsKey(currentResourceName)) { if (baseURI != null) { baseResourceName = baseURI .substring(baseURI.lastIndexOf("/") + 1); } if (systemId.startsWith("./")) { systemId = systemId.substring(2, systemId.length()); } if (pathMap.containsKey(baseResourceName)) { baseResourcePath = pathMap.get(baseResourceName); } else { baseResourcePath = schemaBasePath; } String normalizedPath = getNormalizedPath(baseResourcePath, systemId); InputStream resourceAsStream = getResourceAsStream(normalizedPath); if (systemId.contains("/")) { pathMap.put(currentResourceName, normalizedPath.substring(0,normalizedPath.lastIndexOf("/")+1)); } else { pathMap.put(systemId, baseResourcePath); } Scanner s = setScanner(resourceAsStream); String s1 = s.next().replaceAll("\\n", " ") .replace("\\t", " ") .replaceAll("\\s+", " ").replaceAll("[^\\x20-\\x7e]", ""); InputStream is = new ByteArrayInputStream(s1.getBytes()); s.close(); return new LSInputImpl(publicId, systemId, is, fileReader); } return null; }
ResourceResolver implements LSResourceResolver { @Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { String baseResourceName = null; String baseResourcePath = null; String currentResourceName = systemId.substring(systemId .lastIndexOf("/") + 1); if (!pathMap.containsKey(currentResourceName)) { if (baseURI != null) { baseResourceName = baseURI .substring(baseURI.lastIndexOf("/") + 1); } if (systemId.startsWith("./")) { systemId = systemId.substring(2, systemId.length()); } if (pathMap.containsKey(baseResourceName)) { baseResourcePath = pathMap.get(baseResourceName); } else { baseResourcePath = schemaBasePath; } String normalizedPath = getNormalizedPath(baseResourcePath, systemId); InputStream resourceAsStream = getResourceAsStream(normalizedPath); if (systemId.contains("/")) { pathMap.put(currentResourceName, normalizedPath.substring(0,normalizedPath.lastIndexOf("/")+1)); } else { pathMap.put(systemId, baseResourcePath); } Scanner s = setScanner(resourceAsStream); String s1 = s.next().replaceAll("\\n", " ") .replace("\\t", " ") .replaceAll("\\s+", " ").replaceAll("[^\\x20-\\x7e]", ""); InputStream is = new ByteArrayInputStream(s1.getBytes()); s.close(); return new LSInputImpl(publicId, systemId, is, fileReader); } return null; } }
ResourceResolver implements LSResourceResolver { @Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { String baseResourceName = null; String baseResourcePath = null; String currentResourceName = systemId.substring(systemId .lastIndexOf("/") + 1); if (!pathMap.containsKey(currentResourceName)) { if (baseURI != null) { baseResourceName = baseURI .substring(baseURI.lastIndexOf("/") + 1); } if (systemId.startsWith("./")) { systemId = systemId.substring(2, systemId.length()); } if (pathMap.containsKey(baseResourceName)) { baseResourcePath = pathMap.get(baseResourceName); } else { baseResourcePath = schemaBasePath; } String normalizedPath = getNormalizedPath(baseResourcePath, systemId); InputStream resourceAsStream = getResourceAsStream(normalizedPath); if (systemId.contains("/")) { pathMap.put(currentResourceName, normalizedPath.substring(0,normalizedPath.lastIndexOf("/")+1)); } else { pathMap.put(systemId, baseResourcePath); } Scanner s = setScanner(resourceAsStream); String s1 = s.next().replaceAll("\\n", " ") .replace("\\t", " ") .replaceAll("\\s+", " ").replaceAll("[^\\x20-\\x7e]", ""); InputStream is = new ByteArrayInputStream(s1.getBytes()); s.close(); return new LSInputImpl(publicId, systemId, is, fileReader); } return null; } ResourceResolver(String schemaBasePath); }
ResourceResolver implements LSResourceResolver { @Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { String baseResourceName = null; String baseResourcePath = null; String currentResourceName = systemId.substring(systemId .lastIndexOf("/") + 1); if (!pathMap.containsKey(currentResourceName)) { if (baseURI != null) { baseResourceName = baseURI .substring(baseURI.lastIndexOf("/") + 1); } if (systemId.startsWith("./")) { systemId = systemId.substring(2, systemId.length()); } if (pathMap.containsKey(baseResourceName)) { baseResourcePath = pathMap.get(baseResourceName); } else { baseResourcePath = schemaBasePath; } String normalizedPath = getNormalizedPath(baseResourcePath, systemId); InputStream resourceAsStream = getResourceAsStream(normalizedPath); if (systemId.contains("/")) { pathMap.put(currentResourceName, normalizedPath.substring(0,normalizedPath.lastIndexOf("/")+1)); } else { pathMap.put(systemId, baseResourcePath); } Scanner s = setScanner(resourceAsStream); String s1 = s.next().replaceAll("\\n", " ") .replace("\\t", " ") .replaceAll("\\s+", " ").replaceAll("[^\\x20-\\x7e]", ""); InputStream is = new ByteArrayInputStream(s1.getBytes()); s.close(); return new LSInputImpl(publicId, systemId, is, fileReader); } return null; } ResourceResolver(String schemaBasePath); @Override LSInput resolveResource(String type, String namespaceURI,
			String publicId, String systemId, String baseURI); }
ResourceResolver implements LSResourceResolver { @Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { String baseResourceName = null; String baseResourcePath = null; String currentResourceName = systemId.substring(systemId .lastIndexOf("/") + 1); if (!pathMap.containsKey(currentResourceName)) { if (baseURI != null) { baseResourceName = baseURI .substring(baseURI.lastIndexOf("/") + 1); } if (systemId.startsWith("./")) { systemId = systemId.substring(2, systemId.length()); } if (pathMap.containsKey(baseResourceName)) { baseResourcePath = pathMap.get(baseResourceName); } else { baseResourcePath = schemaBasePath; } String normalizedPath = getNormalizedPath(baseResourcePath, systemId); InputStream resourceAsStream = getResourceAsStream(normalizedPath); if (systemId.contains("/")) { pathMap.put(currentResourceName, normalizedPath.substring(0,normalizedPath.lastIndexOf("/")+1)); } else { pathMap.put(systemId, baseResourcePath); } Scanner s = setScanner(resourceAsStream); String s1 = s.next().replaceAll("\\n", " ") .replace("\\t", " ") .replaceAll("\\s+", " ").replaceAll("[^\\x20-\\x7e]", ""); InputStream is = new ByteArrayInputStream(s1.getBytes()); s.close(); return new LSInputImpl(publicId, systemId, is, fileReader); } return null; } ResourceResolver(String schemaBasePath); @Override LSInput resolveResource(String type, String namespaceURI,
			String publicId, String systemId, String baseURI);  }