Skip to content

qie.applyXSLTransform

Signature: qie.applyXSLTransform(xslTemplate, value)

Returns: String transformedXml - the transformed XML document

Apply an XSL transform to an XML document.

Note

XSL document stored in a system variable allows transform caching which results in better performance.

Parameters

Type Name Description Default
String xslTemplate the name of the global or local variable which contains the XSL document (must be a String variable) or the XSL document as a string
String value the XML to be transformed

Example

// Apply an XSL transform to XML and return the resulting HTML
var xslTransform = `
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <head>
        <title>Bookstore</title>
      </head>
      <body>
        <h2>Bookstore Inventory</h2>
        <table border="1">
          <tr>
            <th>Title</th>
            <th>Author</th>
            <th>Price</th>
          </tr>
          <xsl:for-each select="bookstore/book">
            <tr>
              <td><xsl:value-of select="title"/></td>
              <td><xsl:value-of select="author"/></td>
              <td><xsl:value-of select="price"/></td>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
`;
var xml = `
<bookstore>
  <book>
    <title>Harry Potter</title>
    <author>J.K. Rowling</author>
    <price>29.99</price>
  </book>
  <book>
    <title>The Hobbit</title>
    <author>J.R.R. Tolkien</author>
    <price>19.99</price>
  </book>
</bookstore>
`;
var resultingHtml = qie.applyXSLTransform(xslTransform, xml);