/** * Construct an empty XML filter, with no parent. * * <p>This filter will have no parent: you must assign a parent * before you start a parse or do any configuration with * setFeature or setProperty.</p> * * @see org.xml.sax.XMLReader#setFeature * @see org.xml.sax.XMLReader#setProperty */ public TrAXFilter (Templates templates) throws TransformerConfigurationException { m_templates = templates; m_transformer = (TransformerImpl)templates.newTransformer(); }
/** * Construct an empty XML filter, with no parent. * * <p>This filter will have no parent: you must assign a parent * before you start a parse or do any configuration with * setFeature or setProperty.</p> * * @see org.xml.sax.XMLReader#setFeature * @see org.xml.sax.XMLReader#setProperty */ public TrAXFilter (Templates templates) throws TransformerConfigurationException { m_templates = templates; m_transformer = (TransformerImpl)templates.newTransformer(); }
/** * Create the {@link Transformer} instance used to prefer the XSLT transformation. * <p>The default implementation simply calls {@link Templates#newTransformer()}, and * configures the {@link Transformer} with the custom {@link URIResolver} if specified. * @param templates the XSLT Templates instance to create a Transformer for * @return the Transformer object * @throws TransformerConfigurationException in case of creation failure */ protected Transformer createTransformer(Templates templates) throws TransformerConfigurationException { Transformer transformer = templates.newTransformer(); if (this.uriResolver != null) { transformer.setURIResolver(this.uriResolver); } return transformer; }
/** * Create the {@link Transformer} instance used to prefer the XSLT transformation. * <p>The default implementation simply calls {@link Templates#newTransformer()}, and * configures the {@link Transformer} with the custom {@link URIResolver} if specified. * @param templates the XSLT Templates instance to create a Transformer for * @return the Transformer object * @throws TransformerConfigurationException in case of creation failure */ protected Transformer createTransformer(Templates templates) throws TransformerConfigurationException { Transformer transformer = templates.newTransformer(); if (this.uriResolver != null) { transformer.setURIResolver(this.uriResolver); } return transformer; }
public TrAXFilter(Templates templates) throws TransformerConfigurationException { _templates = templates; _transformer = (TransformerImpl) templates.newTransformer(); _transformerHandler = new TransformerHandlerImpl(_transformer); }
/** * javax.xml.transform.sax.SAXTransformerFactory implementation. * Get a TransformerHandler object that can process SAX ContentHandler * events into a Result, based on the transformation instructions * specified by the argument. * * @param templates Represents a pre-processed stylesheet * @return A TransformerHandler object that can handle SAX events * @throws TransformerConfigurationException */ public TransformerHandler newTransformerHandler(Templates templates) throws TransformerConfigurationException { final Transformer transformer = templates.newTransformer(); final TransformerImpl internal = (TransformerImpl)transformer; return new TransformerHandlerImpl(internal); }
public Properties generate(File[] allTestFiles, String uploadDestPath) { FileOutputStream transformedHtml = null; File mergedResults = new File(folderToUpload.getAbsolutePath() + FileUtil.fileseparator() + TEST_RESULTS_FILE); File mergedResource = null; FileInputStream mergedFileStream = null; try { mergedResource = mergeAllTestResultToSingleFile(allTestFiles); transformedHtml = new FileOutputStream(mergedResults); try { mergedFileStream = new FileInputStream(mergedResource); Source xmlSource = new StreamSource(mergedFileStream); StreamResult result = new StreamResult(transformedHtml); templates.newTransformer().transform(xmlSource, result); } catch (Exception e) { publisher.reportErrorMessage("Unable to publish test properties. Error was " + e.getMessage(), e); } extractProperties(mergedResults); publisher.upload(mergedResults, uploadDestPath); return null; } catch (Exception e) { publisher.reportErrorMessage("Unable to publish test properties. Error was " + e.getMessage(), e); } finally { IOUtils.closeQuietly(mergedFileStream); IOUtils.closeQuietly(transformedHtml); if (mergedResource != null) { mergedResource.delete(); } } return new Properties(); }
/** * Default constructor. Calls <code>startup()</code> if it has not been called before. * * @throws MaryConfigurationException * MaryConfigurationException * @see #startup() */ public MaryNormalisedWriter() throws MaryConfigurationException { try { // startup every time: startup(); transformer = stylesheet.newTransformer(); } catch (Exception e) { throw new MaryConfigurationException("Cannot initialise XML writing code", e); } }
/** * Default constructor. Calls <code>startup()</code> if it has not been called before. * * @throws MaryConfigurationException * MaryConfigurationException * @see #startup() */ public MaryNormalisedWriter() throws MaryConfigurationException { try { // startup every time: startup(); transformer = stylesheet.newTransformer(); } catch (Exception e) { throw new MaryConfigurationException("Cannot initialise XML writing code", e); } }
@Override public void process(final InputStream rawIn, final OutputStream out) throws IOException { try (final InputStream in = new BufferedInputStream(rawIn)) { final Templates templates; if (cache != null) { templates = cache.get(path); } else { templates = newTemplates(context, path); } final Transformer transformer = templates.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, (indentOutput ? "yes" : "no")); // pass all dynamic properties to the transformer for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (entry.getKey().isDynamic()) { String value = context.newPropertyValue(entry.getValue()).evaluateAttributeExpressions(original).getValue(); transformer.setParameter(entry.getKey().getName(), value); } } // use a StreamSource with Saxon StreamSource source = new StreamSource(in); StreamResult result = new StreamResult(out); transformer.transform(source, result); } catch (final Exception e) { throw new IOException(e); } } });
/** * javax.xml.transform.sax.TransformerFactory implementation. * Process the Source into a Templates object, which is a a compiled * representation of the source. Note that this method should not be * used with XSLTC, as the time-consuming compilation is done for each * and every transformation. * * @return A Templates object that can be used to create Transformers. * @throws TransformerConfigurationException */ public Transformer newTransformer(Source source) throws TransformerConfigurationException { final Templates templates = newTemplates(source); final Transformer transformer = templates.newTransformer(); if (_uriResolver != null) { transformer.setURIResolver(_uriResolver); } return(transformer); }
public MaryData process(MaryData d) throws Exception { DOMSource domSource = new DOMSource(d.getDocument()); Transformer transformer = stylesheet.newTransformer(); // Log transformation errors to client: if (doWarnClient) { // Use custom error handler: transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.APML transformer")); } // Transform DOMSource into a DOMResult Document maryxmlDocument = docBuilder.newDocument(); DOMResult domResult = new DOMResult(maryxmlDocument); transformer.transform(domSource, domResult); MaryData result = new MaryData(outputType(), d.getLocale()); result.setDocument(maryxmlDocument); return result; } }
public MaryData process(MaryData d) throws Exception { DOMSource domSource = new DOMSource(d.getDocument()); Transformer transformer = stylesheet.newTransformer(); // Log transformation errors to client: if (doWarnClient) { // Use custom error handler: transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.SSML transformer")); } // Transform DOMSource into a DOMResult Document maryxmlDocument = docBuilder.newDocument(); DOMResult domResult = new DOMResult(maryxmlDocument); transformer.transform(domSource, domResult); MaryData result = new MaryData(outputType(), d.getLocale()); result.setDocument(maryxmlDocument); return result; } }
public MaryData process(MaryData d) throws Exception { DOMSource domSource = new DOMSource(d.getDocument()); Transformer transformer = stylesheet.newTransformer(); // Log transformation errors to client: if (doWarnClient) { // Use custom error handler: transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.Sable transformer")); } // Transform DOMSource into a DOMResult Document maryxmlDocument = docBuilder.newDocument(); DOMResult domResult = new DOMResult(maryxmlDocument); transformer.transform(domSource, domResult); MaryData result = new MaryData(outputType(), d.getLocale()); result.setDocument(maryxmlDocument); return result; } }
public MaryData process(MaryData d) throws Exception { DOMSource domSource = new DOMSource(d.getDocument()); Transformer transformer = stylesheet.newTransformer(); // Log transformation errors to client: if (doWarnClient) { // Use custom error handler: transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.Sable transformer")); } // Transform DOMSource into a DOMResult Document maryxmlDocument = docBuilder.newDocument(); DOMResult domResult = new DOMResult(maryxmlDocument); transformer.transform(domSource, domResult); MaryData result = new MaryData(outputType(), d.getLocale()); result.setDocument(maryxmlDocument); return result; } }
public MaryData process(MaryData d) throws Exception { DOMSource domSource = new DOMSource(d.getDocument()); Transformer transformer = stylesheet.newTransformer(); // Log transformation errors to client: if (doWarnClient) { // Use custom error handler: transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.SSML transformer")); } // Transform DOMSource into a DOMResult Document maryxmlDocument = docBuilder.newDocument(); DOMResult domResult = new DOMResult(maryxmlDocument); transformer.transform(domSource, domResult); MaryData result = new MaryData(outputType(), d.getLocale()); result.setDocument(maryxmlDocument); return result; } }
public MaryData process(MaryData d) throws Exception { DOMSource domSource = new DOMSource(d.getDocument()); Transformer transformer = stylesheet.newTransformer(); // Log transformation errors to client: if (doWarnClient) { // Use custom error handler: transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.APML transformer")); } // Transform DOMSource into a DOMResult Document maryxmlDocument = docBuilder.newDocument(); DOMResult domResult = new DOMResult(maryxmlDocument); transformer.transform(domSource, domResult); MaryData result = new MaryData(outputType(), d.getLocale()); result.setDocument(maryxmlDocument); return result; } }
Transformer transformer = stylesheet.newTransformer();
Transformer transformer = stylesheet.newTransformer();
(TransformerImpl) templates.newTransformer(); transformer.setURIResolver(m_uriResolver); TransformerHandler th =