javax.xml.transform.TransformerConfigurationException Java Examples

The following examples show how to use javax.xml.transform.TransformerConfigurationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmartTransformerFactoryImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Create a Transformer object that copies the input document to the
 * result. Uses the com.sun.org.apache.xalan.internal.processor.TransformerFactory.
 * @return A Transformer object.
 */
public Transformer newTransformer()
    throws TransformerConfigurationException
{
    if (_xalanFactory == null) {
        createXalanTransformerFactory();
    }
    if (_errorlistener != null) {
        _xalanFactory.setErrorListener(_errorlistener);
    }
    if (_uriresolver != null) {
        _xalanFactory.setURIResolver(_uriresolver);
    }
    _currFactory = _xalanFactory;
    return _currFactory.newTransformer();
}
 
Example #2
Source File: XmlUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Create a transformer from a stylesheet
 *
 * @param source DOMSource
 *
 * @return the Transformer
 */
public static Transformer createTransformer(DOMSource source)
{
  if(log.isDebugEnabled())
  {
    log.debug("createTransformer(DOMSource " + source + ")");
  }

  Transformer transformer = null;
  TransformerFactory transformerFactory = TransformerFactory.newInstance();
  URIResolver resolver = new URIResolver();
  transformerFactory.setURIResolver(resolver);

  try
  {
    transformer = transformerFactory.newTransformer(source);
  }
  catch(TransformerConfigurationException e)
  {
    log.error(e.getMessage(), e);
  }

  return transformer;

}
 
Example #3
Source File: TemplatesParser.java    From everrest with Eclipse Public License 2.0 6 votes vote down vote up
public Templates parseTemplates(Source source) throws TransformerConfigurationException, SAXException, IOException {
    InputSource inputSource = SAXSource.sourceToInputSource(source);
    if (inputSource == null) {
        throw new RuntimeException("Unable convert to Input Source");
    }

    SAXTransformerFactory saxTransformerFactory = createFeaturedSaxTransformerFactory();
    TemplatesHandler templateHandler = saxTransformerFactory.newTemplatesHandler();
    XMLReader xmlReader = XMLReaderFactory.createXMLReader();
    if (resolver != null) {
        xmlReader.setEntityResolver(resolver);
    }
    xmlReader.setContentHandler(templateHandler);

    xmlReader.parse(inputSource);

    Templates templates = templateHandler.getTemplates();
    if (templates == null) {
        throw new RuntimeException("Unable create templates from given source");
    }
    return templates;
}
 
Example #4
Source File: XSLTProcessor.java    From openccg with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Makes a list of templates from a series of xsltProcessors that applies those xsltProcessors
 * in order.
 * @param templateList The series of xsltProcessors used to construct the
 * filter.
 * @throws BuildException If no xsltProcessors are specified.
 */
List<Templates> makeTemplates(List<CCGBankTaskTemplates> templateList)
		throws FileNotFoundException,TransformerConfigurationException {
	List<Templates> l = new ArrayList<Templates>();
	
	for(CCGBankTaskTemplates taskTemplates : templateList) {
		for(File f : taskTemplates) {
			StreamSource ss = new StreamSource(
				new BufferedInputStream(new FileInputStream(f)));
			ss.setSystemId(f);
			
			l.add(transformerFactory.newTemplates(ss));				
		}
	}
	
	return Collections.unmodifiableList(l);
}
 
Example #5
Source File: TransformerFactoryImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * javax.xml.transform.sax.SAXTransformerFactory implementation.
 * Create an XMLFilter that uses the given source as the
 * transformation instructions.
 *
 * @param templates The source of the transformation instructions.
 * @return An XMLFilter object, or null if this feature is not supported.
 * @throws TransformerConfigurationException
 */
@Override
public XMLFilter newXMLFilter(Templates templates)
    throws TransformerConfigurationException
{
    try {
        return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
    }
    catch (TransformerConfigurationException e1) {
        if (_errorListener != null) {
            try {
                _errorListener.fatalError(e1);
                return null;
            }
            catch (TransformerException e2) {
                new TransformerConfigurationException(e2);
            }
        }
        throw e1;
    }
}
 
