Can't get my XSL Stylesheet working..

J

Jonathan

At the moment I have 3 files: a small XML instance document, a schema
(which the .xml validates against fine) and a work-in-progress .xsl.
(posted below)
The problem is that I cannot get the stylesheet to grab any data from
the XML document so I just end up with an empty HTML file.
However, if I change the XML file to look at an equivalent DTD
(instead of the XSD) it works as it should.
Any help would be greatly appreciated. I have posted a sample of my
code below.

Thanks in advance.


films.xsd:

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.mycompany.com/filmcatalog"
xmlns:target="http://www.mycompany.com/filmcatalog"
elementFormDefault="qualified">

<element name="filmcatalog">
<complexType>
<sequence>

<element name="Film" maxOccurs="unbounded">
<complexType>
<group ref="target:FilmGroup" />
</complexType>
</element>

</sequence>
</complexType>
</element>

<group name="FilmGroup">
<sequence>
<element name="film_title" type="normalizedString" maxOccurs="2" />
<element name="film_year" type="gYear" />
<element name="runtime" type="nonNegativeInteger" />
<element name="director" type="target:DirectorType" />
<element name="writers" type="target:WriterType" />
<element name="cast" type="target:CastType" maxOccurs="unbounded" />
<element name="film_summary" type="string" minOccurs="0" />
<element name="memorable_Quote" type="normalizedString" minOccurs="0"
maxOccurs="unbounded" />
<element name="film_certUK" type="string" minOccurs="0" />
</sequence>
</group>

<complexType name="DirectorType">
<sequence>
<element name="name" type="string" maxOccurs="2" />
</sequence>
</complexType>

<complexType name="WriterType">
<sequence>
<element name="name" type="string" maxOccurs="unbounded" />
</sequence>
</complexType>

<complexType name="CastType">
<sequence>
<element name="name" type="string" />
<element name="role_played" type="token" minOccurs="1"
maxOccurs="unbounded" />
</sequence>
</complexType>
</schema>


Films.xml:

<?xml version="1.0"?>
<!--<!DOCTYPE filmcatalog SYSTEM "films.dtd">
<filmcatalog>!-->
<filmcatalog
xmlns="http://www.mycompany.com/filmcatalog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mycompany.com/filmcatalog films.xsd">

<Film>

<film_title>The Big Lebowski</film_title>
<film_year>1998</film_year>
<runtime>117</runtime>
<director>
<name>Joel Coen</name>
</director>
<writers>
<name>Ethan Coen</name>
<name>Joel Coen</name>
</writers>
<cast>
<name>Jeff Bridges</name>
<role_played>Jeff 'The Dude' Lebowski</role_played>
</cast>
<cast>
<name>John Goodman</name>
<role_played>Walter Sobchak</role_played>
</cast>
<cast>
<name>Steve Buscemi</name>
<role_played>"Donny"</role_played>
</cast>
<film_summary>Dude Lebowski, mistaken for a millionaire Lebowski,
seeks restitution for his ruined rug and enlists his bowling buddies
to help get it.</film_summary>
<memorable_Quote></memorable_Quote>
<film_certUK>18</film_certUK>

</Film>
</filmcatalog>


and Films.xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="html" encoding="UTF-8"/>

<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="filmcatalog/Film/film_title"/></title>
</head>

<body>
<h1>Film: <xsl:value-of select="filmcatalog/Film/film_title"/></h1>
<p>Year: <xsl:value-of select="filmcatalog/Film/film_year"/></p>
<p>Summary: <xsl:value-of
select="filmcatalog/Film/film_summary"/></p>
<p>Runtime: <xsl:value-of select="filmcatalog/Film/runtime"/>
mins.</p>
<p>UK Certification: <xsl:value-of
select="filmcatalog/Film/film_certUK"/></p>
<p>Directors: <xsl:value-of
select="filmcatalog/Film/director/name"/></p>
<p>Writers: <xsl:value-of
select="filmcatalog/Film/writers/name"/></p>
<p><b>Cast</b><br/>
<TABLE>
<TR>
<TH>Name</TH>
<TH>Role</TH>
</TR>
<xsl:apply-templates select="filmcatalog/Film/cast"/>
</TABLE></p>
<p>Quote: "<xsl:value-of
select="filmcatalog/Film/memorable_Quote"/>"</p>
</body>
</html>

</xsl:template>


<xsl:template match="filmcatalog/Film/cast">
<TR>
<TD><xsl:value-of select="name"/></TD>
<TD><xsl:value-of select="role_played"/></TD>
</TR>
</xsl:template>

</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top