Last active
August 29, 2015 14:05
-
-
Save GaretJax/94be14ed20a2f59c72db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Example command line usage: | |
| php -f table.php > out.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $xslDoc = new DOMDocument(); | |
| $xslDoc->load("./transform.xsl"); | |
| $xmlDoc = new DOMDocument(); | |
| $xmlDoc->load("./test.xml"); | |
| $proc = new XSLTProcessor(); | |
| $proc->importStylesheet($xslDoc); | |
| echo $proc->transformToXML($xmlDoc); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
| <xsl:output method="html" encoding="utf-8" indent="yes"/> | |
| <xsl:template match="/"> | |
| <table border="1"> | |
| <thead> | |
| <tr> | |
| <th rowspan="2"></th> | |
| <th rowspan="2">Username</th> | |
| <th rowspan="2">Status</th> | |
| <th rowspan="2">IP</th> | |
| <th rowspan="2">Protocol</th> | |
| <th colspan="12">Stats</th> | |
| </tr> | |
| <tr> | |
| <th>ok</th> | |
| <th>nok</th> | |
| <th>ignore</th> | |
| <th>timeout</th> | |
| <th>cache</th> | |
| <th>tun</th> | |
| <th>lastresptime</th> | |
| <th>emmok</th> | |
| <th>emmnok</th> | |
| <th>rate</th> | |
| <th>timeonchannel</th> | |
| <th>expectsleep</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <xsl:apply-templates select="//users/user"/> | |
| </tbody> | |
| <tfoot> | |
| <tr> | |
| <th colspan="5" scope="row">Totals</th> | |
| <td><xsl:value-of select="//totals/cwok"/></td> | |
| <td><xsl:value-of select="//totals/cwnok"/></td> | |
| <td><xsl:value-of select="//totals/cwignore"/></td> | |
| <td><xsl:value-of select="//totals/cwtimeout"/></td> | |
| <td><xsl:value-of select="//totals/cwcache"/></td> | |
| <td><xsl:value-of select="//totals/cwtun"/></td> | |
| <td colspan="6"></td> | |
| </tr> | |
| </tfoot> | |
| </table> | |
| </xsl:template> | |
| <xsl:template match="/oscam/users/user"> | |
| <tr> | |
| <td><xsl:value-of select="position()"/></td> | |
| <td><xsl:value-of select="@name"/></td> | |
| <td><xsl:value-of select="@status"/></td> | |
| <td><xsl:value-of select="@ip"/></td> | |
| <td><xsl:value-of select="@protocol"/></td> | |
| <xsl:apply-templates select="stats/*"/> | |
| </tr> | |
| </xsl:template> | |
| <xsl:template match="/oscam/users/user/stats/*"> | |
| <td><xsl:value-of select="text()"/></td> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment