473,395 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can't get my XSL Stylesheet working..

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:output 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>
Jul 20 '05 #1
1 1431
This is a VFAQ.

See: http://www.topxml.com/people/bosley/defaultns.asp
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Jonathan" <j.********@ntlworld.com> wrote in message
news:77**************************@posting.google.c om...
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:output 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>

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sarah Haskins | last post by:
I have a few questions about this problem I'm having involving XML, DTD, and XSL. I'm working with this DTD which defines a stylesheet, as such... <?xml version="1.0" encoding="UTF-8"?>...
1
by: MC | last post by:
Hi to all, I would like to use in a XSL stylesheet an array variable which is defined in a Java program. For example, in my program, i defined a tab variable String tab = {"first", "second",...
2
by: Dave Kuhlman | last post by:
I'd like to specify a stylesheet for a section of my page. And, within that section, I want my stylesheet to override all other stylesheets (and styles). For example: <div...
4
by: Steve | last post by:
Hi, I have the below line in every page of a site, to set up the top section of the page: <table width="100%" cellspacing="0" cellpadding="0" background="images/index_topstrip.gif">
3
by: Ron Vecchi | last post by:
I'm pretty new to Xml and Xslt so bear with. I cant seem to add the xsl prefix to my stylesheet and get it to work. Error: The wrong namespace was used for XSL. Use...
0
by: hq4000 | last post by:
Given AStyleSheet.xsl : <AStyleSheet> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.mytest.mytest2.mytest3.com" version="1.0"> <xsl:output method="xml"...
9
by: gkountz | last post by:
Hi: I am brand new to css and a have a limited amount of working knowledge regarding HTMl. This is primarily from using Frontpage. I recently purchased Stylemaster, a css authoring program,...
3
by: RC | last post by:
Let's say: if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { // Now I got an XML object here var xmlDocument = XMLHttpRequestObject.responseXML; // next I have...
6
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I want to insert a CSS Stylesheet file in a <LINKtag inside my MasterPage so that it will work in all of the the ASPX pages that use that MasterPage (no matter where the page is in the directory...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.