+ <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<p></p><p><sales> </p><p> <division id="North"> </p><p> <revenue>10</revenue> </p><p> <growth>9</growth> </p><p> <bonus>7</bonus> </p><p> </division> </p><p> <division id="South"> </p><p> <revenue>4</revenue> </p><p> <growth>3</growth> </p><p> <bonus>4</bonus> </p><p> </division> </p><p> <division id="West"> </p><p> <revenue>6</revenue> </p><p> <growth>-1.5</growth> </p><p> <bonus>2</bonus> </p><p> </division> </p><p></sales></p><p></p><p>and an xslt document of</p><p></p><p><html xsl:version="1.0" </p><p> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" </p><p> lang="en"> </p><p> <head> </p><p> <title>Sales Results By Division</title> </p><p> </head> </p><p> <body> </p><p> <table border="1"> </p><p> <tr> </p><p> <th>Division</th> </p><p> <th>Revenue</th> </p><p> <th>Growth</th> </p><p> <th>Bonus</th> </p><p> </tr> </p><p> <xsl:for-each select="sales/division"> </p><p> <!-- order the result by revenue --> </p><p> <xsl:sort select="revenue" </p><p> data-type="number" </p><p> order="descending"/> </p><p> <tr> </p><p> <td> </p><p> <em><xsl:value-of select="@id"/></em> </p><p> </td> </p><p> <td> </p><p> <xsl:value-of select="revenue"/> </p><p> </td> </p><p> <td> </p><p> <!-- highlight negative growth in red --> </p><p> <xsl:if test="growth &lt; 0"> </p><p> <xsl:attribute name="style"> </p><p> <xsl:text>color:red</xsl:text> </p><p> </xsl:attribute> </p><p> </xsl:if> </p><p> <xsl:value-of select="growth"/> </p><p> </td> </p><p> <td> </p><p> <xsl:value-of select="bonus"/> </p><p> </td> </p><p> </tr> </p><p> </xsl:for-each> </p><p> </table> </p><p> </body> </p><p></html></p><p></p><p>You would end up with</p><p></p><p><html lang="en"></p><p><head></p><p><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></p><p><title>Sales Results By Division</title></p><p></head></p><p><body><table border="1"></p><p><tr></p><p><th>Division</th></p><p><th>Revenue</th></p><p><th>Growth</th></p><p><th>Bonus</th></p><p></tr></p><p><tr></p><p><td><em>North</em></td></p><p><td>10</td></p><p><td>9</td></p><p><td>7</td></p><p></tr></p><p><tr></p><p><td><em>West</em></td></p><p><td>6</td></p><p><td style="color:red">-1.5</td></p><p><td>2</td></p><p></tr></p><p><tr></p><p><td><em>South</em></td></p><p><td>4</td></p><p><td>3</td></p><p><td>4</td></p><p></tr></p><p></table></body></p><p></html></p></description>
0 commit comments