Computer Forums

Member Login

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

Join Date: Mar 2009

Posts: 7

rwhcurtis is on a distinguished road

Exclamation xslt sibling node 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  
 
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 with Sound/Videocard Phase Hardware Troubleshooting 6 05-02-2008 07:28 AM
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
Hardware problem fufonzo Hardware Troubleshooting 1 04-09-2007 10:38 PM