@Override public void write(OutputStream outputStream) throws IOException { if (getTransformer() == null) { Context .getCurrentLogger() .warning( "Unable to apply the transformation. No transformer found!"); } else { try { // Generates the result of the transformation getTransformer().transform(getSaxSource(), new StreamResult(outputStream)); } catch (TransformerException te) { throw new IOException("Transformer exception. " + te.getMessage()); } } } }
/** * Returns the SAX transformer handler associated to the transform sheet. * * @return The SAX transformer handler. * @throws IOException */ public TransformerHandler getTransformerHandler() throws IOException { TransformerHandler result = null; final Templates templates = getTemplates(); if (templates != null) { try { result = getSaxTransformerFactory().newTransformerHandler( templates); } catch (TransformerConfigurationException tce) { throw new IOException("Transformer configuration exception. " + tce.getMessage()); } } return result; }
/** * Returns the SAX source associated to the source representation. * * @return The SAX source associated to the source representation. * @throws IOException */ public SAXSource getSaxSource() throws IOException { return toSaxSource(getSourceRepresentation()); }
/** * Writes the transformed source into the given JAXP result. The source is * retrieved using the {@link #getSaxSource()} method. * * @param result * The JAXP result object. * @throws IOException */ public void write(Result result) throws IOException { transform(getSaxSource(), result); }
Templates templates = getTemplates(); if (getErrorListener() != null) { result.setErrorListener(getErrorListener()); if (getUriResolver() != null) { result.setURIResolver(getUriResolver()); for (String name : getParameters().keySet()) { result.setParameter(name, getParameters().get(name)); for (String name : getOutputProperties().keySet()) { result.setOutputProperty(name, getOutputProperties().get(name));
+ "/Mail.xslt").get(); TransformRepresentation result = new TransformRepresentation(rmepMail, transformSheet); result.getOutputProperties().put(OutputKeys.INDENT, "yes"); return result;
wadl2htmlXsltUrl.openStream(), MediaType.APPLICATION_W3C_XSLT); representation = new TransformRepresentation( Context.getCurrent(), this, xslRep); representation.setMediaType(MediaType.TEXT_HTML);
if (getTransformSheet() != null) { try { getTransformSheet().getStream()); if (getTransformSheet().getIdentifier() != null) { transformSource.setSystemId(getTransformSheet() .getIdentifier().getTargetRef().toString()); if (getUriResolver() != null) { transformerFactory.setURIResolver(getUriResolver());
if (getSourceRepresentation() instanceof XmlRepresentation) { source = ((XmlRepresentation) getSourceRepresentation()) .getSaxSource(); } else if (getSourceRepresentation() instanceof TransformRepresentation) { final TransformRepresentation lastTR = (TransformRepresentation) getSourceRepresentation(); TransformRepresentation rootTR = lastTR; final XMLFilter lastFilter = lastTR.getXmlFilter(); XMLFilter rootFilter = lastFilter; XMLFilter currFilter = null; while (rootTR.getSourceRepresentation() instanceof TransformRepresentation) { rootTR = (TransformRepresentation) rootTR .getSourceRepresentation(); currFilter = rootTR.getXmlFilter(); rootFilter.setParent(currFilter); rootFilter = currFilter; if (rootTR.getSourceRepresentation() instanceof XmlRepresentation) { rootSource = ((XmlRepresentation) rootTR .getSourceRepresentation()).getSaxSource() .getInputSource(); } else { rootSource = new InputSource(rootTR.getSourceRepresentation() .getStream()); source = new SAXSource(new InputSource(getSourceRepresentation() .getStream())); if (getSourceRepresentation().getIdentifier() != null) {
/** * Transforms the given JAXP source into the given result. * * @param source * The JAXP source object. * @param result * The JAXP result object. * @throws IOException */ public void transform(Source source, Result result) throws IOException { if (getTransformer() == null) { Context.getCurrentLogger() .warning( "Unable to apply the transformation. No transformer found!"); } else { try { // Generates the result of the transformation getTransformer().transform(source, result); } catch (TransformerException te) { throw new IOException("Transformer exception. " + te.getMessage()); } } }
final Templates templates = getTemplates(); result.setURIResolver(getUriResolver()); for (final String name : getParameters().keySet()) { result.setParameter(name, getParameters().get(name)); for (final String name : getOutputProperties().keySet()) { result.setOutputProperty(name, getOutputProperties().get( name));
/** * Transforms a source XML representation by applying an XSLT transform * sheet to it. * * @param source * The source XML representation. * @return The generated result representation. */ public Representation transform(Representation source) { final Representation result = new TransformRepresentation(getContext(), source, getTransformSheet()); if (this.resultLanguages != null) { result.getLanguages().addAll(getResultLanguages()); } result.setCharacterSet(getResultCharacterSet()); if (this.resultEncodings != null) { result.getEncodings().addAll(getResultEncodings()); } result.setMediaType(getResultMediaType()); return result; }
if (getTransformSheet() != null) { try { getTransformSheet().getStream()); if (getTransformSheet().getLocationRef() != null) { transformSource.setSystemId(getTransformSheet() .getLocationRef().getTargetRef().toString()); if (getUriResolver() != null) { transformerFactory.setURIResolver(getUriResolver());
/** * Returns the SAX transformer handler associated to the transform sheet. * * @return The SAX transformer handler. * @throws IOException */ public TransformerHandler getTransformerHandler() throws IOException { TransformerHandler result = null; Templates templates = getTemplates(); if (templates != null) { try { result = getSaxTransformerFactory().newTransformerHandler( templates); } catch (TransformerConfigurationException tce) { throw new IOException("Transformer configuration exception. " + tce.getMessage()); } } return result; }
/** * Transforms a source XML representation by applying an XSLT transform * sheet to it. * * @param source * The source XML representation. * @return The generated result representation. */ public Representation transform(Representation source) { final Representation result = new TransformRepresentation(getContext(), source, getTransformSheet()); if (this.resultLanguages != null) { result.getLanguages().addAll(getResultLanguages()); } result.setCharacterSet(getResultCharacterSet()); if (this.resultEncodings != null) { result.getEncodings().addAll(getResultEncodings()); } result.setMediaType(getResultMediaType()); return result; }
/** * Parses the input source by sending the result event to the * XML reader's content handler. * * @param input * The input source. */ public void parse(InputSource input) throws IOException, SAXException { try { source.getTransformer().transform( source.getSaxSource(), new SAXResult(getContentHandler())); } catch (TransformerException te) { throw new IOException("Transformer exception. " + te.getMessage()); } }
/** * Returns the SAX XML filter applying the transform sheet to its input. * * @return The SAX XML filter. * @throws IOException */ public XMLFilter getXmlFilter() throws IOException { XMLFilter result = null; final Templates templates = getTemplates(); if (templates != null) { try { result = getSaxTransformerFactory().newXMLFilter(templates); } catch (TransformerConfigurationException tce) { throw new IOException("Transformer configuration exception. " + tce.getMessage()); } } return result; }
/** * Returns the SAX XML filter applying the transform sheet to its input. * * @return The SAX XML filter. * @throws IOException */ public XMLFilter getXmlFilter() throws IOException { XMLFilter result = null; final Templates templates = getTemplates(); if (templates != null) { try { result = getSaxTransformerFactory().newXMLFilter(templates); } catch (TransformerConfigurationException tce) { throw new IOException("Transformer configuration exception. " + tce.getMessage()); } } return result; }