I was outputting my XSLT as HTML, but I have read that outputting as XML is better for validation reasons. So when I change my output from HTML to XML it ruins the page, so does this mean I need to remove all HTML elements from the XSLT file now? I am also styling via an external CSS file, when outputting as XML, does the styling need to be within the XSLT file?
Here is my code for the page:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="xml"
doctype-system="http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd"
doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.2//EN" />
<xsl:template match="/">
<xsl:element name="head">
<xsl:element name="title">Selected Flight Route</xsl:element>
<link rel="stylesheet" type="text/css" href="mystyles.css" title="Style"/>
</xsl:element>
<xsl:element name="body">
<xsl:element name="div"><!-- This holds the navigation bar-->
<xsl:attribute name="id">
<xsl:text>navdiv</xsl:text>
</xsl:attribute>
<xsl:element name="div"><!-- This holds the image links-->
<xsl:attribute name="id">
<xsl:text>navlinks</xsl:text>
</xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="id">
<xsl:text>navlinksone</xsl:text>
</xsl:attribute>
<xsl:attribute name="href">flights.php</xsl:attribute>
</xsl:element>
<xsl:element name="a">
<xsl:attribute name="id">
<xsl:text>navlinkstwo</xsl:text>
</xsl:attribute>
<xsl:attribute name="href">planes.php</xsl:attribute>
</xsl:element>
<xsl:element name="a">
<xsl:attribute name="id">
<xsl:text>navlinksthree</xsl:text>
</xsl:attribute>
<xsl:attribute name="href">weatherfeed.php</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:element><!-- End the navigation bar-->
<xsl:element name="div"><xsl:attribute name="id">
<xsl:text>maindiv</xsl:text>
</xsl:attribute>
<h1 id="heading">Flights and planes</h1>
<xsl:element name="div"><xsl:attribute name="id">
<xsl:text>divone</xsl:text>
</xsl:attribute><img width="30" height="30" src="globe.png"/><p class="centerp">Selecting the Globe will display all flight routes.</p></xsl:element>
<xsl:element name="div"><xsl:attribute name="id">
<xsl:text>divtwo</xsl:text>
</xsl:attribute><img width="75" height="30" src="planepic.png"/><p class="centerp">Selecting the Plane will display all Aircraft info.</p></xsl:element>
<xsl:element name="div"><xsl:attribute name="id">
<xsl:text>divthree</xsl:text>
</xsl:attribute><img width="32" height="30" src="weather.png"/><p class="centerp">The Weather icon displays the weather in all citys.</p></xsl:element>
</xsl:element>
</xsl:element>
<!-- End the Body element -->
</xsl:template>
<!-- End the Main Template element -->
</xsl:stylesheet>
Here is a link to the page with the output as XML, and here is the same page with output as HTML, can anyone tell me why this is messing up my page when outputting as XML? While researching to see what the issue was I noticed that example files outputting as XML did not seem to have any HTML elements in there.
Here is the original file I use to transform the XML:
<?php
$xml = new DOMDocument();
$xml->load('flights.xml');
$xsl = new DOMDocument;
$xsl->load('index.xsl');
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl);
echo $proc->transformToXML($xml);
?>