-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.php
More file actions
59 lines (57 loc) · 1.86 KB
/
renderer.php
File metadata and controls
59 lines (57 loc) · 1.86 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
header("Access-Control-Allow-Origin: *");
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XmlView - XmlAspect.org</title>
<!--
bookmarklet forwards to renderer.php which has ORIGIN set to original XML document.
PROS: ? no cross domain issues CONS: if PHP , incompatible with CDN
-->
<style>
iframe{float:right; width:30%; height:10em;}
.BookmarkletTag{ font-size:large; }
</style>
<script type="text/javascript">
var XmlHost = "localhost"
, XslHost = "mylocal";
document.domain = XmlHost;
function onLoad()
{
var baseUrl = "https://cdn.xml4jquery.com/ajax/libs/XmlView/1.0.0/"
, xslUrl = baseUrl+"AsTable.xsl"
, xmlUrl = baseUrl+'countries.xml';
document.body.innerHTML = "<a href='"+xslUrl+"'> loading "+xslUrl+"</a>";
getXml( xmlUrl, function (xml)
{ //document.domain = XslHost;
getXml( xslUrl, function (xsl, p, r)
{ p = new XSLTProcessor();
p.importStylesheet(xsl);
r = p.transformToFragment( xml, document );
document.body.replaceChild( r, document.body.firstChild );
});
});
function getXml(url, callback)
{ var xhr = new XMLHttpRequest();
xhr.url = url;
xhr.open("GET", url, false);
// xhr.setRequestHeader( 'Origin', document.location.origin );
// xhr.overrideMimeType( 'text/xml' );
xhr.onreadystatechange = function()
{
if( 4 != xhr.readyState )
return;
if( xhr.responseXML )
return callback( xhr.responseXML );
return new DOMParser().parseFromString( xhr.responseText, "application/xml" );
}
xhr.send();
}
}
</script>
</head>
<body onload="onLoad();">
<h1>Loading...</h1>
</body>
</html>