473,480 Members | 4,939 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

xslt looping help :-( please

1 New Member
Hi!

Ok so im having a very very rookie (i assume) problem.

I want to take this:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <?xml-stylesheet type="text/xsl" href="xslTest.xsl"?>
  3. <dataTree>
  4.  
  5.     <group>
  6.         <teacher>John Jacobs</teacher>
  7.              <classr>Algebra I</classr>
  8.              <classr>Algebra II</classr>
  9.     </group>
  10.  
  11.  
  12.     <group>        
  13.         <teacher>Goldberg</teacher>
  14.              <classr>History I</classr>
  15.              <classr>History II</classr>
  16.     </group>  
  17.  
  18. </dataTree>
  19.  
and turn it into this:

Expand|Select|Wrap|Line Numbers
  1. John Jacobs
  2.  
  3. Algebra I
  4. Algebra II
  5.  
  6. Goldberg
  7.  
  8. History I
  9. History II
  10.  

This is what i thought would work:


Expand|Select|Wrap|Line Numbers
  1.  
  2. <?xml version="1.0" encoding="ISO-8859-1"?>
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4.  
  5. <xsl:template match="/">
  6.  <html>
  7.  <body>
  8.  
  9.  <xsl:for-each select="dataTree/group">
  10.             <xsl:value-of select="teacher" /><br /><br />
  11.             <xsl:value-of select="classr" /><br />            
  12.  </xsl:for-each>
  13.  
  14.  </body>
  15.  </html>
  16. </xsl:template>
  17. </xsl:stylesheet>
  18.  
this is what i get:

Expand|Select|Wrap|Line Numbers
  1. John Jacobs
  2.  
  3. Algebra I
  4. Goldberg
  5.  
  6. History I
  7.  
I just learned XSLT last night but i know java and javascript and php and C# and all of those languages so I thought this would work. can anyone suggest another way or point out what im doing wrong?

thank you soo much!
Jul 26 '07 #1
1 1181
jkmyoung
2,057 Recognized Expert Top Contributor
there are multiple classr nodes; you need another for-each. Where you have:
<xsl:value-of select="classr" /><br />
Replace with
<xsl:for-each select="classr"><xsl:value-of select="."/><br/></xsl:for-each>
Jul 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2210
by: Ruthless | last post by:
hello. All XML and XSLT are processed by preprocessor as a trees. How can i simply display my XML as some kind of tree. given xml: <struct> <node level="1" no="1">
3
1655
by: Just Curious | last post by:
Hello, I have a following situation.. XML Document contains <PurchaseOrder> <LineItems> <LineItem> <Description></Description> </LineItem> <LineItem>
3
2336
by: Michael Ahlers | last post by:
Obviously if you're looping or using a template, choosing output based on the current iteration is easy. For example, if you're walking a set of elements and you want index % 2 == 0 produce one...
3
2180
by: Teksure | last post by:
Hi group, searching in the Internet I found two products for XML which incorporate a very robust debugger for XSL/XSLT, I would like you to see these products and then, give me your opinion about...
6
3214
by: Christopher | last post by:
I am currently in the process of evaluating the performance hits of moving to the .NET platform for our application. I created a sample project that loads the transforms the same XML and XSLT in...
4
2193
by: Iain | last post by:
Hi all, I am try to split the some data out of a nested xml file and get all the data in one new xml file. I have two XSLT files one takes the personal information and one takes the data out of...
6
2993
by: aidy | last post by:
Hi, This is a snippet of my XSLT <xsl:for-each select = "SAFS_LOG/LOG_MESSAGE"> <xsl:choose> <xsl:when test="@type = 'FAILED'"> <xsl:variable name="isFailed" select="@type" /> <BR>...
1
4717
by: balderdash | last post by:
Hi I am very close to achieving the output I need but I cant seem to get it right. The problem is I am looping through a table and selecting values, if there are 2 values per (row) Issuer I...
8
3425
by: Lawrence | last post by:
Hi Is there any way of using variables in XSLT? I have been using <xsl:param name="showDetails"/and want to be able to set it to say 1 or 0 dependent on certain XSL:if statements throughout...is...
1
6736
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
6908
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
5331
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,...
0
4478
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
2994
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
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
561
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.