-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpage_example.html
76 lines (67 loc) · 2.07 KB
/
webpage_example.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc(filename)
{
if (window.ActiveXObject)
{
xhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
else
{
xhttp = new XMLHttpRequest();
}
xhttp.open("GET", filename, false);
try {xhttp.responseType = "msxml-document"} catch(err) {} // Helping IE11
xhttp.send("");
return xhttp.responseXML;
}
function translate(xml_source)
{
xsl = loadXMLDoc("isybau2interlis/isybau2vdsdss.xsl");
// code for IE
if (window.ActiveXObject || xhttp.responseType == "msxml-document")
{
ex = xml_source.transformNode(xsl);
return ex;
}
// code for Chrome, Firefox, Opera, <etc class=""></etc>
else if (document.implementation && document.implementation.createDocument)
{
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml_source, document);
return resultDocument;
}
}
function download(filename, text_contents) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text_contents));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
function convert(xml_source){
// Translate document
interlis_file_contents = translate(xml_source);
// Start file download.
download("interlis2.txt", interlis_file_contents);
}
function read_uploaded_file(){
// Read uploaded document
const input_file = document.getElementById('input').files[0];
var reader = new FileReader();
reader.readAsText(input_file);
return reader;
}
</script>
</head>
<body>
NB: Not yet working!<br>
ISYBAU Stammdaten <input type="file" id="input" multiple><br>
<input type="button" value="Convert File" onclick="convert();"></inputbutton>
</body>
</html>