topical media & game development
mashup-amazon-10-10-01-SimpleTransform-Default.aspx / aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Simple Transformation</title>
<script language="javascript">
var myXml ;
var myXsl ;
function Init(){
if (window.ActiveXObject){
// Create an Xml object
myXml = new ActiveXObject("Msxml2.DomDocument");
// Create an Xsl object
myXsl = new ActiveXObject("Msxml2.DomDocument");
} else {
myXml = document.implementation.createDocument("","xsl",null);
myXsl = document.implementation.createDocument("","xsl",null);
}
// Set both documents to be synchronous
myXml.async=false;
myXsl.async=false;
// load the sample file
myXml.load('zeppelin.xml');
// Load the sample transformation
myXsl.load('Simple.xsl');
}
function DoTransform(){
if (window.ActiveXObject){
// Transform the data.
var strTmp = myXml.transformNode(myXsl);
// Print out the results
document.getElementById('results').innerHTML = strTmp;
} else {
// Create Processor
var myProcessor = new XSLTProcessor();
myProcessor.importStylesheet(myXsl);
var myResults = myProcessor.transformToFragment(myXml, document);
var target = document.getElementById('results');
// display the response
target.appendChild(myResults);
}
}
</script>
</head>
<body onload="Init()">
<form id="form1" runat="server">
<h1>Simple XSL Transformation</h1>
Click the button to transform XML using the browser's XSL parser. <br />
<input type="button" onclick="DoTransform()" value="Click Me" />
<div id="results">
Results go here.
</div>
</form>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.