Transforms a config file with an XSLT transform.

@param name file name of the config file
@param transform file name of the XSLT file

@throws Exception if something goes wrong
343697
public void transform(String name, String transform) throws Exception {

        File configFile = new File(m_configDir, name);
        File transformFile = new File(m_xsltDir, transform);
        try (InputStream stream = new FileInputStream(transformFile)) {
            StreamSource source = new StreamSource(stream);
            transform(configFile, source);
        }
    }
159018
private void writeDocument( Document document, File file )
        throws TransformerException, FileNotFoundException
    {
        document.normalize();
        DOMSource source = new DOMSource( document );
        StreamResult result = new StreamResult( new FileOutputStream( file ) );
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty( OutputKeys.INDENT, "yes" );
        transformer.transform( source, result );
    }
307689
public void transform( InputStream xmlIS,
                           InputStream xslIS,
                           Map params,
                           OutputStream result,
                           String encoding) {
        try {
            TransformerFactory trFac = TransformerFactory.newInstance();
            Transformer transformer = trFac.newTransformer(new StreamSource(xslIS));
            Iterator it = params.keySet().iterator();
            while (it.hasNext()) {
                String key = (String)it.next();
                transformer.setParameter(key, (String)params.get(key));
            }
            transformer.setOutputProperty("encoding", encoding);
            transformer.transform(new StreamSource(xmlIS), new StreamResult(result));
        } catch (Exception e) {
            getLogger().severe("XmlHttpProxy: Exception with xslt " + e);
        }
    }
888082
public void execute(
          TransformerImpl transformer)
            throws TransformerException
  {

    int sourceNode = transformer.getXPathContext().getCurrentNode();
    String countString = getCountString(transformer, sourceNode);

    try
    {
      transformer.getResultTreeHandler().characters(countString.toCharArray(),
                                                    0, countString.length());
    }
    catch(SAXException se)
    {
      throw new TransformerException(se);
    }
  }
597715
public static function transform($xslFileName, DOMDocument $xml)
    {
        $xsl = new DOMDocument;
        $xsl->load(__DIR__.'/../../xslt/'.$xslFileName.'.xsl');

        $proc = new XSLTProcessor;
        $proc->importStyleSheet($xsl);

        libxml_use_internal_errors(true);

        $result = $proc->transformToXML($xml);

        foreach (libxml_get_errors() as $error) {
            //throw new \Exception($error->message);
        }

        return $result;
    }
981767
public static String xmlToString(Document document) throws Exception {
        if (transformer == null) {
            throw new Exception("Transformer is null");
        }
        Source xmlSource = new DOMSource(document);
        StringWriter stringWriter = new StringWriter();
        Result result = new StreamResult(stringWriter);
        transformer.transform(xmlSource, result);
        return stringWriter.toString();
    }
1206700
public static transformaction get(nitro_service service, String name) throws Exception{
		transformaction obj = new transformaction();
		obj.set_name(name);
		transformaction response = (transformaction) obj.get_resource(service);
		return response;
	}
646199
def _transform(xsl_filename, xml, **kwargs):
    """"""
    xslt = _make_xsl(xsl_filename)
    xml = xslt(xml, **kwargs)
    return xml
459491
public void execute(TransformerImpl transformer) throws TransformerException
  {    
    XPathContext context = transformer.getXPathContext();

    // Verify that result has not already been set by another result
    // element. Recursion is allowed: intermediate results are cleared 
    // in the owner ElemExsltFunction execute().
    if (transformer.currentFuncResultSeen()) {
        throw new TransformerException("An EXSLT function cannot set more than one result!");
    }

    int sourceNode = context.getCurrentNode();

    // Set the return value;
    XObject var = getValue(transformer, sourceNode);
    transformer.popCurrentFuncResult();
    transformer.pushCurrentFuncResult(var);
  }
407980
private static InputStream transform(final TransformerFactory factory,
        final InputStream xml) throws TransformerException {
        final byte[] input;
        try {
            input = RsXslt.consume(xml);
        } catch (final IOException ex) {
            throw new IllegalStateException(ex);
        }
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final Source xsl = RsXslt.stylesheet(
            factory, new StreamSource(
                new Utf8InputStreamContent(
                    new ByteArrayInputStream(new Utf8String(input).asBytes())
                )
            )
        );
        RsXslt.transformer(factory, xsl).transform(
            new StreamSource(
                new Utf8InputStreamContent(
                    new ByteArrayInputStream(new Utf8String(input).asBytes())
                )
            ),
            new StreamResult(
                new Utf8OutputStreamContent(baos)
            )
        );
        return new ByteArrayInputStream(
            new Utf8String(baos.toByteArray()).asBytes()
        );
    }
