K
kmunderwood
I am trying to combine "if match=" and "when test"
I am a newbie, and have made both work separately, but I can not seem
to combine them.
This is my xml("index.xml")page(I can not change this, it comes to me
this way.
<?xml version="1.0" encoding="iso-8859-1" ?>
- <fieldgate ser="6C000D010A0" tag="TTL Bulk Storage Farm" type="full"
devices="all">
<time>19700101-000000</time>
<timezone>0</timezone>
<ff_version>01.02.02-071 20050118</ff_version>
<os_version>3.18</os_version>
<conf>FXA520-AA1A</conf>
- <device id="11183312ee" tag="B05" type="HART">
<u4>°C</u4>
<v4>22.22</v4>
<u2>In H2O</u2>
<dev>Cerabar S</dev>
<man>Endress+Hauser</man>
<u1>lb</u1>
<v1>535.91</v1>
<type>HART</type>
- <param>
<t1ch>Bulk Tank B5</t1ch>
<t2ch>Weight in Pounds</t2ch>
<max>43928.00</max>
<min>0.00</min>
</param>
</device>
</fieldgate>
The "device" element repeats 11 more times,(tag number changes) and I
want to ignore some,
so I am using an "if match".
I just repeat the table for each bulk tank that I want to display.
This is my "if match" xsl("index.xsl"):
It works, but I can not make a v1 under 2000, have the background
change color
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table width="800" border="2" bordercolor="#3300CC"
bgcolor="#0099CC">
<tr>
<th>Tank #</th>
<th>Current Level</th>
<th>Temp.</th>
</tr>
<xsl:for-each select="fieldgate/device">
<xsl:if match=".[tag='B01']">
<tr>
<td width="200"><xsl:value-of select="tag"/></td>
<td width="200"><xsl:value-of select="v1"/></td>
<td width="200"><xsl:value-of select="v4"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
This shows an html page like this:
Tank # CurrentLevel Temp.
B01 395.47 69.65
I want the cell background to change to red when the level is below
2000
This is my "when test" xsl("index2.xsl"):
It works, but shows all tags, and I want to ignore some.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template
match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Tank</th>
<th>Level</th>
</tr>
<xsl:for-each select="fieldgate/device">
<tr>
<td><xsl:value-of select="tag"/></td>
<xsl:choose>
<xsl:when test="v1 < 100">
<td bgcolor="#ff00ff">
<xsl:value-of select="v1"/></td>
</xsl:when>
<xsltherwise>
<td><xsl:value-of select="v1"/></td>
</xsltherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>
This is my html:
<html>
<head>
<style type="text/css">
th, td { font-size: 200%; }
</style>
</head>
<body>
<script language="javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("index.xml")
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("index.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
</body>
</html>
I have tried various combinations, to no avail.
If you can not help, can you suggest an article or suggestions on which
way to go?
I am a newbie, and have made both work separately, but I can not seem
to combine them.
This is my xml("index.xml")page(I can not change this, it comes to me
this way.
<?xml version="1.0" encoding="iso-8859-1" ?>
- <fieldgate ser="6C000D010A0" tag="TTL Bulk Storage Farm" type="full"
devices="all">
<time>19700101-000000</time>
<timezone>0</timezone>
<ff_version>01.02.02-071 20050118</ff_version>
<os_version>3.18</os_version>
<conf>FXA520-AA1A</conf>
- <device id="11183312ee" tag="B05" type="HART">
<u4>°C</u4>
<v4>22.22</v4>
<u2>In H2O</u2>
<dev>Cerabar S</dev>
<man>Endress+Hauser</man>
<u1>lb</u1>
<v1>535.91</v1>
<type>HART</type>
- <param>
<t1ch>Bulk Tank B5</t1ch>
<t2ch>Weight in Pounds</t2ch>
<max>43928.00</max>
<min>0.00</min>
</param>
</device>
</fieldgate>
The "device" element repeats 11 more times,(tag number changes) and I
want to ignore some,
so I am using an "if match".
I just repeat the table for each bulk tank that I want to display.
This is my "if match" xsl("index.xsl"):
It works, but I can not make a v1 under 2000, have the background
change color
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table width="800" border="2" bordercolor="#3300CC"
bgcolor="#0099CC">
<tr>
<th>Tank #</th>
<th>Current Level</th>
<th>Temp.</th>
</tr>
<xsl:for-each select="fieldgate/device">
<xsl:if match=".[tag='B01']">
<tr>
<td width="200"><xsl:value-of select="tag"/></td>
<td width="200"><xsl:value-of select="v1"/></td>
<td width="200"><xsl:value-of select="v4"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
This shows an html page like this:
Tank # CurrentLevel Temp.
B01 395.47 69.65
I want the cell background to change to red when the level is below
2000
This is my "when test" xsl("index2.xsl"):
It works, but shows all tags, and I want to ignore some.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template
match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Tank</th>
<th>Level</th>
</tr>
<xsl:for-each select="fieldgate/device">
<tr>
<td><xsl:value-of select="tag"/></td>
<xsl:choose>
<xsl:when test="v1 < 100">
<td bgcolor="#ff00ff">
<xsl:value-of select="v1"/></td>
</xsl:when>
<xsltherwise>
<td><xsl:value-of select="v1"/></td>
</xsltherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>
This is my html:
<html>
<head>
<style type="text/css">
th, td { font-size: 200%; }
</style>
</head>
<body>
<script language="javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("index.xml")
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("index.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
</body>
</html>
I have tried various combinations, to no avail.
If you can not help, can you suggest an article or suggestions on which
way to go?