473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I show only one Element with this code


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:otherwise>
<td><xsl:value-of select="v1"/></td>
</xsl:otherwise>
</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

Jul 20 '05 #1
2 1296


km*********@charter.net wrote:
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:param name="deviceTag" select="'B01'" />
<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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
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:otherwise>
<td><xsl:value-of select="v1"/></td>
</xsl:otherwise>
</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 Honnen wrote:
km*********@charter.net wrote:
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:param name="deviceTag" select="'B01'" />
> <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.
--

Martin Honnen
http://JavaScript.FAQTs.com/


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ryh | last post by:
I have the following scritpt. It hides div layer when mouse is out of the div layer. Inside DIV I have IFRAME box. Unfortuantely it does not work in Mozilla or IE 5.5. It hides div when cursor is...
5
by: Mel | last post by:
i need to have 2 side by side iframes, a link on top of the one will show/hide the other can someone help me pleeeeezzzzz ?
3
by: alex | last post by:
I'd like to have a show/hide widget on my web site, kind of like "show details" / "hide details" in Google Groups. Is there a tutorial explaining how to make them? Google's is a bit complex and...
2
by: Greg | last post by:
Hello, I am trying to display order ids and order details (order items). I would like to give the user Hide/Show option to either display or hide order details. The page would look like: ...
5
by: srampally | last post by:
I need the capabilty to hide/show a selection list, just the way its done at http://www.lufthansa.com (place the cursor over "Group Companies"). However, I am looking for a javascript that is much...
17
by: alxasa | last post by:
Hi, can someone please show me how to most elegently do this?..... I have a textbox, and I want to search the contents of it and replace all instances of a certain word, and replace that word...
6
by: Norman | last post by:
Hello, I have a working Show / Hide form, that works on FF, but what I would like to do is to be able to display one part when a user clicks on one radio button and display another part when the...
11
by: dmorand | last post by:
I'm having some trouble with my javascript which is supposed to hide/show a div element. I have to click on the link twice before it'll hide. I can't seem to figure out why the first click does...
8
by: tkjensen | last post by:
How to make a own dataview in c#? Can someone please help me? I want to get id and users and everything else from database to be showed in the same place at the same time just as DataView. Please...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.