Example #6
Source File: XmlFactory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns properly configured (e.g. security features) factory
 * - securityProcessing == is set based on security processing property, default is true
 */
public static TransformerFactory createTransformerFactory(boolean disableSecureProcessing) throws IllegalStateException {
    try {
        TransformerFactory factory = TransformerFactory.newInstance();
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.log(Level.FINE, "TransformerFactory instance: {0}", factory);
        }
        factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
        return factory;
    } catch (TransformerConfigurationException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
        throw new IllegalStateException( ex);
    } catch (AbstractMethodError er) {
        LOGGER.log(Level.SEVERE, null, er);
        throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er);
    }
}
 
Example #7
Source File: XsltView.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Load the {@link Templates} instance for the stylesheet at the configured location.
 */
private Templates loadTemplates() throws ApplicationContextException {
	Source stylesheetSource = getStylesheetSource();
	try {
		Templates templates = this.transformerFactory.newTemplates(stylesheetSource);
		if (logger.isDebugEnabled()) {
			logger.debug("Loading templates '" + templates + "'");
		}
		return templates;
	}
	catch (TransformerConfigurationException ex) {
		throw new ApplicationContextException("Can't load stylesheet from '" + getUrl() + "'", ex);
	}
	finally {
		closeSourceIfNecessary(stylesheetSource);
	}
}
 
Example #8
Source File: SmartTransformerFactoryImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public XMLFilter newXMLFilter(Templates templates)
    throws TransformerConfigurationException {
    try {
        return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
    }
    catch(TransformerConfigurationException e1) {
        if (_xsltcFactory == null) {
            createXSLTCTransformerFactory();
        }
        ErrorListener errorListener = _xsltcFactory.getErrorListener();
        if(errorListener != null) {
            try {
                errorListener.fatalError(e1);
                return null;
            }
            catch( TransformerException e2) {
                new TransformerConfigurationException(e2);
            }
        }
        throw e1;
    }
}
 
Example #9
Source File: MCRTemplatesCompiler.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
/** Returns a new transformer for the compiled XSL templates 
 */
public static Transformer getTransformer(Templates templates) throws TransformerConfigurationException {
    Transformer tf = factory.newTransformerHandler(templates).getTransformer();

    // In debug mode, add a TraceListener to log stylesheet execution
    if (LOGGER.isDebugEnabled()) {
        try {
            TraceManager tm = ((org.apache.xalan.transformer.TransformerImpl) tf).getTraceManager();
            tm.addTraceListener(new MCRTraceListener());

        } catch (Exception ex) {
            LOGGER.warn(ex);
        }
    }

    return tf;
}
 
Example #10
Source File: CejshBuilder.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
public CejshBuilder(CejshConfig config, ExportOptions options)
        throws TransformerConfigurationException, ParserConfigurationException, XPathExpressionException {
    this.gcalendar = new GregorianCalendar(UTC);
    this.logLevel = config.getLogLevel();
    this.options = options;
    TransformerFactory xslFactory = TransformerFactory.newInstance();
    tranformationErrorHandler = new TransformErrorListener();
    bwmetaXsl = xslFactory.newTransformer(new StreamSource(config.getCejshXslUrl()));
    if (bwmetaXsl == null) {
        throw new TransformerConfigurationException("Cannot load XSL: " + config.getCejshXslUrl());
    }
    bwmetaXsl.setOutputProperty(OutputKeys.INDENT, "yes");
    bwmetaXsl.setErrorListener(tranformationErrorHandler);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    db = dbf.newDocumentBuilder();
    XPathFactory xPathFactory = ProarcXmlUtils.defaultXPathFactory();
    XPath xpath = xPathFactory.newXPath();
    xpath.setNamespaceContext(new SimpleNamespaceContext().add("m", ModsConstants.NS));
    issnPath = xpath.compile("m:mods/m:identifier[@type='issn' and not(@invalid)]");
    partNumberPath = xpath.compile("m:mods/m:titleInfo/m:partNumber");
    dateIssuedPath = xpath.compile("m:mods/m:originInfo/m:dateIssued");
    reviewedArticlePath = xpath.compile("m:mods/m:genre[text()='article' and @type='peer-reviewed']");
}
 
