Name: xsltApplyStylesheet

Type: function

Syntax: xsltApplyStylesheet xmlDocID, xsltStylesheetID

Summary: 

Introduced: 6.5

OS: mac,windows,linux,ios,android,windows_mobile,linux_mobile

Platforms: desktop,server,web,mobile

Example:
put xsltApplyStylesheet(tDocID, tStylesheetID) into tProcessedData

The result: &lt;!-- order the result by revenue --&gt;&#13;.

Description:
The xsltApplyStylesheet function returns the data set resulting from applying the xslt document against the specified xml document. For instance, given xml data of

&lt;sales&gt;&#13;
        &lt;division id="North"&gt;&#13;
                &lt;revenue&gt;10&lt;/revenue&gt;&#13;
                &lt;growth&gt;9&lt;/growth&gt;&#13;
                &lt;bonus&gt;7&lt;/bonus&gt;&#13;
        &lt;/division&gt;&#13;
        &lt;division id="South"&gt;&#13;
                &lt;revenue&gt;4&lt;/revenue&gt;&#13;
                &lt;growth&gt;3&lt;/growth&gt;&#13;
                &lt;bonus&gt;4&lt;/bonus&gt;&#13;
        &lt;/division&gt;&#13;
        &lt;division id="West"&gt;&#13;
                &lt;revenue&gt;6&lt;/revenue&gt;&#13;
                &lt;growth&gt;-1.5&lt;/growth&gt;&#13;
                &lt;bonus&gt;2&lt;/bonus&gt;&#13;
        &lt;/division&gt;&#13;
&lt;/sales&gt;

and an xslt document of

&lt;html xsl:version="1.0"&#13;
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&#13;
      lang="en"&gt;&#13;
    &lt;head&gt;&#13;
        &lt;title&gt;Sales Results By Division&lt;/title&gt;&#13;
    &lt;/head&gt;&#13;
    &lt;body&gt;&#13;
        &lt;table border="1"&gt;&#13;
            &lt;tr&gt;&#13;
                &lt;th&gt;Division&lt;/th&gt;&#13;
                &lt;th&gt;Revenue&lt;/th&gt;&#13;
                &lt;th&gt;Growth&lt;/th&gt;&#13;
                &lt;th&gt;Bonus&lt;/th&gt;&#13;
            &lt;/tr&gt;&#13;
            &lt;xsl:for-each select="sales/division"&gt;&#13;
                &lt;xsl:sort select="revenue"&#13;
                          data-type="number"&#13;
                          order="descending"/&gt;&#13;
                &lt;tr&gt;&#13;
                    &lt;td&gt;&#13;
                        &lt;em&gt;&lt;xsl:value-of select="@id"/&gt;&lt;/em&gt;&#13;
                    &lt;/td&gt;&#13;
                    &lt;td&gt;&#13;
                        &lt;xsl:value-of select="revenue"/&gt;&#13;
                    &lt;/td&gt;&#13;
                    &lt;td&gt;&#13;
                        &lt;!-- highlight negative growth in red --&gt;&#13;
                        &lt;xsl:if test="growth &lt; 0"&gt;&#13;
                             &lt;xsl:attribute name="style"&gt;&#13;
                                 &lt;xsl:text&gt;color:red&lt;/xsl:text&gt;&#13;
                             &lt;/xsl:attribute&gt;&#13;
                        &lt;/xsl:if&gt;&#13;
                        &lt;xsl:value-of select="growth"/&gt;&#13;
                    &lt;/td&gt;&#13;
                    &lt;td&gt;&#13;
                        &lt;xsl:value-of select="bonus"/&gt;&#13;
                    &lt;/td&gt;&#13;
                &lt;/tr&gt;&#13;
            &lt;/xsl:for-each&gt;&#13;
        &lt;/table&gt;&#13;
    &lt;/body&gt;&#13;
&lt;/html&gt;

You would end up with

&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
&lt;title&gt;Sales Results By Division&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;&lt;table border="1"&gt;
&lt;tr&gt;
&lt;th&gt;Division&lt;/th&gt;
&lt;th&gt;Revenue&lt;/th&gt;
&lt;th&gt;Growth&lt;/th&gt;
&lt;th&gt;Bonus&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;North&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;West&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td style="color:red"&gt;-1.5&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;South&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;/body&gt;
&lt;/html&gt;

References: revXMLEvaluateXpath (function), xsltLoadStylesheet (function), xsltLoadStylesheetFromFile (function), revXMLCreateTreeFromFile (function), revXMLCreateTree (function), xsltApplyStylesheetFromFile (function)

Tags: xml
