Example usage for javax.xml.transform Transformer clearParameters

List of usage examples for javax.xml.transform Transformer clearParameters

Introduction

In this page you can find the example usage for javax.xml.transform Transformer clearParameters.

Prototype

public abstract void clearParameters();

Source Link

Document

Clear all parameters set with setParameter.

Usage

From source file:org.jaggeryjs.hostobjects.xslt.XSLTHostObject.java

private static void setParams(Transformer transformer, NativeObject paramMap) {
    transformer.clearParameters();
    Object[] ids = paramMap.getIds();
    for (Object id : ids) {
        String key = (String) id;
        Object obj = paramMap.get(key, paramMap);
        transformer.setParameter(key, HostObjectUtil.serializeObject(obj));
    }//from ww w . j a  v  a 2  s .com
}

From source file:org.jzkit.search.util.RecordConversion.XSLFragmentTransformer.java

public void performTransformation(javax.xml.transform.Source source, javax.xml.transform.Result result,
        Map trans_properties) {//from w w  w.  ja va2s.c  o  m
    try {
        checkStylesheetDatestamp();

        Transformer trans = t.newTransformer();

        // Transformer objects are transient stateful objects that track the application
        // of a specific transformation to a given source and the resulting output.
        // Will be cleaned up when it goes out of scope. N.B. We use the newTemplates
        // method of the TemplateFactory since we expect multithreaded execution of and
        // repeated use of specific transformations.

        // We pass in any params to the transformation
        trans.clearParameters();
        if (trans_properties != null) {
            Set<Map.Entry> entries = trans_properties.entrySet();
            for (java.util.Iterator i = entries.iterator(); i.hasNext();) {
                Map.Entry e = (Map.Entry) i.next();
                trans.setParameter(e.getKey().toString(), e.getValue().toString());
            }
        }

        trans.transform(source, result);
    } catch (javax.xml.transform.TransformerConfigurationException tce) {
        log.warn("TransformerConfigurationException exception finding template " + the_path, tce);
    } catch (javax.xml.transform.TransformerException te) {
        log.warn("TransformerException General exception finding template " + the_path, te);
    } catch (Exception e) {
        log.warn("General exception finding template " + the_path, e);
    }
}

From source file:org.openedit.entermedia.generators.XsltGenerator.java

/**
 * Run the given page through the stylesheet specified in its config file and output the result
 * to the given output stream.  This generator accepts a configuration which looks like this:
 * <pre>/*from w w w  .  j  av a2s. c  o m*/
 * &lt;generator name="xslt"&gt;
 *   &lt;stylesheet&gt;/path/to/my/stylesheet.xsl&lt;/stylesheet&gt;
 *   [&lt;use-request-parameters&gt;true&lt;/use-request-parameters&gt;]
 *   [&lt;generator&gt;...&lt;/generator&gt;]
 * &lt;/generator&gt;
 * </pre>
 *
 * @see Generator#generate(Page, WebPageContext)
 */
public void generate(WebPageRequest inContext, Page inPage, Output inOut) throws OpenEditException {
    // Put all the request parameters as parameters to the stylesheet, if
    // the user so desired.  In addition, pass "requestURI" and
    // "queryString" parameters, which have the obvious values.
    try {
        String template = inContext.findValue("xsltlayout");
        Transformer transformer = getTransformer(template);

        if (Boolean.parseBoolean(inContext.findValue("xsltaddrequestparameters"))) {
            populateParameters(inContext, transformer);
        }

        StreamResult result = new StreamResult(inOut.getWriter());
        String home = (String) inContext.getPageValue("home");
        transformer.setParameter("home", home);

        if (!inPage.exists()) {
            inPage = getPageManager().getPage(PathUtilities.extractPagePath(inPage.getPath()) + ".xml");
        }
        StreamSource xmlSource = new StreamSource(inPage.getReader());
        transformer.transform(xmlSource, result);
        transformer.clearParameters();
        inOut.getWriter().flush();
    } catch (Exception ex) {
        throw new OpenEditException(ex);
    }
}

From source file:org.pentaho.di.trans.steps.xslt.XsltData.java

public Transformer getTemplate(String xslFilename, boolean isAfile) throws Exception {
    Transformer template = transformers.get(xslFilename);
    if (template != null) {
        template.clearParameters();
        return template;
    }//from  ww  w .j a v a 2 s  .  co  m

    return createNewTemplate(xslFilename, isAfile);
}