Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How do I show only one Element with this code

Reply
Thread Tools

How do I show only one Element with this code

 
 
kmunderwood@charter.net
Guest
Posts: n/a
 
      03-28-2005

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"
xmlnssl="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>
<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>

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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-28-2005


http://www.velocityreviews.com/forums/(E-Mail Removed) 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"
> xmlnssl="http://www.w3.org/1999/XSL/Transform">


<xslaram name="deviceTag" />
or if you want to have a default value
<xslaram 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/
 
Reply With Quote
 
 
 
 
kmunderwood@charter.net
Guest
Posts: n/a
 
      03-28-2005
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform"><xsl:template
match="/">
<xslaram name="deviceTag1" select="'B01'" />
<xslaram name="deviceTag2" select="'B02'" />
<xslaram name="deviceTag3" select="'B03'" />
<xslaram name="deviceTag4" select="'B04'" />
<xslaram name="deviceTag5" select="'B05'" />
<xslaram name="deviceTag6" select="'B06'" />
<xslaram name="deviceTag7" select="'B07'" />
<xslaram name="deviceTag8" select="'B08'" />
<xslaram name="deviceTag9" select="'B09'" />
<xslaram name="deviceTag10" select="'B10'" />
<xslaram name="deviceTag11" select="'B11'" />
<xslaram 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>
<xsltherwise>
<td><xsl:value-of select="v1"/></td>
</xsltherwise>
</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:
> (E-Mail Removed) 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"
> > xmlnssl="http://www.w3.org/1999/XSL/Transform">

>
> <xslaram name="deviceTag" />
> or if you want to have a default value
> <xslaram 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/


 
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
Re: When running Ant on command line, how to not-show its WARNING messages and only show ERROR message? John B. Matthews Java 0 12-09-2011 05:19 PM
HTML Select element: How to show drop-down list by clicking only once Stefan Mueller HTML 5 06-14-2008 01:41 PM
HTML Select element: How to show drop-down list by clicking only once Stefan Mueller Java 0 06-13-2008 11:33 AM
More than one element of list changing when only one should be Chuckk Hubbard Python 1 06-09-2008 07:48 AM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM



Advertisments