Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-26-2009, 07:37 AM   #1 (permalink)
 
Newb Techie

Join Date: Mar 2009

Posts: 7

rwhcurtis is on a distinguished road

Exclamation xsl problem

Im having problems gerenerating a xhtml document from an xml using xslt. The problem is that I cant generate an xhtml that shows data from the xml which comes from a sibling nodes of the same name.....heres the example

XML

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="req3.xsl"?>
<cars xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="cars.xsd">
<car transmission="manual" engine="petrol">
<make>Nissan</make>
<model>Primera</model>
<cc>1500</cc>
<year>1996</year>
<price>3.200</price>
<colour>Green</colour>
<image-filename>primera.jpg</image-filename>
<email>bob@carsales.com</email>
<feature>Air conditioning</feature>
<feature>CD player</feature>
</car>
</cars>

XSLT

?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/htm11.dtd"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Massey Used Cars</title>
</head>
<body>
<h1>Cars</h1>
<xsl:for-each select="cars/car">
<p>
<img>
<xsl:attribute name="src">
<xsl:value-of select="image-filename"/><br />
</xsl:attribute>
<xsl:attribute name="alt">Not Available</xsl:attribute>
</img>
<br />
Make: <xsl:value-of select="make"/><br />
Model <xsl:value-of select="model"/><br />
Engine: <xsl:value-of select="cc"/>cc, <xsl:value-of select="@transmission"/>, <xsl:value-of select="@engine"/><br />
Year: <xsl:value-of select="year"/><br />
Price: $<xsl:value-of select="price"/><br />
Colour: <xsl:value-of select="colour"/><br />
Email: <xsl:value-of select="email"/><br />
<xsl:for-each select="feature">
Features: <xsl:value-of select="/feature"/><br />
</xsl:for-each>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

XHTML OUTPUT

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/htm11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title>Massey Used Cars</title></head><body><h1>Cars</h1><p><img src="primera.jpg" alt="Not Available"/><br/>
Make: Nissan<br/>
Model Primera<br/>
Engine: 1500cc, manual, petrol<br/>
Year: 1996<br/>
Price: $3.200<br/>
Colour: Green<br/>
Email: bob@carsales.com<br/>
Features: <br/>
Features: <br/></p>
<p>
........
...


As you can see the 'features' of the cars arent appearing in the xhtml?

Could anyone help me witht this please?
rwhcurtis is offline  
Old 04-26-2009, 09:07 AM   #2 (permalink)
oldskool's Avatar
 
Electrical Systems Design

Join Date: Jun 2008

Location: Maine, USA

Posts: 1,646

oldskool has a spectacular aura aboutoldskool has a spectacular aura about

Default Re: xsl problem

It appears there is a "smiley" ; did you inadvertently put an ")" in the code ? Or was that to just mark where you are having the problem ?
oldskool is offline  
Old 04-26-2009, 09:40 AM   #3 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: xsl problem

Put your code in code tags first of all...
__________________

Need website help? PM me!
CrazeD is offline  
Old 04-26-2009, 09:48 AM   #4 (permalink)
 
Newb Techie

Join Date: Mar 2009

Posts: 7

rwhcurtis is on a distinguished road

Default Re: xsl problem

no im not sure why that smiley's there lol, but the problem is in the last few lines of the xhtml output... the features of the cars are not there?...

also how do i put it in code tag
rwhcurtis is offline  
Old 04-26-2009, 09:49 AM   #5 (permalink)
 
Newb Techie

Join Date: Mar 2009

Posts: 7

rwhcurtis is on a distinguished road

Default Re: xsl problem

the siblings im having problems with are the cars/car/feature... theres multiple /feature elements but i cant seem to display them in the xhtml
rwhcurtis is offline  
 
Closed Thread

Tags
xhtml, xml, xslt

Thread Tools
Display Modes

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem installing software in windows xp pro imagesmith Windows Operating Systems and Software 3 02-20-2008 02:46 PM
Serious computer problem. HeeRoMaKi Hardware Troubleshooting 71 07-28-2007 11:42 PM
Wireless Problem! dropper Computer Networking & Internet Access 3 07-08-2007 04:58 PM
Dhcp leasing problem Kloppstock Computer Networking & Internet Access 12 05-13-2007 07:13 PM
cant find the problem... Jhill1 Hardware Troubleshooting 13 05-07-2007 04:51 PM