bzr branch
http://darksoft.org/webbzr/adei/trunk
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
1 |
function XSLPOOL(cache) { |
2 |
if (typeof cache == "undefined") this.use_cache = false; |
|
3 |
this.use_cache = cache; |
|
4 |
||
5 |
this.cache = new Array(); |
|
86
by Suren A. Chilingaryan
Alarms support in all browsers |
6 |
|
7 |
this.xsl_supported = true; |
|
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
8 |
}
|
9 |
||
86
by Suren A. Chilingaryan
Alarms support in all browsers |
10 |
XSLPOOL.prototype.ProcessXML = function(xmldoc, xattr, error) { |
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
11 |
if (!xmldoc) { |
89
by Suren A. Chilingaryan
Minor fixups in XML+XSLT processing |
12 |
if (xattr.handler) xattr.handler(null, xattr.attr, error); |
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
13 |
else adei.ReportError(error); |
14 |
return; |
|
15 |
}
|
|
16 |
||
86
by Suren A. Chilingaryan
Alarms support in all browsers |
17 |
if (xattr.handler) { |
18 |
var htmldoc = xsltApply(xattr.xsltdoc, xmldoc); |
|
19 |
xattr.handler(htmldoc, xattr.attr); |
|
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
20 |
} else { |
86
by Suren A. Chilingaryan
Alarms support in all browsers |
21 |
xsltApply(xattr.xsltdoc, xmldoc, xattr.attr); |
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
22 |
}
|
23 |
}
|
|
24 |
||
86
by Suren A. Chilingaryan
Alarms support in all browsers |
25 |
XSLPOOL.prototype.ApplyXSLT = function(xslt, xsltdoc, xmlurl, handler, attr) { |
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
26 |
var xattr = new Object; |
27 |
||
28 |
xattr.self = this; |
|
29 |
xattr.handler = handler; |
|
30 |
xattr.attr = attr; |
|
31 |
xattr.xsltdoc = xsltdoc; |
|
32 |
||
86
by Suren A. Chilingaryan
Alarms support in all browsers |
33 |
if (xsltdoc) { // The XSLT is supported by browser |
34 |
if (typeof xmlurl == "object") { |
|
35 |
this.ProcessXML(xmlurl, xattr); |
|
36 |
} else { |
|
37 |
loadXML(xmlurl, |
|
38 |
function (xmldoc, attr, error) { |
|
39 |
attr.self.ProcessXML(xmldoc, attr, error) |
|
40 |
}, xattr); |
|
41 |
}
|
|
42 |
} else { // XSLT is not supported |
|
43 |
this.xsl_supported = false; |
|
44 |
||
45 |
if ((!xslt)||(typeof xmlurl == "object")) { // We can't help in that case |
|
46 |
adei.ReportError(translate("Browser is not supporting XSL transform")); |
|
47 |
} else { // trying server-side transformation, should be supported |
|
48 |
if (!handler) handler = htmlReplace; |
|
49 |
loadXML(urlAddProperty(xmlurl, "xslt", xslt), handler, attr); |
|
50 |
}
|
|
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
51 |
}
|
52 |
}
|
|
53 |
||
86
by Suren A. Chilingaryan
Alarms support in all browsers |
54 |
XSLPOOL.prototype.ProcessXSLT = function(xsltdoc, xattr) { |
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
55 |
if (this.use_cache) { |
86
by Suren A. Chilingaryan
Alarms support in all browsers |
56 |
this.cache[xattr.xslt] = xsltdoc; |
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
57 |
}
|
58 |
||
86
by Suren A. Chilingaryan
Alarms support in all browsers |
59 |
return this.ApplyXSLT(xattr.xslt, xsltdoc, xattr.xmlurl, xattr.handler, xattr.attr); |
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
60 |
}
|
61 |
||
62 |
XSLPOOL.prototype.Load = function(xslt, xmlurl, handler, attr) { |
|
86
by Suren A. Chilingaryan
Alarms support in all browsers |
63 |
if (!this.xsl_supported) { |
64 |
return this.ApplyXSLT(xslt, false, xmlurl, handler, attr); |
|
65 |
}
|
|
66 |
||
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
67 |
if (typeof this.cache[xslt] != "undefined") { |
86
by Suren A. Chilingaryan
Alarms support in all browsers |
68 |
return this.ApplyXSLT(xslt, this.cache[xslt], xmlurl, handler, attr); |
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
69 |
}
|
70 |
||
71 |
var xattr = new Object; |
|
72 |
xattr.self = this; |
|
73 |
xattr.handler = handler; |
|
74 |
xattr.attr = attr; |
|
75 |
xattr.xslt = xslt; |
|
76 |
xattr.xmlurl = xmlurl; |
|
163
by Suren A. Chilingaryan
Handle setup-specific XSL files in javascript |
77 |
|
78 |
loadXSLT("services/get.php?target=xslt&xslt=" + xslt, |
|
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
79 |
function (xsltdoc, self) { xattr.self.ProcessXSLT(xsltdoc, xattr) }, |
80 |
xattr
|
|
81 |
);
|
|
205
by Suren A. Chilingaryan
Revert back to SetConfiguration from SetCustomProperties while handling certain property in search; trully support HTML content in description field within search results; support execution in XMLModule; support for setup-specific javascript code; KATRIN update |
82 |
}
|
83 |
||
84 |
XSLPOOL.prototype.HTMLReplaceCallback = function (htmldoc, place, error) { |
|
85 |
if ((typeof htmldoc != "undefined")&&(htmldoc)) { |
|
86 |
htmlReplace(htmldoc, place); |
|
87 |
} else { |
|
88 |
adei.ReportError(error); |
|
89 |
}
|
|
90 |
}
|
|
91 |
||
92 |
XSLPOOL.prototype.HTMLReplaceAndExecuteCallback = function (htmldoc, place, error) { |
|
93 |
if ((typeof htmldoc != "undefined")&&(htmldoc)) { |
|
94 |
htmlReplace(htmldoc, place, true); |
|
95 |
} else { |
|
96 |
adei.ReportError(error); |
|
97 |
}
|
|
85
by Suren A. Chilingaryan
XML+XSLT modules support, Alarms support in frontend (mozilla only) |
98 |
}
|