Merge pull request #1 from jnylen/master
[nonametv.git] / examples / displayfile.html
blob1fde805b083c7b37068132c738ad6c37e3aa429c
1 <html> <head> <script type="text/javascript">
3 function transformXml(xmlurl, xslturl, nodeid){
4 // load the xslt file
5 try {
6 // First try to use the Internet-Explorer method.
7 // If this fails, an exception will be thrown and we
8 // will test the Mozilla method instead.
9 var xslt = new ActiveXObject("Msxml2.XSLTemplate");
11 // Load stylesheet
12 var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
13 xslDoc.async = false;
14 xslDoc.resolveExternals = false;
15 xslDoc.load(xslturl);
16 // alert( "Stylesheet loaded" );
17 xslt.stylesheet = xslDoc;
20 var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
21 xmlDoc.async = false;
22 xmlDoc.resolveExternals = false;
23 xmlDoc.validateOnParse = false;
24 xmlDoc.load(xmlurl);
25 // alert( "Xml loaded" );
27 var xslProc = xslt.createProcessor();
28 xslProc.input = xmlDoc;
29 // xslProc.addParameter("subj", subject);
30 xslProc.transform();
31 document.getElementById(nodeid).innerHTML = xslProc.output;
33 catch(e) {
34 try{
35 var xslStylesheet;
36 var xsltProcessor = new XSLTProcessor();
37 var myDOM;
38 var xmlDoc;
40 var myXMLHTTPRequest = new XMLHttpRequest();
41 myXMLHTTPRequest.open("GET", xslturl, false);
42 myXMLHTTPRequest.send(null);
44 xslStylesheet = myXMLHTTPRequest.responseXML;
45 xsltProcessor.importStylesheet(xslStylesheet);
47 // load the xml file
48 myXMLHTTPRequest = new XMLHttpRequest();
49 myXMLHTTPRequest.open("GET", xmlurl, false);
50 myXMLHTTPRequest.send(null);
51 xmlDoc = myXMLHTTPRequest.responseXML;
53 // xsltProcessor.setParameter(null,"subj",subject);
54 // ATTENTION if you get interesting errors in the next line
55 // check if your webserver is sending the x-gzip encoding
56 // correctly! (Apache needs AddEncoding and must not have anything
57 // else relating to .gz files)
58 var fragment = xsltProcessor.transformToFragment(xmlDoc,document);
59 document.getElementById(nodeid).innerHTML = "";
60 // myDOM = fragment;
61 document.getElementById(nodeid).appendChild(fragment);
63 catch(e) {
64 alert(e);
69 function loadListing()
71 var file = document.location.search.substring(1);
73 document.getElementById('heading').innerHTML = file;
75 listingUrl = "http://" + document.location.host + "/xmltv/" + file + ".xml.gz"
76 transformXml( listingUrl, 'listing.xsl', 'listing' );
77 return false;
80 </script>
81 <style type="text/css">
82 .startdate { display: none; }
83 .enddate { display: none; }
84 </style>
86 </head>
87 <body onload="loadListing()">
89 <h2><span id="heading"></span></h2>
90 <div id="listing">
91 Loading programmes...
92 </div>
94 </body>
95 </html>