473,546 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:styleshe et 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:valu e-of select="part"/></li>
</xsl:for-each>
</ol>

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

</xsl:stylesheet>

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

Mar 19 '06 #1
5 1161

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

<li><xsl:valu e-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>Te st</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.s ilmaril.ie> wrote:
<xsl:templat e 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.s ilmaril.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
1428
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 feeds that include additional refinement by the end user. To do this we have an XSL file the display a default feed, but also presents a form that...
1
3269
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 link to the gif file. why? <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"...
11
1899
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> <d:customerid>1049306</d:customerid> <e:professioncode b:dt="mv.string"> <c:v>byggtapetserarbeider</c:v>
0
995
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" src="Common/Template.ascx" />
0
1072
by: Wilson Wu | last post by:
Hi, How can i create a xml and xsl for more than one worksheet. Thanks Wilson
16
1839
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> ....html...
3
1375
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
1012
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 "Open with Transform," word tries to validate the XSL and complains about the xsl:stylesheet elements that dreamweaver inserts at the top of the...
6
2241
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> <loc>http://localhost/index.php/index.php/Games/The-edge-of-the- wall</loc>
5
3484
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 with this issue for several days, but there is no result. Could someone help me? <html> <head>
0
7504
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7694
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7792
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1921
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 we have to send another system
0
747
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.