Skip to content

Instantly share code, notes, and snippets.

@kristokuiv
Created March 9, 2014 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristokuiv/9446237 to your computer and use it in GitHub Desktop.
Save kristokuiv/9446237 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:param name="file" select="document('data.xml')"/>
<xsl:template match="/">
<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html></xsl:text>
<html>
<head>
<title>Data</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<meta charset="utf-8"></meta>
<style>
body {
background-color: #FFCC66;
text-align: center;
margin: 0 auto;
}
}
</style>
</head>
<body>
<div class="content">
<div class="temp">
<xsl:for-each select="root/sensors">
<xsl:if test="@active = 'true'">
<xsl:for-each select="sensor">
<h2>
Location: <xsl:value-of select="@location"/>
</h2>
<h3>
Hetked, mil temperatuur oli alla 15C
</h3>
<table>
<tr>
<th>Time</th>
<th>Value</th>
</tr>
<xsl:for-each select="reading">
<xsl:if test="@value &lt; 15">
<tr>
<td>
<xsl:value-of select="ms:format-date(substring(@timestamp,1,10), 'dd. MMM yy')"/>
<xsl:value-of select="ms:format-time(substring(@timestamp,1,19), ' @ hh:mm:ss')"/>
</td>
<td>
<xsl:value-of select="concat(substring(@value,1,4), @unit)"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</div>
<div>
<xsl:for-each select="root/switches">
<xsl:if test="@active = 'true'">
<xsl:for-each select="switch">
<h2>
Location: <xsl:value-of select="@location"/>
</h2>
<h3>
Switch: <xsl:value-of select="@switches"/>
</h3>
<h3>
Hetked, mil väärtus oli suurem kui 0 ehk tuled põlesid
</h3>
<table>
<tr>
<th>Time</th>
<th>Value</th>
</tr>
<xsl:for-each select="log">
<xsl:if test="@value!=0">
<tr>
<td>
<xsl:value-of select="ms:format-date(substring(@timestamp,1,10), 'dd. MMM yy')"/>
<xsl:value-of select="ms:format-time(substring(@timestamp,1,19), ' @ hh:mm:ss')"/>
</td>
<td>
<xsl:value-of select="@value"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment