Step by Step
- Create or use an existing .xml file.
- You can reference your .xsd file (schema) if you've created one, in the opening element tag of the root element <document of your xml page as shown in the following code example.
- DO NOT reference your .xsl file in your .xml page. This will be done by the CrossBrowser.js file in your .xhtml loader page.
-
<?xml version="1.0" encoding="utf-8"?>
-
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" -
xsi:noNamespaceSchemaLocation="Example.xsd">
-
- Create or use an existing .xsl (.xslt) file.
- Make sure you set your xsl:output method="...." to xml as shown in the following code example (this is a Mozilla/Gecko browser requirement).
- Also, if you use an external .css file(master.css), include the relative path to it in the <head></head> section in the
following code example.
-
<?xml version="1.0" encoding="utf-8"?>
-
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
<xsl:output method="xml"/> -
<xsl:template match="/">
-
<html>
-
<head>
-
<title>Example.xsl</title>
-
<link> href="master.css" media="screen" rel="stylesheet" type="text/css"/> -
<meta>content="text/html; charset=UTF-8" http-equiv="Content-Type" />
-
</head>
-
- The Sarissa ECMAscript Library v.0.9.6.1 folder has been provided for you in the main folder.
- Create a scripts folder in your Project folder and copy the sarissa.js file located in the Sarissa ECMAscript Library to it.
- Create the CrossBrowser.js file (the following code example) and put it in the same scripts folder with the sarissa.js file.
- Add your xsl and xml file names to the var xslStylesheet = "........"; and the var xmlDatafile = "...........";
as shown in the following code example.
-
var xslStylesheet = "Example.xsl"; -
var xmlDatafile = "Example.xml"; -
-
var xslDoc = Sarissa.getDomDocument();
-
xslDoc.async = false;
-
xslDoc.load(xslStylesheet);
-
-
var xmlDoc = Sarissa.getDomDocument();
-
xmlDoc.async = false;
-
xmlDoc.load(xmlDatafile);
-
-
var processor = new XSLTProcessor();
-
processor.importStylesheet(xslDoc);
-
-
var resultDocument = processor.transformToDocument(xmlDoc);
-
document.write(Sarissa.serialize(resultDocument));
-
- Add your xsl and xml file names to the var xslStylesheet = "........"; and the var xmlDatafile = "...........";
as shown in the following code example.
- Attach the external Javascipts to the (X)HTML Loader web page.
- You can change the <title> of the web page and the <link> to your own external .css file.
- In the <head></head> section, create a relative path to the external sarissa.js script with the <script></script> element..
- In the <body></body> section, create a relative path to the external CrossBrowser.js script with the <script></script> element.
- Save all files and then double-click on your Example.htm file to open it.
- It will open and render respectively in Microsoft Internet Explorer, Firefox, Netscape and Mozilla browsers.