Animeboards.com Forums

Animeboards.com Forums (http://animeboards.com/index.php)
-   HTML, PHP, MySQL, Graphics, Coding (http://animeboards.com/forumdisplay.php?f=88)
-   -   XSL: Doing something wrong? (http://animeboards.com/showthread.php?t=67739)

David Ikari 17-10-2009 09:08 PM

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?


All times are GMT -4. The time now is 02:15 PM.

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