Example #11
Source File: TransformerFactoryImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 * Create a Transformer object that copies the input document to the result.
 *
 * @return A Transformer object that simply copies the source to the result.
 * @throws TransformerConfigurationException
 */
@Override
public Transformer newTransformer()
    throws TransformerConfigurationException
{
    TransformerImpl result = new TransformerImpl(new Properties(),
        _indentNumber, this);
    if (_uriResolver != null) {
        result.setURIResolver(_uriResolver);
    }

    if (!_isNotSecureProcessing) {
        result.setSecureProcessing(true);
    }
    return result;
}
 
Example #12
Source File: JdkXmlUtils.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static SAXTransformerFactory getSAXTransformFactory(boolean overrideDefaultParser) {
    SAXTransformerFactory tf = overrideDefaultParser
            ? (SAXTransformerFactory) SAXTransformerFactory.newInstance()
            : (SAXTransformerFactory) new TransformerFactoryImpl();
    try {
        tf.setFeature(OVERRIDE_PARSER, overrideDefaultParser);
    } catch (TransformerConfigurationException ex) {
        // ignore since it'd never happen with the JDK impl.
    }
    return tf;
}
 
Example #13
Source File: MCRXSLTransformation.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method getStylesheet. Returns a precompiled stylesheet.
 * 
 * @param stylesheet
 *            A StreamSource
 * @return Templates The precompiled Stylesheet
 */
public Templates getStylesheet(Source stylesheet) {
    try {

        return saxFactory.newTemplates(stylesheet);
    } catch (TransformerConfigurationException tcx) {
        LOGGER.fatal(tcx.getMessageAndLocation());

        return null;
    }
}
 
Example #14
Source File: SmartTransformerFactoryImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a TemplatesHandler object that can process SAX ContentHandler
 * events into a Templates object. Uses the
 * com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
 */
public TemplatesHandler newTemplatesHandler()
    throws TransformerConfigurationException
{
    if (_xsltcFactory == null) {
        createXSLTCTransformerFactory();
    }
    if (_errorlistener != null) {
        _xsltcFactory.setErrorListener(_errorlistener);
    }
    if (_uriresolver != null) {
        _xsltcFactory.setURIResolver(_uriresolver);
    }
    return _xsltcFactory.newTemplatesHandler();
}
 
Example #15
Source File: TransformerFactoryImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 src The source of the transformation instructions.
 * @return A TransformerHandler object that can handle SAX events
 * @throws TransformerConfigurationException
 */
@Override
public TransformerHandler newTransformerHandler(Source src)
    throws TransformerConfigurationException
{
    final Transformer transformer = newTransformer(src);
    if (_uriResolver != null) {
        transformer.setURIResolver(_uriResolver);
    }
    return new TransformerHandlerImpl((TransformerImpl) transformer);
}
 
Example #16
Source File: TikaEntityProcessor.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private static ContentHandler getXmlContentHandler(Writer writer)
        throws TransformerConfigurationException {
  SAXTransformerFactory factory = (SAXTransformerFactory)
          TransformerFactory.newInstance();
  TransformerHandler handler = factory.newTransformerHandler();
  handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
  handler.setResult(new StreamResult(writer));
  return handler;
}
 
Example #17
Source File: RomImage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void write( ) throws RomException, IOException
{
	// Use a Transformer for output
	TransformerFactory tFactory = TransformerFactory.newInstance();
	Transformer transformer;
	try
	{
		transformer = tFactory.newTransformer( );
	}
	catch ( TransformerConfigurationException e )
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
		throw new RomException( e );
	}
	DOMSource source = new DOMSource(document);
	FileWriter writer = new FileWriter( "docs/rom.def" );
	StreamResult result = new StreamResult( writer );
	try
	{
		transformer.transform( source, result );
	}
	catch ( TransformerException e1 )
	{
		// TODO Auto-generated catch block
		e1.printStackTrace();
		throw new RomException( e1 );
	}
	writer.close( );
}
 
