Reply
 
Thread Tools
Old 17-10-2009, 09:08 PM   #1   [permalink]
David Ikari
Forum Master
 
David Ikari's Avatar
 
Join Date: 26 Jun 2000
Location: Newcastle, Australia
Posts: 2,388
XSL: Doing something wrong?

Might be the wrong place, might be a dumb question. But I'll ask it, 'cause that's what I'm here for!

I'm working with XSLT, trying to format an XML document. I'm in the middle of learning it for fun (using a friends uni exercises). For some reason, I can't get any xslt command to work beyond a particular section of code (excluding apply-template). Anyone able to help me figure out what's going on?

PS: airline.xml has passed W3C markup validation.


airline.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="airline-xslt.xsl"?>
<!DOCTYPE bookings [
<!ELEMENT bookings (passenger*)>
	<!ELEMENT passenger (id, address, leg+)>
		<!ELEMENT id (surname, given, initial)>
			<!ELEMENT surname (#PCDATA)>
			<!ELEMENT given (#PCDATA)>
			<!ELEMENT initial (#PCDATA)>
		<!ELEMENT address (property, street, suburb, telephone)>
			<!ELEMENT property (#PCDATA)>
			<!ELEMENT street (#PCDATA)>
			<!ELEMENT suburb (#PCDATA)>
			<!ATTLIST suburb postcode CDATA #IMPLIED>
			<!ELEMENT telephone (#PCDATA)>
		<!ELEMENT leg (date, flight)>
			<!ELEMENT date (day, month)>
				<!ELEMENT day (#PCDATA)>
				<!ELEMENT month (#PCDATA)>
					<!ATTLIST month year CDATA #REQUIRED>
			<!ELEMENT flight (arrive, depart, grade, aircraft)>
				<!ATTLIST flight ID CDATA #REQUIRED>
				<!ELEMENT arrive EMPTY>
					<!ATTLIST arrive airportID CDATA #REQUIRED>
					<!ATTLIST arrive time CDATA #REQUIRED>
				<!ELEMENT depart EMPTY>
					<!ATTLIST depart airportID CDATA #REQUIRED>
					<!ATTLIST depart time CDATA #REQUIRED>
				<!ELEMENT grade EMPTY>
					<!ATTLIST grade type CDATA #REQUIRED>
				<!ELEMENT aircraft EMPTY>
					<!ATTLIST aircraft ID CDATA #IMPLIED>
]>

<bookings>
	<passenger>
		<id>
			<surname>Franks</surname>
			<given>Paul</given>
			<initial>J</initial>	
		</id>
		<address>
			<property>University of Newcastle</property>
			<street>University Drive</street>
			<suburb postcode="2308">CALLAGHAN</suburb>
			<telephone>0249216175</telephone>	
		</address>
		<leg>
			<date>
				<day>11</day>
				<month year="2003">August</month>
			</date>
			<flight ID="QF005">
				<arrive airportID="SIN" time="21:35"/>
				<depart airportID="SYD" time="15:45"/>
				<grade type="Economy"/>
				<aircraft ID="744"/>
			</flight>	
		</leg>
		<leg>
			<date>
				<day>21</day>
				<month year="2003">August</month>
			</date>
			<flight ID="QF010">
				<arrive airportID="MEL" time="04:55"/>
				<depart airportID="SIN" time="19:45"/>
				<grade type="Economy"/>
				<aircraft/>
			</flight>
		</leg>
		<leg>
			<date>
				<day>24</day>
				<month year="2003">August</month>
			</date>
			<flight ID="QF434">
				<arrive airportID="SYD" time="14:20"/>
				<depart airportID="MEL" time="13:00"/>
				<grade type="Business"/>
				<aircraft ID="73H"/>
			</flight>
		</leg>
	</passenger>
</bookings>
airline-xslt.xslt
Code:
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml">

<xsl:template match="bookings">

  <html xml:lang="en" lang="en">

  <head>
    <title>Banana Airline Bookings</title>
  </head>

  <body>

    <h1>Welcome to Banana Airlines</h1>
	<p>
		<xsl:value-of select="passenger/id" />
		<xsl:value-of select="passenger/address" />
		<xsl:value-of 

select="passenger/address/suburb/@postcode" />
		<xsl:for-each select="passenger/leg">
			<xsl:value-of select="date" />
			<xsl:value-of select="date/month/@year" />
			<xsl:value-of select="flight" />
		</xsl:for-each>

	</p>

    <xsl:apply-templates select="bookings" />

  </body>

  </html>

</xsl:template>

</xsl:stylesheet>
Problem: <xsl:value-of select="flight" /> Doesn't return any value no matter where it is placed, or how I try and read it. Any help?
David Ikari is offline   Reply With Quote
Reply

Thread Tools

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What's wrong? Nairohe General Non-Anime Discussion Archive 2000-2003 9 29-03-2002 02:58 PM


New To Site? Need Help?

All times are GMT -4. The time now is 06:58 AM.


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2018, vBulletin Solutions, Inc.