473,397 Members | 2,068 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,397 software developers and data experts.

XSL:for-each

Hello!

When looking at a file, test1.xml in IExplorer6 or Firefox I see:

1. cup

I want the result to be:
1. cup
2. spoon
3. chair

Why aren´t all parts listed?

Here is the code (test1.xml + test1.xsl):

test1.xml :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="test1.xsl"?>
<!DOCTYPE test
[<!ELEMENT test (head)>
<!ELEMENT head (part*)>
<!ELEMENT part (#PCDATA)>]>
<test>
<head>
<part>cup </part>
<part>spoon </part>
<part>chair</part>
</head>
</test>
-----------stop------------------------------------------

test1.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>

<ol>
<xsl:for-each select="test/head">
<li><xsl:value-of select="part"/></li>
</xsl:for-each>
</ol>

</body>
</html>
</xsl:template>

</xsl:stylesheet>

----------stop-------------

Mar 19 '06 #1
5 1153

Geranium wrote:
<xsl:for-each select="test/head"> <xsl:for-each select="test/head/part"> <li><xsl:value-of select="part"/></li>

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

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 19 '06 #2
Thank you so much!
That DOT!
Mar 19 '06 #3
Geranium wrote:
Hello!

When looking at a file, test1.xml in IExplorer6 or Firefox I see:

1. cup

I want the result to be:
1. cup
2. spoon
3. chair

Why aren´t all parts listed?


You should consider using a template, not for-each.

For-each is best kept for processing out-of-sequence data,
or for reordering the data. If all you want is the data in
document order, use templates.

<xsl:template match="/">
<html>
<head><title>Test</title></head>
<body>
<ol>
<xsl:apply-templates select="test/head/part"/>
</ol>
</body>
</html>
</xsl:template>

<xsl:template match="part">
<li>
<xsl:value-of select="part"/>
</li>
</xsl:template>

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Mar 19 '06 #4
On Sun, 19 Mar 2006 23:46:38 +0000, Peter Flynn
<pe********@m.silmaril.ie> wrote:
<xsl:template match="part">
<li>
<xsl:value-of select="part"/>


<xsl:value-of select="."/>
--
Eric Amick
Columbia, MD
Mar 20 '06 #5
Eric Amick wrote:
On Sun, 19 Mar 2006 23:46:38 +0000, Peter Flynn
<pe********@m.silmaril.ie> wrote:
<xsl:template match="part">
<li>
<xsl:value-of select="part"/>


<xsl:value-of select="."/>


Duuh. Yes, sorry. Too much St Patrick's Day :-)

///Peter
Mar 20 '06 #6

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

Similar topics

3
by: deja | last post by:
Hi there, We are providing feeds via RSS/REST (query to RSS) with an attached XSL file that works quite nicely. We are now "pushing the envelope" by allowing feed-builders to build their own...
1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
11
by: Rolf Barbakken | last post by:
I have an xml with records like this one: <a:response> <a:href>http://server/public/sol/comp/1049306.eml</a:href> <a:propstat> <a:status>HTTP/1.1 200 OK</a:status> <a:prop>...
0
by: David Rose | last post by:
Hello I know nothing of XSL but was wondering if it was possible to do the following: Given an XML template: <template> <register TagPrefix="whatever" TagName="Template"...
0
by: Wilson Wu | last post by:
Hi, How can i create a xml and xsl for more than one worksheet. Thanks Wilson
16
by: Indy | last post by:
Hi, I have a XHTML input file with custom tag which specifies html fragments to include For example: <html> .... <include frag1="frag1.html" frag2="frag2.html"> More html here </include>...
3
by: Al Hatch | last post by:
I have an XML file of the form: <AAA > <BBB>0001</BBB> <CCC> <DDD>0121</DDD> </CCC> <DDD> <EEE>0152</EEE> <FFF>0032</FFF>
0
by: zach.taylor.12 | last post by:
Can anyone give me advice on the following? I need to create an XSLT to display some XML data in MS Word. I have tried using Dreamweaver to create the XSL. When I try to apply the XSL by using...
6
by: Olagato | last post by:
I need to transform this: <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url> <loc>http://localhost/index.php/index./Paths-for-the-extreme-player</ loc> </url> <url>...
5
by: Jason | last post by:
Hi all, Are you familiar with Safari? I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the latest Safari. When I test xsltProcessor, there is a error as following, I have dealt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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.