Skip to content

Instantly share code, notes, and snippets.

@Jozefson
Last active August 29, 2015 13:57
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 Jozefson/f0d975accf0662e9b2f1 to your computer and use it in GitHub Desktop.
Save Jozefson/f0d975accf0662e9b2f1 to your computer and use it in GitHub Desktop.
vr2
<?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>Temperature 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: #99CCFF;
width: 80%;
text-align: center;
margin: 0 auto;
}
.content {
display: inline-block;
}
table {
display: inline-block;
}
table td {
padding: 7px;
margin: 0 auto;
}
.temp {
float: left;
}
.sens {
font-size:small;
}
.switch {
float: left;
margin-left: 80px;
}
</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>
<table>
<tr>
<th>Time</th>
<th>Value</th>
</tr>
<xsl:for-each select="reading">
<tr>
<td>
<xsl:value-of select="ms:format-date(substring(@timestamp,1,10), 'yyyy MMM dd')"/>
<xsl:value-of select="ms:format-time(substring(@timestamp,1,19), ' Kell: hh:mm:ss')"/>
</td>
<td>
<xsl:value-of select="concat(substring(@value,1,4), @unit)"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</div>
<div class="switch">
<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 class="sens">
Switch: <xsl:value-of select="@switches"/>
</h3>
<table>
<tr>
<th>Time</th>
<th>Value</th>
</tr>
<xsl:for-each select="log">
<tr>
<td>
<xsl:value-of select="ms:format-date(substring(@timestamp,1,10), 'yyyy MMM dd')"/>
<xsl:value-of select="ms:format-time(substring(@timestamp,1,19), ' Kell: hh:mm:ss')"/>
</td>
<td>
<xsl:value-of select="@value"/>
</td>
</tr>
</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