1092347
public void execute(
          TransformerImpl transformer)
            throws TransformerException
  {
    try
    {
      SerializationHandler rth = transformer.getResultTreeHandler();

        if (m_disableOutputEscaping)
      {
        rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
      }

      rth.characters(m_ch, 0, m_ch.length);

      if (m_disableOutputEscaping)
      {
        rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
      }
    }
    catch(SAXException se)
    {
      throw new TransformerException(se);
    }
  }
1181961
public void setTransform(Element element, String transform) {
		if (transform.contains("scale")) {
			try {
				String scaleValue = transform.substring(transform.indexOf("scale(") + 6);
				scaleValue = scaleValue.substring(0, scaleValue.indexOf(")"));
				Dom.setStyleAttribute(element, "zoom", scaleValue);
			} catch (Exception e) {
			}
		}
	}
533934
public void generate(final File fileName) {
        final File outputFile = removeTemplatePrefix(fileName);
        templateFile = fileName;

        try (final InputStream in = new BufferedInputStream(new FileInputStream(fileName));
             final OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) {
            final Transformer transformer = TransformerFactory.newInstance().newTransformer();
            final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
            parserFactory.setNamespaceAware(true);
            XMLReader reader = parserFactory.newSAXParser().getXMLReader();
            this.setContentHandler(null);
            this.setParent(reader);
            reader = this;
            final Source source = new SAXSource(reader, new InputSource(in));
            source.setSystemId(fileName.toURI().toString());
            final Result result = new StreamResult(out);
            transformer.transform(source, result);
        } catch (final RuntimeException e) {
            throw e;
        } catch (final Exception e) {
            logger.error("Failed to transform " + fileName + ": " + e.getMessage(), e);
        }
    }
69211
public void transform(final File inputFile, final List<XMLFilter> filters) throws DITAOTException {
        final File outputFile = new File(inputFile.getAbsolutePath() + FILE_EXTENSION_TEMP);
        transformFile(inputFile, outputFile, filters);
        try {
            deleteQuietly(inputFile);
            moveFile(outputFile, inputFile);
        } catch (final RuntimeException e) {
            throw e;
        } catch (final Exception e) {
            throw new DITAOTException("Failed to replace " + inputFile + ": " + e.getMessage());
        }
    }
52890
private static Transformer transformer(final TransformerFactory factory,
        final Source stylesheet) throws TransformerConfigurationException {
        final Transformer tnfr = factory.newTransformer(stylesheet);
        if (tnfr == null) {
            throw new TransformerConfigurationException(
                String.format(
                    "%s failed to create new XSL transformer for '%s'",
                    factory.getClass(),
                    stylesheet.getSystemId()
                )
            );
        }
        return tnfr;
    }
289721
@Override
    public void transform(InputStream inputStream, OutputStream outputStream) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, CS_WIN1252))) {
            String line;
            String closingTag = null;
            Stack<String> stack = new Stack<>();
            String id = null;
            String url = null;
            String label = null;
            
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                int i = line.indexOf('>', 1);
                int j = line.indexOf(' ', 1);
                int end = i == -1 ? j : j == -1 ? i : i < j ? i : j;
                int token = ArrayUtils.indexOf(TOKENS, end < 1 ? "" : line.substring(1, end).toLowerCase());
                
                if (stack.isEmpty() && token != 0) {
                    continue;
                }
                
                switch (token) {
                    case 0: // <ul>
                        if (closingTag != null) {
                            write(outputStream, ">", true, 0);
                            closingTag = "</topic>";
                        }
                        
                        stack.push(closingTag);
                        closingTag = null;
                        break;
                        
                    case 1: // </ul>
                        write(outputStream, closingTag, true, 0);
                        closingTag = stack.pop();
                        writeClosingTag(outputStream, closingTag, stack.size());
                        closingTag = null;
                        break;
                        
                    case 2: // <li>
                        writeClosingTag(outputStream, closingTag, 0);
                        write(outputStream, "<topic", false, stack.size());
                        closingTag = " />";
                        break;
                        
                    case 3: // <param>
                        String name = extractAttribute("name", line);
                        String value = extractAttribute("value", line);
                        
                        if ("name".equalsIgnoreCase(name)) {
                            if (label == null) {
                                label = value;
                            } else {
                                id = value;
                            }
                        } else if ("local".equalsIgnoreCase(name)) {
                            url = value;
                        }
                        break;
                        
                    case 4: // </object>
                        writeAttribute(outputStream, "id", id);
                        writeAttribute(outputStream, "label", label);
                        writeAttribute(outputStream, "url", url);
                        id = label = url = null;
                        break;
                }
            }
        }
    }
1134381
protected void configureTransformerInstance(final IClassTransformer transformerInstance,
                                              final Properties properties) throws Exception {
    if (null == transformerInstance || !(transformerInstance instanceof ClassTransformer)) {
      return;
    }
    ((ClassTransformer)transformerInstance).configure(properties);
  }