@Override public InputSource resolveEntity(String publicId, String systemId) { String matchingPrefix = findMatchingPrefix(systemId); Resource resource = null; if (matchingPrefix != null) { resource = resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length())); } if (resource == null) { resource = resourceOracle.getResource(pathBase + systemId); } if (resource != null) { String content; try { InputStream resourceStream = resource.openContents(); content = Util.readStreamAsString(resourceStream); } catch (IOException ex) { logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation()); throw new RuntimeException(ex); } InputSource inputSource = new InputSource(new StringReader(content)); inputSource.setPublicId(publicId); inputSource.setSystemId(resource.getPath()); return inputSource; } /* * Let Sax find it on the interweb. */ return null; }
@Override public InputSource resolveEntity(String publicId, String systemId) { String matchingPrefix = findMatchingPrefix(systemId); Resource resource = null; if (matchingPrefix != null) { resource = resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length())); } if (resource == null) { resource = resourceOracle.getResource(pathBase + systemId); } if (resource != null) { String content; try { InputStream resourceStream = resource.openContents(); content = Util.readStreamAsString(resourceStream); } catch (IOException ex) { logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation()); throw new RuntimeException(ex); } InputSource inputSource = new InputSource(new StringReader(content)); inputSource.setPublicId(publicId); inputSource.setSystemId(resource.getPath()); return inputSource; } /* * Let Sax find it on the interweb. */ return null; }
private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime, ResourceOracle resourceOracle, String templatePath, Resource resource) throws UnableToCompleteException { Document doc = null; try { String content = designTime.getTemplateContent(templatePath); if (content == null) { content = Util.readStreamAsString(resource.openContents()); } doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor( content, resource.getPath()); } catch (IOException iex) { logger.die("Error opening resource:" + resource.getLocation(), iex); } catch (SAXParseException e) { logger.die( "Error parsing XML (line " + e.getLineNumber() + "): " + e.getMessage(), e); } return doc; }
resourceStream = resource.openContents(); } catch (IOException ex) { logger.log(TreeLogger.ERROR, "Error opening resource: " + resource.getLocation()); throw new RuntimeException(ex);
private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime, ResourceOracle resourceOracle, String templatePath, Resource resource) throws UnableToCompleteException { Document doc = null; try { String content = designTime.getTemplateContent(templatePath); if (content == null) { content = Util.readStreamAsString(resource.openContents()); } doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor( content, resource.getPath()); } catch (IOException iex) { logger.die("Error opening resource:" + resource.getLocation(), iex); } catch (SAXParseException e) { logger.die( "Error parsing XML (line " + e.getLineNumber() + "): " + e.getMessage(), e); } return doc; }
resourceStream = resource.openContents(); } catch (IOException ex) { logger.log(TreeLogger.ERROR, "Error opening resource: " + resource.getLocation()); throw new RuntimeException(ex);