-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXsltProcessorExample03.htm
More file actions
executable file
·36 lines (31 loc) · 1.25 KB
/
Copy pathXsltProcessorExample03.htm
File metadata and controls
executable file
·36 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html>
<head>
<title>XSLTProcessor Example</title>
<script type="text/javascript">
window.onload = function () {
//use XHR to load
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("get", "employees.xml", false);
xmlhttp.send(null);
var xmldom = xmlhttp.responseXML;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("get", "employees2.xslt", false);
xmlhttp.send(null);
var xsltdom = xmlhttp.responseXML;
var processor = new XSLTProcessor();
processor.importStylesheet(xsltdom);
processor.setParameter(null, "message", "Hello World!");
var fragment = processor.transformToFragment(xmldom, document);
var div = document.getElementById("divResult");
div.appendChild(fragment);
}
</script>
</head>
<body>
<p>This example loads employees.xml and transforms it using employees2.xslt.
The parameter <code>message</code> is passed in and is equal to "Hello
World!". The resulting code is then displayed.</p>
<div id="divResult"></div>
</body>
</html>