Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Trouble excluding select xml out to HTML using xsl

Reply
Thread Tools

Trouble excluding select xml out to HTML using xsl

 
 
kmunderwood@charter.net
Guest
Posts: n/a
 
      03-17-2005
I am having trouble excluding select xml out to HTML using xsl

I want to ignore some xml and turn others red

I can not find the right way to both:

1. Only show the <tag> that want to, and
2. Turn an attribute a color when it falls below a certain level.


This is the way I want the html to display:

Tank Level Temperature
B05 535.91 22.22

But, the way it pulls in all "Tag"
It looks like:

Tank Level Temperature
B05 535.91 22.22
_4..20mA-2 -0.01 <no data>

I want to ignore the _4..20mA-2, among others.
When the tank level falls below 600, I want the background or text to
turn red.



This is the way I get the xml.
(its abreviated. It is very long and shows 17 "Tag", or devices, but I
only
want to show 12 of them)

<?xml version="1.0" encoding="iso-8859-1" ?>
<fieldgate ser="6C000D010A0" tag="TTL Bulk Storage Farm" type="full"
devices="all">
<timezone>0</timezone>
<os_version>3.18</os_version>
<conf>FXA520-AA1A</conf>
<device id="11183312ee" tag="B05" type="HART">
<u4>°C</u4>
<v4>22.22</v4>
<dev>Cerabar S</dev>
<man>Endress+Hauser</man>
<u1>lb</u1>
<v1>535.91</v1>
<type>HART</type>
<unid>11183312ee</unid>
</device>
<device id="_4..20mA-2" tag="_4..20mA-2" type="INTRN">
<u>mA</u>
<tag>_4..20mA-2</tag>
<hlsts1>OK</hlsts1>
<v1>-0.01</v1>
<man>Endress+Hauser</man>
<unid>_4..20mA-2</unid>
</device>
</fieldgate>




This is the xsl:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform"><xsl:template
match="/">
<html>
<body>
<h2>Bulk Storage Tanks</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Tank</th>
<th>Level</th>
<th>Temperature</th>
</tr>
<xsl:for-each select="fieldgate/device">
<tr>
<td><xsl:value-of select="tag"/></td>
<xsl:choose>
<xsl:when test="v1 &lt; 600">
<td bgcolor="#ff00ff">
<xsl:value-of select="v1"/></td>
</xsl:when>
<xsltherwise>
<td><xsl:value-of select="v1"/></td>
</xsltherwise>
</xsl:choose>
<td><xsl:value-of select="v4"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>

This works fine, but includes all "tag", and I want to ignore some.


Tank Level Temperature
B05 535.91 22.22
B04 42567.36 22.81
_4..20mA-2 -0.01 Blank


The 535.91 background turns red, which is what I am looking for, but I
want to ignore <tag> _4..20mA-2

I had success displaying only the ones I wanted, using an "if match".
<xsl:if match=".[tag='B05']">, but I cant "test" on it.


This is the 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>

Can anyone give me an idea on how to do this, I am stuck, and a newbie
at xml/xsl

Thank You, Ken

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using css in html embedded in xml rendered using xsl with javascript (phew) confused XML 3 05-25-2007 11:06 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
XML/XSL newb q: can I ever select or refer to xml attribute values? 5tein XML 1 04-30-2004 12:42 AM
Excluding xsl selection for elements with missing attributes Terry Chilvers XML 1 09-01-2003 11:51 AM
Excluding Child for Repurposing with XML and XSLT Eric Weiss XML 1 07-06-2003 05:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57