Note that there are some explanatory texts on larger screens.

plurals
  1. POLink to .XSL file from a .HTML file
    text
    copied!<p>I am sure this is real easy and I am just missing something simple but...</p> <p>I have a home page (index.html) and I want to link to another page that is an .xsl file (to show some xml data). I am using this code to do it:</p> <pre><code>&lt;h1&gt;&lt;a href="catalogue_overview.xsl"&gt;VIEW CATALOGUE&lt;/a&gt;&lt;/h1&gt; </code></pre> <p>When I open the .xsl file by itself (I use Dreamweaver) it opens and displays the data (from the xml file) fine.</p> <p>When I open it from the link on the index.html page it just shows me the unformatted text contained in the <code>&lt;h&gt;</code> and <code>&lt;p&gt;</code> tags etc. There is no formatiing and no xml data.</p> <p>What am I doing wrong?</p> <p>Do I need to tell the index.html file something so it knows about the .xsl file?</p> <p>Am I doing this wrong?</p> <p>I am linking to a PHP file the same way and that seems to work fine.</p> <p>I will post my code in case that helps!</p> <h2>XML FILE</h2> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;?xml-stylesheet type="text/xsl" href="catalogue_overview.xsl"?&gt; &lt;catalogue&gt; &lt;record&gt; &lt;catId&gt;001&lt;/catId&gt; &lt;title&gt;Fungus&lt;/title&gt; &lt;location&gt;NP&lt;/location&gt; &lt;photographer&gt;Me&lt;/photographer&gt; &lt;equipment&gt;Canon EOS 40D&lt;/equipment&gt; &lt;caption&gt;Small fungus of the genus Fungaroidiae on a log&lt;/caption&gt; &lt;notes&gt;This is a very rare species of fungus&lt;/notes&gt; &lt;date&gt;10/8/2012&lt;/date&gt; &lt;imageUrl&gt;images/IMG_1684.jpg&lt;/imageUrl&gt; &lt;/record&gt; &lt;/catalogue&gt; </code></pre> <h2>XSL FILE</h2> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;!-- DWXMLSource="catalogue.xml" --&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="html" encoding="UTF-8"/&gt; &lt;xsl:template match="catalogue"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Photo Catalogue&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="css/style.css"/&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 align="center"&gt; Photo Catalogue&lt;/h1&gt; &lt;h2 align="center"&gt; Catalogue Overview &lt;/h2&gt; &lt;p align="center"&gt; This is an overview of the photo catalogue. It enables the user to have a quick and easy browse through the images and their information.&lt;/p&gt; &lt;hr/&gt; &lt;xsl:apply-templates/&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:template match="catId"&gt; &lt;h2&gt; Catalogue ID: &lt;span style="color:2A588F"&gt;&lt;xsl:apply-templates/&gt; &lt;/span&gt; &lt;/h2&gt; &lt;/xsl:template&gt; &lt;xsl:template match="title"&gt; &lt;h3&gt; Title: &lt;span style="color:2A588F"&gt;&lt;xsl:apply-templates/&gt; &lt;/span&gt; &lt;/h3&gt; &lt;/xsl:template&gt; &lt;xsl:template match="location"&gt; &lt;p&gt; Location: &lt;span style="color:2A588F"&gt;&lt;xsl:apply-templates/&gt; &lt;/span&gt; &lt;/p&gt; &lt;/xsl:template&gt; &lt;xsl:template match="photographer"&gt; &lt;p&gt; Photographer: &lt;span style="color:2A588F"&gt;&lt;xsl:apply-templates/&gt; &lt;/span&gt; &lt;/p&gt; &lt;/xsl:template&gt; &lt;xsl:template match="equipment"&gt; &lt;p&gt; Equipment: &lt;span style="color:2A588F"&gt;&lt;xsl:apply-templates/&gt; &lt;/span&gt; &lt;/p&gt; &lt;/xsl:template&gt; &lt;xsl:template match="caption"&gt; &lt;p&gt; Caption: &lt;span style="color:2A588F"&gt;&lt;xsl:apply-templates/&gt; &lt;/span&gt; &lt;/p&gt; &lt;/xsl:template&gt; &lt;xsl:template match="notes"&gt; &lt;p&gt; Notes: &lt;span style="color:2A588F"&gt;&lt;xsl:apply-templates/&gt; &lt;/span&gt; &lt;/p&gt; &lt;/xsl:template&gt; &lt;xsl:template match="date"&gt; &lt;p&gt; Date: &lt;span style="color:2A588F"&gt;&lt;xsl:apply-templates/&gt; &lt;/span&gt; &lt;/p&gt; &lt;/xsl:template&gt; &lt;xsl:template match="imageUrl"&gt; &lt;p&gt;Image:&lt;br/&gt;&lt;img src="{.}" width="250"/&gt;&lt;/p&gt; &lt;hr/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <h2>INDEX.HTML FILE</h2> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Photo Catalogue - HOME&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="css/style.css"/ &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;div class="content"&gt; &lt;h1&gt;Photo Catalogue&lt;/h1&gt; &lt;h2&gt;Welcome to the Photo Catalogue&lt;/h2&gt; &lt;p&gt;It is intended to be a simple tool to store you favourite photos for easy viewing. It uses XML to store the image details and this is retrieved, displayed and edited using a combination of XSL and PHP.&lt;/p&gt; &lt;h2&gt;Navigation&lt;/h2&gt; &lt;p&gt;Select the option you would like below to see its functionality...&lt;/p&gt; &lt;h1&gt;&lt;a href="catalogue_overview.xsl"&gt;VIEW CATALOGUE&lt;/a&gt;&lt;/h1&gt; &lt;h1&gt;&lt;a href="catalogueupdate.php"&gt;EDIT CATALOGUE&lt;/a&gt;&lt;/h1&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Hope this helps</p> <p>NOTE the link to the .php file seems to work fine. I am running off XAMPP.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload