xslt sibling node problem

Status
Not open for further replies.

rwhcurtis

Solid State Member
Messages
7
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:eek:utput 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?
 
Status
Not open for further replies.
Back
Top Bottom