/** * Initialize this XsltView's TransformerFactory. */ @Override protected void initApplicationContext() throws BeansException { this.transformerFactory = newTransformerFactory(this.transformerFactoryClass); this.transformerFactory.setErrorListener(this.errorListener); if (this.uriResolver != null) { this.transformerFactory.setURIResolver(this.uriResolver); } if (this.cacheTemplates) { this.cachedTemplates = loadTemplates(); } }
public void startup() throws Exception { setWarnClient(true); // !! where should that be decided? if (stylesheet == null) { TransformerFactory tFactory = TransformerFactory.newInstance(); tFactory.setURIResolver(new URIResolver() { public Source resolve(String href, String base) { if (href.endsWith("emotion-to-mary.xsl")) { return new StreamSource(this.getClass().getResourceAsStream("emotion-to-mary.xsl")); } else { return null; } } }); StreamSource stylesheetStream = new StreamSource(this.getClass().getResourceAsStream("apml-to-mary.xsl")); stylesheet = tFactory.newTemplates(stylesheetStream); } if (dbFactory == null) { dbFactory = DocumentBuilderFactory.newInstance(); } if (docBuilder == null) { docBuilder = dbFactory.newDocumentBuilder(); } super.startup(); }
public void startup() throws Exception { setWarnClient(true); // !! where should that be decided? if (stylesheet == null) { TransformerFactory tFactory = TransformerFactory.newInstance(); tFactory.setURIResolver(new URIResolver() { public Source resolve(String href, String base) { if (href.endsWith("emotion-to-mary.xsl")) { return new StreamSource(this.getClass().getResourceAsStream("emotion-to-mary.xsl")); } else { return null; } } }); StreamSource stylesheetStream = new StreamSource(this.getClass().getResourceAsStream("apml-to-mary.xsl")); stylesheet = tFactory.newTemplates(stylesheetStream); } if (dbFactory == null) { dbFactory = DocumentBuilderFactory.newInstance(); } if (docBuilder == null) { docBuilder = dbFactory.newDocumentBuilder(); } super.startup(); }
/** * Initialize this XsltView's TransformerFactory. */ @Override protected void initApplicationContext() throws BeansException { this.transformerFactory = newTransformerFactory(this.transformerFactoryClass); this.transformerFactory.setErrorListener(this.errorListener); if (this.uriResolver != null) { this.transformerFactory.setURIResolver(this.uriResolver); } if (this.cacheTemplates) { this.cachedTemplates = loadTemplates(); } }
tfactory.setURIResolver(uriResolver);
XmlUtils.getTransformerFactory().setURIResolver(RESOURCES_URI_RESOLVER); if (Docx4jProperties.getProperty(PROPERTY_HTML_OUTPUT_TYPE, true)){ log.info("Outputting well-formed XHTML.."); XmlUtils.getTransformerFactory().setURIResolver(originalURIResolver);
argv[++i], ObjectFactory.findClassLoader(), true); tfactory.setURIResolver(uriResolver);
public static void transform(String xsltDir, String source, String xslt, String dest, URIResolver alt) throws Exception { TransformerFactory f = TransformerFactory.newInstance(); StreamSource xsrc = new StreamSource(new FileInputStream(xslt)); f.setURIResolver(new MyURIResolver(xsltDir, alt)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new MyURIResolver(xsltDir, alt)); StreamSource src = new StreamSource(new FileInputStream(source)); StreamResult res = new StreamResult(new FileOutputStream(dest)); t.transform(src, res); }
public static void transform(String xsltDir, String source, String xslt, String dest, URIResolver alt) throws FileNotFoundException, TransformerException { TransformerFactory f = TransformerFactory.newInstance(); StreamSource xsrc = new StreamSource(new FileInputStream(xslt)); f.setURIResolver(new MyURIResolver(xsltDir, alt)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new MyURIResolver(xsltDir, alt)); StreamSource src = new StreamSource(new FileInputStream(source)); StreamResult res = new StreamResult(new FileOutputStream(dest)); t.transform(src, res); }
public static void transform(String xsltDir, String source, String xslt, String dest, URIResolver alt) throws FileNotFoundException, TransformerException { TransformerFactory f = TransformerFactory.newInstance(); StreamSource xsrc = new StreamSource(new FileInputStream(xslt)); f.setURIResolver(new MyURIResolver(xsltDir, alt)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new MyURIResolver(xsltDir, alt)); StreamSource src = new StreamSource(new FileInputStream(source)); StreamResult res = new StreamResult(new FileOutputStream(dest)); t.transform(src, res); }
public static byte[] transform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws TransformerException { TransformerFactory f = TransformerFactory.newInstance(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt)); f.setURIResolver(new ZipURIResolver(files)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new ZipURIResolver(files)); StreamSource src = new StreamSource(new ByteArrayInputStream(source)); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult res = new StreamResult(out); t.transform(src, res); return out.toByteArray(); }
public static byte[] transform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws TransformerException { TransformerFactory f = TransformerFactory.newInstance(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt)); f.setURIResolver(new ZipURIResolver(files)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new ZipURIResolver(files)); StreamSource src = new StreamSource(new ByteArrayInputStream(source)); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult res = new StreamResult(out); t.transform(src, res); return out.toByteArray(); }
public static byte[] transform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws Exception { TransformerFactory f = TransformerFactory.newInstance(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt)); f.setURIResolver(new ZipURIResolver(files)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new ZipURIResolver(files)); StreamSource src = new StreamSource(new ByteArrayInputStream(source)); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult res = new StreamResult(out); t.transform(src, res); return out.toByteArray(); }
public static byte[] saxonTransform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws Exception { TransformerFactory f = new net.sf.saxon.TransformerFactoryImpl(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt)); f.setURIResolver(new ZipURIResolver(files)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new ZipURIResolver(files)); StreamSource src = new StreamSource(new ByteArrayInputStream(source)); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult res = new StreamResult(out); t.transform(src, res); return out.toByteArray(); }
public static byte[] saxonTransform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws TransformerException { TransformerFactory f = new net.sf.saxon.TransformerFactoryImpl(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt)); f.setURIResolver(new ZipURIResolver(files)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new ZipURIResolver(files)); StreamSource src = new StreamSource(new ByteArrayInputStream(source)); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult res = new StreamResult(out); t.transform(src, res); return out.toByteArray(); }
public TransformerFactory newTransformerFactory(String pFactoryClassName) { System.setProperty("javax.xml.transform.TransformerFactory", pFactoryClassName); TransformerFactory tFactory = TransformerFactory.newInstance(); System.clearProperty("javax.xml.transform.TransformerFactory"); tFactory.setURIResolver(this); return tFactory; }
public void reloadStyleSheet() throws TransformerConfigurationException { TransformerFactory transFact = TransformerFactory.newInstance(); if(uriResolver != null){ transFact.setURIResolver(uriResolver); } this.templates = transFact.newTemplates(new StreamSource(uri.toString())); }
public static void transform(String xsltDir, String source, String xslt, String dest, URIResolver alt) throws Exception { TransformerFactory f = TransformerFactory.newInstance(); StreamSource xsrc = new StreamSource(new FileInputStream(xslt)); f.setURIResolver(new MyURIResolver(xsltDir, alt)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new MyURIResolver(xsltDir, alt)); StreamSource src = new StreamSource(new FileInputStream(source)); StreamResult res = new StreamResult(new FileOutputStream(dest)); t.transform(src, res); }
//First create the resolver MapEntryResolver uriResolver = new MapEntryResolver(); //pass your map uriResolver.setMap(yourMap); //and attach it to the factory TransformerFactory factory = new TransformerFactoryImpl(); factory.setURIResolver(uriResolver); Transformer transformer = factory.newTransformer(new StreamSource(this.getClass().getResourceAsStream(pathToYourXsl)); //start transform and store result ByteArrayOutputstream result = new ByteArrayOutputstream(); transformer.transform(new StreamSource(pathToYourInputXml), new StreamResult(result));
public static Transformer configure(TransformerFactory factory, String resource) throws TransformerConfigurationException { URIResolver resolver = new SimpleResolver(factory.getURIResolver()); factory.setURIResolver(resolver); Transformer transformer = factory.newTransformer(new StreamSource(SimpleResolver.class.getResource(resource).toString())); transformer.setURIResolver(resolver); return transformer; }