Example #18
Source File: TransformerFactoryImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * javax.xml.transform.sax.SAXTransformerFactory implementation.
 * Get a TransformerHandler object that can process SAX ContentHandler
 * events into a Result. This method will return a pure copy transformer.
 *
 * @return A TransformerHandler object that can handle SAX events
 * @throws TransformerConfigurationException
 */
@Override
public TransformerHandler newTransformerHandler()
    throws TransformerConfigurationException
{
    final Transformer transformer = newTransformer();
    if (_uriResolver != null) {
        transformer.setURIResolver(_uriResolver);
    }
    return new TransformerHandlerImpl((TransformerImpl) transformer);
}
 
Example #19
Source File: AuroraWrapper.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void addResults(final Document doc, final String _benchmark, final String _score) throws TransformerConfigurationException, TransformerException, IOException {
    final Element result = getRootEntity(doc);

    addBenchmarkResults(doc, result, _benchmark, _score, "1");

    final TransformerFactory tranformerFactory = TransformerFactory.newInstance();
    final Transformer tr = tranformerFactory.newTransformer();
    tr.setOutputProperty(OutputKeys.INDENT, "yes");
    try (FileOutputStream fos = new FileOutputStream(fileName)) {
        tr.transform(new DOMSource(doc), new StreamResult(fos));
    }
}
 
Example #20
Source File: SmartTransformerFactoryImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a TransformerHandler object that can process SAX ContentHandler
 * events based on a copy transformer.
 * Uses com.sun.org.apache.xalan.internal.processor.TransformerFactory.
 */
public TransformerHandler newTransformerHandler()
    throws TransformerConfigurationException
{
    if (_xalanFactory == null) {
        createXalanTransformerFactory();
    }
    if (_errorlistener != null) {
        _xalanFactory.setErrorListener(_errorlistener);
    }
    if (_uriresolver != null) {
        _xalanFactory.setURIResolver(_uriresolver);
    }
    return _xalanFactory.newTransformerHandler();
}
 
Example #21
Source File: AuroraWrapper.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void addResults(final Document doc, final String _benchmark, final String _score) throws TransformerConfigurationException, TransformerException, IOException {
    final Element result = getRootEntity(doc);

    addBenchmarkResults(doc, result, _benchmark, _score, "1");

    final TransformerFactory tranformerFactory = TransformerFactory.newInstance();
    final Transformer tr = tranformerFactory.newTransformer();
    tr.setOutputProperty(OutputKeys.INDENT, "yes");
    try (FileOutputStream fos = new FileOutputStream(fileName)) {
        tr.transform(new DOMSource(doc), new StreamResult(fos));
    }
}
 
Example #22
Source File: ProcessorStylesheetElement.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * This method can be over-ridden by a class that extends this one.
 * @param handler The calling StylesheetHandler/TemplatesBuilder.
 */
protected Stylesheet getStylesheetRoot(StylesheetHandler handler) throws TransformerConfigurationException
{
  StylesheetRoot stylesheet;
  stylesheet = new StylesheetRoot(handler.getSchema(), handler.getStylesheetProcessor().getErrorListener());
  
  if (handler.getStylesheetProcessor().isSecureProcessing())
    stylesheet.setSecureProcessing(true);
  
  return stylesheet;
}
 
Example #23
Source File: TransformerFactoryImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
@Override
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);
}
 
Example #24
Source File: BisJmsSender.java    From iaf with Apache License 2.0 5 votes vote down vote up
public void configure() throws ConfigurationException {
	super.configure();
	if (!isSoap()) {
		throw new ConfigurationException(getLogPrefix() + "soap must be true");
	}
	try {
		bisUtils = BisUtils.getInstance();
		bisErrorTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisUtils.getSoapNamespaceDefs() + "\n" + bisUtils.getBisNamespaceDefs(), (isResultInPayload() ? bisUtils.getBisErrorXPath() : bisUtils.getOldBisErrorXPath()), "text"));
		responseTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(StringUtils.isNotEmpty(getResponseNamespaceDefs()) ? bisUtils.getSoapNamespaceDefs() + "\n" + getResponseNamespaceDefs() : bisUtils.getSoapNamespaceDefs(), StringUtils.isNotEmpty(getResponseXPath()) ? bisUtils.getSoapBodyXPath() + "/" + getResponseXPath() : bisUtils.getSoapBodyXPath() + "/*", "xml"));
		bisErrorListTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisUtils.getSoapNamespaceDefs() + "\n" + bisUtils.getBisNamespaceDefs(), (isResultInPayload() ? bisUtils.getBisErrorListXPath() : bisUtils.getOldBisErrorListXPath()), "xml"));
	} catch (TransformerConfigurationException e) {
		throw new ConfigurationException(getLogPrefix() + "cannot create transformer", e);
	}
}
 
