I have spent a long time trying to figure this out but I am having luck. Here is my XML file:
Code:<?xml version="1.0" encoding="UTF-8"?> <flights xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="flights.xsd"> <flight flightid="1"> <flightno>EK98</flightno> <callsign>UAE98</callsign> <airline>Emirates Airline</airline> <plane planeid="1"> <name>Airbus A380-861</name> <registereddate>07-06-10</registereddate> </plane> <registration>3A6-EDJ</registration> <altitude height="feet">41000</altitude> <speed ratio="mph">564</speed> <distance unit="miles">erf</distance> <route> <routename>FCO-DXB</routename> <from> <iatacode>FCO</iatacode> <airport>Fiumicino</airport> <country>Italy</country> <city>Rome</city> <latitude>41.8044</latitude> <longitude>12.2508</longitude> </from> <to> <iatacode>DXB</iatacode> <airport>Dubai Intl</airport> <country>United Arab Emirates</country> <city>Dubai</city> <latitude>25.2528</latitude> <longitude>55.3644</longitude> </to> </route> <course bearing="degrees">154</course> <journey> <distance type="miles">2,697</distance> <time>PT5H30M</time> </journey> </flight> <flight flightid="2"> <flightno>BA283</flightno> <callsign>BAW283</callsign> <airline>British Airways</airline> <plane planeid="2"> <name>Boeing 747-436</name> <registereddate>06-12-97</registereddate> </plane> <registration>3A6-EDJ</registration> <altitude height="feet">41000</altitude> <speed ratio="mph">564</speed> <distance unit="miles">erf</distance> <route> <routename>LHR-LAX</routename> <from> <iatacode>LHR</iatacode> <airport>Heathrow</airport> <country>England</country> <city>London</city> <latitude>51.4775</latitude> <longitude>0.4614</longitude> </from> <to> <iatacode>LAX</iatacode> <airport>Los Angeles International</airport> <country>United States of America</country> <city>L.A</city> <latitude>33.9471</latitude> <longitude>-118.4082</longitude> </to> </route> <course bearing="degrees">154</course> <journey> <distance type="miles">5,441 miles</distance> <time>PT11H5M</time> </journey> </flight> </flights>
Here is an image of what I am trying to achieve:
table.png
Here is my attempt at the XSTL:
I would really appreciate some help to figure this out.Code:<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" omit-xml-declaration="yes" /> <xsl:param name="code" select="'FCO-DXB'" /> <xsl:template match="/flights"> <html> <head> <title>flights</title> </head> <body> <xsl:apply-templates select="flight/route[routename/. = $code]" /> </body> </html> </xsl:template> <xsl:template match="routename"> <table> <tr> <td><b>IATA Code</b></td> <td><b>Airport</b></td> <td><b>Country</b></td> </tr> <xsl:apply-templates select="*" /> </table> </xsl:template> <xsl:template match="from|to"> <tr><xsl:apply-templates select="*" /></tr> </xsl:template> <xsl:template match="iatacode|airport|country|city"> <td><xsl:value-of select="." /></td> </xsl:template> <xsl:template match="text()" /> </xsl:stylesheet>
Thank you!!



Reply With Quote
Bookmarks