How do I show only one Element with this code

K

kmunderwood

How do I show only one Element with this code
Help Me, OH!!! Help Me ;)

I have code that works, but...

This is the way it comes out in html
The Level, or Element "v1"(background) turns red when under 600

Bulk Storage Tanks

Tank<tag> Level<v1> Temperature<v4>
B05 535.91 22.22
B04 42567.36 22.81
B06 37265.17 21.94
B11 86.47 22.67
B01 395.47 69.65
B10 2.29 21.66
B07 32974.62 23.12
B03 13007.45 22.18
B02 23328.18 22.53
B12 71.17 21.57
B09 28961.24 22.34
B08 28045.13 21.52
P&F HM NAN none
_4..20mA-1 -0.01 none
_4..20mA-2 -0.01 none
_5V 4.92 none none
_boardtemp none 45.41

But, This is the way I want it

Tank Level Temperature
B01 395.47 69.65
(red bground)

Then, I can repeat the code in its own table, to show only the tanks
that I need.
(And in the order I want also)

Here is the abbreviated xml (I dont make the xml)
Full xml: http://home.earthlink.net/~kmunderwood/index.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<fieldgate ser="1B555D010A0" tag="TTL Bulk Storage Farm" type="full"
devices="all">
<os_version>3.18</os_version>
<conf>FXA520-AA1A</conf>
<device id="11183312ee" tag="B05" type="HART">
<v4>22.22</v4>
<tag>B05</tag>
<u1>lb</u1>
<v1>535.91</v1>
</device>
<device id="11183312e6" tag="B04" type="HART">
<v4>22.81</v4>
<tag>B04</tag>
<u1>lb</u1>
<v1>42567.36</v1>
</device>
<device id="11183309c5" tag="B01" type="HART">
<v4>69.65</v4>
<tag>B01</tag>
<u1>lb</u1>
<v1>395.47</v1>
</device>
<device id="_boardtemp" tag="_boardtemp" type="INTRN">
<tag>_boardtemp</tag>
<v1>45.41</v1>
<man>Endress+Hauser</man>
</device>
</fieldgate>

Here is the xsl

<?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>Bulk Storage Tanks</h2>
<table border="1">
<tr bgcolor="green">
<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="red">
<xsl:value-of select="v1"/></td>
</xsl:when>
<xsl:eek:therwise>
<td><xsl:value-of select="v1"/></td>
</xsl:eek:therwise>
</xsl:choose>
<td><xsl:value-of select="v4"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>

How do I tell it to show only B01, or B02, etc, plus its child Elements
that I choose?

Someone???An example??? Explainations might go over my head, but if
that is all you can give, Ill take it.

Thank you, Thank You, Thank You.

Ken
 
M

Martin Honnen

How do I show only one Element with this code
Tank Level Temperature
B01 395.47 69.65
(red bground)

Here is the abbreviated xml (I dont make the xml)
Full xml: http://home.earthlink.net/~kmunderwood/index.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<fieldgate ser="1B555D010A0" tag="TTL Bulk Storage Farm" type="full"
devices="all">
<device id="11183309c5" tag="B01" type="HART">
<v4>69.65</v4>
<tag>B01</tag>
<u1>lb</u1>
<v1>395.47</v1>

You could define a global parameter in your stylesheet for that tag
value you are looking for e.g.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="deviceTag" />
or if you want to have a default value
<xsl:template
match="/">
<html>
<body>
<h2>Bulk Storage Tanks</h2>
<table border="1">
<tr bgcolor="green">
<th>Tank</th>
<th>Level</th>
<th>Temperature</th>
</tr>
<xsl:for-each select="fieldgate/device">

Then here you would need
<xsl:for-each select="fieldgate/device[@tag = $deviceTag]">

Then check the documentation of your XSLT processor on how to set global
parameters when you run a transformation.

Of course depending on what you want to achieve and how your input data
looks you might not even need a xsl:for-each loop but I have tried to
suggest a small change to your posted XSL instead of creating a new one.
 
K

kmunderwood

Oh wow, that is great..Thank You
I have repeated the param name, and made a table for each
tank, to give me exactly what I am looking for.
Cant thank you enough.
!!!!!!!
Ken

How to I check to see which XSLT processor I am running?
I will look it up to continue my lesson.

This is what it looks like now.

<?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="/">
<xsl:param name="deviceTag1" select="'B01'" />
<xsl:param name="deviceTag2" select="'B02'" />
<xsl:param name="deviceTag3" select="'B03'" />
<xsl:param name="deviceTag4" select="'B04'" />
<xsl:param name="deviceTag5" select="'B05'" />
<xsl:param name="deviceTag6" select="'B06'" />
<xsl:param name="deviceTag7" select="'B07'" />
<xsl:param name="deviceTag8" select="'B08'" />
<xsl:param name="deviceTag9" select="'B09'" />
<xsl:param name="deviceTag10" select="'B10'" />
<xsl:param name="deviceTag11" select="'B11'" />
<xsl:param name="deviceTag12" select="'B12'" />
<html>
<body>


<h2>Bulk Storage Tanks</h2>
<table border="1">
<tr bgcolor="green">
<th>Tank</th>
<th>Level</th>
<th>Temperature</th>
</tr>

<xsl:for-each select="fieldgate/device[@tag = $deviceTag1]">
<tr>
<td><xsl:value-of select="@tag"/></td>
<xsl:choose>
<xsl:when test="v1 &lt; 600">
<td bgcolor="red">
<xsl:value-of select="v1"/></td>
</xsl:when>
<xsl:eek:therwise>
<td><xsl:value-of select="v1"/></td>
</xsl:eek:therwise>
</xsl:choose>
<td><xsl:value-of select="v4"/></td>
</tr>
</xsl:for-each>
</table>
Repeated to the end.
</body>
</html>
</xsl:template></xsl:stylesheet>

Thanks a million!!!!
Ken


Martin said:
How do I show only one Element with this code
Tank Level Temperature
B01 395.47 69.65
(red bground)

Here is the abbreviated xml (I dont make the xml)
Full xml: http://home.earthlink.net/~kmunderwood/index.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<fieldgate ser="1B555D010A0" tag="TTL Bulk Storage Farm" type="full"
devices="all">
<device id="11183309c5" tag="B01" type="HART">
<v4>69.65</v4>
<tag>B01</tag>
<u1>lb</u1>
<v1>395.47</v1>

You could define a global parameter in your stylesheet for that tag
value you are looking for e.g.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="deviceTag" />
or if you want to have a default value
<xsl:template
match="/">
<html>
<body>
<h2>Bulk Storage Tanks</h2>
<table border="1">
<tr bgcolor="green">
<th>Tank</th>
<th>Level</th>
<th>Temperature</th>
</tr>
<xsl:for-each select="fieldgate/device">

Then here you would need
<xsl:for-each select="fieldgate/device[@tag = $deviceTag]">

Then check the documentation of your XSLT processor on how to set global
parameters when you run a transformation.

Of course depending on what you want to achieve and how your input data
looks you might not even need a xsl:for-each loop but I have tried to
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top