Example #25
Source File: SmartTransformerFactoryImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Get a TransformerHandler object that can process SAX ContentHandler
 * events based on a transformer specified by the stylesheet Source.
 * Uses com.sun.org.apache.xalan.internal.processor.TransformerFactory.
 */
public TransformerHandler newTransformerHandler(Source src)
    throws TransformerConfigurationException
{
    if (_xalanFactory == null) {
        createXalanTransformerFactory();
    }
    if (_errorlistener != null) {
        _xalanFactory.setErrorListener(_errorlistener);
    }
    if (_uriresolver != null) {
        _xalanFactory.setURIResolver(_uriresolver);
    }
    return _xalanFactory.newTransformerHandler(src);
}
 
Example #26
Source File: MCRIFSCommands.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@MCRCommand(syntax = "generate md5 file report in directory {0}",
    help = "generates XML a report over all content stores about failed md5 checks and write it in directory {0}")
public static void writeFileMD5Report(String targetDirectory) throws IOException, SAXException,
    TransformerConfigurationException {
    File targetDir = getDirectory(targetDirectory);
    FSNodeChecker checker = new MD5Checker();
    writeReport(targetDir, checker);
}
 
Example #27
Source File: Util.java    From act with GNU General Public License v3.0 5 votes vote down vote up
public static String documentToString(Document doc)
    throws ParserConfigurationException, TransformerConfigurationException, TransformerException {
  StringWriter stringWriter = new StringWriter();
  DOMSource source = new DOMSource(doc);
  StreamResult result = new StreamResult(stringWriter);
  Transformer transformer = getTransformerFactory().newTransformer();
  transformer.transform(source, result);
  return stringWriter.toString();
}
 
Example #28
Source File: TransformerFactoryImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * javax.xml.transform.sax.SAXTransformerFactory implementation.
 * Get a TransformerHandler object that can process SAX ContentHandler
 * events into a Result. This method will return a pure copy transformer.
 *
 * @return A TransformerHandler object that can handle SAX events
 * @throws TransformerConfigurationException
 */
@Override
public TransformerHandler newTransformerHandler()
    throws TransformerConfigurationException
{
    final Transformer transformer = newTransformer();
    if (_uriResolver != null) {
        transformer.setURIResolver(_uriResolver);
    }
    return new TransformerHandlerImpl((TransformerImpl) transformer);
}
 
Example #29
Source File: SoapWrapper.java    From iaf with Apache License 2.0 5 votes vote down vote up
private void init() throws ConfigurationException {
	try {
		extractBodySoap11  = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_BODY_XPATH, "xml", false, null, false));
		extractBodySoap12  = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP12, EXTRACT_BODY_XPATH, "xml", false, null, false));
		extractHeader      = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_HEADER_XPATH, "xml"));
		extractFaultCount  = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_FAULTCOUNTER_XPATH, "text"));
		extractFaultCode   = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_FAULTCODE_XPATH, "text"));
		extractFaultString = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_FAULTSTRING_XPATH, "text"));
	} catch (TransformerConfigurationException e) {
		throw new ConfigurationException("cannot create SOAP transformer", e);
	}
}
 
Example #30
Source File: DomAnnotationParserFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
AnnotationParserImpl(boolean disableSecureProcessing) {
    try {
        SAXTransformerFactory factory = stf.get();
        factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, disableSecureProcessing);
        transformer = factory.newTransformerHandler();
    } catch (TransformerConfigurationException e) {
        throw new Error(e); // impossible
    }
}