Skip to content

Instantly share code, notes, and snippets.

@henriAbel
Created March 8, 2014 13:02
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 henriAbel/c9a567138b856ab33626 to your computer and use it in GitHub Desktop.
Save henriAbel/c9a567138b856ab33626 to your computer and use it in GitHub Desktop.
XSLT fail
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html></xsl:text>
<html>
<head>
<title>Temperatuuid</title>
<meta charset="utf-8"></meta>
<style>
body {
background-color: #ddd;
width: 80%;
text-align: center;
margin: 0 auto;
}
.content {
display: inline-block;
}
table {
display: inline-block;
}
table td {
padding: 7px;
}
.temp {
float: left;
}
.switch {
float: left;
margin-left: 60px;
}
</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>
Asukoht: <xsl:value-of select="@location"/>
</h2>
<table>
<tr>
<th>Aeg</th>
<th>Ühik</th>
<th>Väärtus</th>
</tr>
<xsl:for-each select="reading">
<tr>
<td>
<xsl:value-of select="@timestamp"/>
</td>
<td>
<xsl:value-of select="@unit"/>
</td>
<td>
<xsl:value-of select="@value"/>
</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>
Asukoht: <xsl:value-of select="@location"/>
</h2>
<h3>
Lülitab: <xsl:value-of select="@switches"/>
</h3>
<table>
<tr>
<th>Aeg</th>
<th>Väärtus</th>
</tr>
<xsl:for-each select="log">
<tr>
<td>
<xsl:value-of select="@timestamp"/>
</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