473,495 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

simple(?) nested for-each

The following xml file is converted by the piece of xml below (oil.xsl).
I have the right number of dots for the unordered list items, but it
won't print out the "use's". What am I doing wrong?

XML scrap:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="oil.xsl"?>
<oils>

<oil>
<name>ALCAID-100</name>
<use>Instrument Air Compressor crankcases (except Sullair)</use>
<use>#1 vacuum pump crankcase</use>
</oil>

<oil>
<name>A.T.F.</name>
<use>GT1 &amp; GT2 starting package torque converters</use>
<use>#4 acid pump stroke control boxes</use>
<use>Old R.O. caustic regeneration boxes (diaphragm only)</use>
</oil>
</oils>
XSL stylesheet:

<?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>Plant Lube Oil Guide</h2>
<table border="0" width="100%">
<tr bgcolor="#F0F0F0">
<th align="left">Oil</th>
<th align="left">Machinery</th>
</tr>
<xsl:for-each select="oils/oil">
<tr>
<td><xsl:value-of select="name"/></td>
<td><ul>
<xsl:for-each select="use">
<li><xsl:value-of select="use"/></li>
</xsl:for-each>
</ul>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>
John Estess
jh******@yahoo.com

Jul 20 '05 #1
2 4618
John Estess wrote:

Instead of this:
<xsl:for-each select="use">
<li><xsl:value-of select="use"/></li>
Try this: <xsl:for-each select="use">
<li><xsl:value-of select="."/></li>


Your original statement will select the value of oils/oil/use/use.

--
Victor
Jul 20 '05 #2
John Estess <je*****@elp.rr.com> wrote in message news:<JV*******************@fe2.texas.rr.com>...
What am I doing wrong?


Try this (as a quick guess):

<xsl:for-each select="use">
<li><xsl:value-of select="."/>

You're probably looping through the node set you expect, but
<xsl:for-each> changes the context to each set member element in turn.
Your code had effectively been looking for an extra <uses> element
_within_ each loop element.
Jul 20 '05 #3

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

Similar topics

1
1234
by: Anthony | last post by:
Hi there, I have a simpletable that i have succesfully bound to a datalist.. It just shows name, description and image.. FINE.. However i would now like to simply split them into sections i.e...
4
3425
by: Vili | last post by:
Hi all What is the best way to do a simple nested datagrid? I have a tableA with personID, first name and last. TableB with information on personID. I am looking for a way to bring name values...
1
6741
by: levidicom | last post by:
foreach($test as $var1){ foreach($test2 as $var2) { echo '"var1: " . $var1 . "<br>"var2: " . $var2 . "<br> \n"'; }
3
18772
by: ThatsIT.net.au | last post by:
I'm looking for a very simple nested grid view example. Also I have been creating tables instead of using gridview for complex tasks or just spitting out html from code. Do you recommend using...
0
3758
by: Sam | last post by:
Have been trying to do this in flexy for a while, but it does not seem to support it. I have an array of categories of which each contains an array of things. So I'd like the template to look like...
5
5231
by: Ivan S | last post by:
I'm using next snippet: $somearray = array(...); foreach($somearray as $item1) { foreach($item1 as $item2) { // ... do something ... } }
15
2721
by: fjm | last post by:
Hello everyone and happy Sunday. :) I have a problem that I *think* I may know the solution to but have no idea how to write the code for it. I am working on a templating system wher I have...
2
4432
by: gomako | last post by:
Hi, I'm new, so please let me know if any of my forum etiquette is wrong! Apologies for the fairly nondescript subject line, but I am being driven insane by it. Anyhow, I have a form with...
0
7120
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6991
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
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7196
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...
1
6878
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
7373
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
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.