1 |
4307
|
leinfelder
|
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
|
2 |
|
|
<html>
|
3 |
|
|
<head>
|
4 |
|
|
<title>
|
5 |
|
|
<a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008 Overview
|
6 |
|
|
</title>
|
7 |
|
|
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
|
8 |
|
|
<script>
|
9 |
|
|
function asd() {
|
10 |
|
|
|
11 |
|
|
parent.document.title="Sarissa.js Overview";
|
12 |
|
|
|
13 |
|
|
}
|
14 |
|
|
</script>
|
15 |
|
|
</head>
|
16 |
|
|
<body bgcolor="white" onload="asd();">
|
17 |
|
|
|
18 |
|
|
<!-- ========== START OF NAVBAR ========== -->
|
19 |
|
|
<a name="navbar_top"><!-- --></a>
|
20 |
|
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
21 |
|
|
<tr>
|
22 |
|
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
23 |
|
|
<a name="navbar_top_firstrow"><!-- --></a>
|
24 |
|
|
<table border="0" cellpadding="0" cellspacing="3">
|
25 |
|
|
<tr align="center" valign="top">
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
29 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
33 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
34 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
35 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
36 |
|
|
</tr>
|
37 |
|
|
</table>
|
38 |
|
|
</td>
|
39 |
|
|
<td bgcolor="#EEEEFF" align="right" valign="top">
|
40 |
|
|
<em>
|
41 |
|
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
42 |
|
|
</td>
|
43 |
|
|
</tr>
|
44 |
|
|
|
45 |
|
|
<tr>
|
46 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
47 |
|
|
PREV
|
48 |
|
|
NEXT</font></td>
|
49 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
50 |
|
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
51 |
|
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
52 |
|
|
|
53 |
|
|
<script>
|
54 |
|
|
<!--
|
55 |
|
|
if(window==top) {
|
56 |
|
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
57 |
|
|
}
|
58 |
|
|
//-->
|
59 |
|
|
</script>
|
60 |
|
|
<noscript>
|
61 |
|
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
62 |
|
|
</noscript>
|
63 |
|
|
</font></td>
|
64 |
|
|
</tr>
|
65 |
|
|
</table>
|
66 |
|
|
<!-- =========== END OF NAVBAR =========== -->
|
67 |
|
|
|
68 |
|
|
<hr>
|
69 |
|
|
<center>
|
70 |
|
|
|
71 |
|
|
<h2>Sarissa.js</h2>
|
72 |
|
|
|
73 |
|
|
</center>
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
<h4>Summary</h4>
|
79 |
|
|
<p>
|
80 |
|
|
|
81 |
|
|
No overview generated for 'Sarissa.js'<BR/><BR/>
|
82 |
|
|
|
83 |
|
|
</p>
|
84 |
|
|
|
85 |
|
|
<hr>
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
<table border="1" cellpadding="3" cellspacing="0" width="100%">
|
89 |
|
|
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
|
90 |
|
|
<td colspan=2><font size="+2">
|
91 |
|
|
|
92 |
|
|
<b>Class Summary</b>
|
93 |
|
|
|
94 |
|
|
</font></td>
|
95 |
|
|
</tr>
|
96 |
|
|
|
97 |
|
|
<tr bgcolor="white" class="TableRowColor">
|
98 |
|
|
<td width="15%"><b><a href="Sarissa.html">Sarissa</a></b></td>
|
99 |
|
|
<td> </td>
|
100 |
|
|
</tr>
|
101 |
|
|
|
102 |
|
|
<tr bgcolor="white" class="TableRowColor">
|
103 |
|
|
<td width="15%"><b><a href="XSLTProcessor.html">XSLTProcessor</a></b></td>
|
104 |
|
|
<td> </td>
|
105 |
|
|
</tr>
|
106 |
|
|
|
107 |
|
|
<tr bgcolor="white" class="TableRowColor">
|
108 |
|
|
<td width="15%"><b><a href="XMLSerializer.html">XMLSerializer</a></b></td>
|
109 |
|
|
<td> </td>
|
110 |
|
|
</tr>
|
111 |
|
|
|
112 |
|
|
<tr bgcolor="white" class="TableRowColor">
|
113 |
|
|
<td width="15%"><b><a href="XMLHttpRequest.html">XMLHttpRequest</a></b></td>
|
114 |
|
|
<td> </td>
|
115 |
|
|
</tr>
|
116 |
|
|
|
117 |
|
|
</table>
|
118 |
|
|
<hr/>
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
122 |
|
|
|
123 |
|
|
<!-- ========== END METHOD SUMMARY =========== -->
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
<pre class="sourceview"><span class="comment">/**
|
127 |
|
|
* ====================================================================
|
128 |
|
|
* About
|
129 |
|
|
* ====================================================================
|
130 |
|
|
* Sarissa is an ECMAScript library acting as a cross-browser wrapper for native XML APIs.
|
131 |
|
|
* The library supports Gecko based browsers like Mozilla and Firefox,
|
132 |
|
|
* Internet Explorer (5.5+ with MSXML3.0+), Konqueror, Safari and a little of Opera
|
133 |
|
|
* <span class="attrib">@version</span> 0.9.7.6
|
134 |
|
|
* <span class="attrib">@author</span>: Manos Batsis, mailto: mbatsis at users full stop sourceforge full stop net
|
135 |
|
|
* ====================================================================
|
136 |
|
|
* Licence
|
137 |
|
|
* ====================================================================
|
138 |
|
|
* Sarissa is free software distributed under the GNU GPL version 2 (see <a href="gpl.txt">gpl.txt</a>) or higher,
|
139 |
|
|
* GNU LGPL version 2.1 (see <a href="lgpl.txt">lgpl.txt</a>) or higher and Apache Software License 2.0 or higher
|
140 |
|
|
* (see <a href="asl.txt">asl.txt</a>). This means you can choose one of the three and use that if you like. If
|
141 |
|
|
* you make modifications under the ASL, i would appreciate it if you submitted those.
|
142 |
|
|
* In case your copy of Sarissa does not include the license texts, you may find
|
143 |
|
|
* them online in various formats at <a href="http://www.gnu.org">http://www.gnu.org</a> and
|
144 |
|
|
* <a href="http://www.apache.org">http://www.apache.org</a>.
|
145 |
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
146 |
|
|
* KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
147 |
|
|
* WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE
|
148 |
|
|
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
149 |
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
150 |
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
151 |
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
152 |
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
153 |
|
|
*/</span>
|
154 |
|
|
<span class="comment">/**
|
155 |
|
|
* <p>Sarissa is a utility class. Provides "static" methods for DOMDocument,
|
156 |
|
|
* DOM Node serialization to XML strings and other utility goodies.</p>
|
157 |
|
|
* <span class="attrib">@constructor</span>
|
158 |
|
|
*/</span>
|
159 |
|
|
<span class="reserved">function</span> Sarissa(){};
|
160 |
|
|
Sarissa.PARSED_OK = <span class="literal">"Document contains no parsing errors"</span>;
|
161 |
|
|
Sarissa.PARSED_EMPTY = <span class="literal">"Document is empty"</span>;
|
162 |
|
|
Sarissa.PARSED_UNKNOWN_ERROR = <span class="literal">"Not well-formed or other error"</span>;
|
163 |
|
|
var _sarissa_iNsCounter = 0;
|
164 |
|
|
var _SARISSA_IEPREFIX4XSLPARAM = <span class="literal">""</span>;
|
165 |
|
|
var _SARISSA_HAS_DOM_IMPLEMENTATION = document.implementation && true;
|
166 |
|
|
var _SARISSA_HAS_DOM_CREATE_DOCUMENT = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.createDocument;
|
167 |
|
|
var _SARISSA_HAS_DOM_FEATURE = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.hasFeature;
|
168 |
|
|
var _SARISSA_IS_MOZ = _SARISSA_HAS_DOM_CREATE_DOCUMENT && _SARISSA_HAS_DOM_FEATURE;
|
169 |
|
|
var _SARISSA_IS_SAFARI = (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf(<span class="literal">"applewebkit"</span>) != -1 || navigator.vendor.indexOf(<span class="literal">"Apple"</span>) != -1));
|
170 |
|
|
var _SARISSA_IS_OPERA = navigator.userAgent.toLowerCase().indexOf(<span class="literal">"opera"</span>) != -1;
|
171 |
|
|
var _SARISSA_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf(<span class="literal">"msie"</span>) > -1 && navigator.userAgent.toLowerCase().indexOf(<span class="literal">"opera"</span>) == -1;
|
172 |
|
|
|
173 |
|
|
<span class="reserved">if</span>(!window.Node || !Node.ELEMENT_NODE){
|
174 |
|
|
Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5, ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12};
|
175 |
|
|
};
|
176 |
|
|
|
177 |
|
|
<span class="reserved">if</span>(typeof XMLDocument == <span class="literal">"undefined"</span> && typeof Document !=<span class="literal">"undefined"</span>){ XMLDocument = Document; }
|
178 |
|
|
<span class="comment">
|
179 |
|
|
// IE initialization</span>
|
180 |
|
|
<span class="reserved">if</span>(_SARISSA_IS_IE){
|
181 |
|
|
<span class="comment"> // for XSLT parameter names, prefix needed by IE</span>
|
182 |
|
|
_SARISSA_IEPREFIX4XSLPARAM = <span class="literal">"xsl:"</span>;
|
183 |
|
|
<span class="comment"> // used to store the most recent ProgID available out of the above</span>
|
184 |
|
|
var _SARISSA_DOM_PROGID = <span class="literal">""</span>;
|
185 |
|
|
var _SARISSA_XMLHTTP_PROGID = <span class="literal">""</span>;
|
186 |
|
|
var _SARISSA_DOM_XMLWRITER = <span class="literal">""</span>;
|
187 |
|
|
<span class="comment">/**
|
188 |
|
|
* Called when the Sarissa_xx.js file is parsed, to pick most recent
|
189 |
|
|
* ProgIDs for IE, then gets destroyed.
|
190 |
|
|
* <span class="attrib">@private</span>
|
191 |
|
|
* <span class="attrib">@param</span> idList an array of MSXML PROGIDs from which the most recent will be picked for a given object
|
192 |
|
|
* <span class="attrib">@param</span> enabledList an array of arrays where each array has two items; the index of the PROGID for which a certain feature is enabled
|
193 |
|
|
*/</span>
|
194 |
|
|
Sarissa.pickRecentProgID = <span class="reserved">function</span> (idList){
|
195 |
|
|
<span class="comment"> // found progID flag</span>
|
196 |
|
|
var bFound = false;
|
197 |
|
|
<span class="reserved">for</span>(var i=0; i < idList.length && !bFound; i++){
|
198 |
|
|
try{
|
199 |
|
|
var oDoc = new ActiveXObject(idList[i]);
|
200 |
|
|
o2Store = idList[i];
|
201 |
|
|
bFound = true;
|
202 |
|
|
}catch (objException){
|
203 |
|
|
<span class="comment"> // trap; try next progID</span>
|
204 |
|
|
};
|
205 |
|
|
};
|
206 |
|
|
<span class="reserved">if</span> (!bFound) {
|
207 |
|
|
throw <span class="literal">"Could not retreive a valid progID of Class: "</span> + idList[idList.length-1]+<span class="literal">". (original exception: "</span>+e+<span class="literal">")"</span>;
|
208 |
|
|
};
|
209 |
|
|
idList = null;
|
210 |
|
|
<span class="reserved">return</span> o2Store;
|
211 |
|
|
};
|
212 |
|
|
<span class="comment"> // pick best available MSXML progIDs</span>
|
213 |
|
|
_SARISSA_DOM_PROGID = null;
|
214 |
|
|
_SARISSA_THREADEDDOM_PROGID = null;
|
215 |
|
|
_SARISSA_XSLTEMPLATE_PROGID = null;
|
216 |
|
|
_SARISSA_XMLHTTP_PROGID = null;
|
217 |
|
|
<span class="reserved">if</span>(!window.XMLHttpRequest){
|
218 |
|
|
<span class="comment">/**
|
219 |
|
|
* Emulate XMLHttpRequest
|
220 |
|
|
* <span class="attrib">@constructor</span>
|
221 |
|
|
*/</span>
|
222 |
|
|
XMLHttpRequest = <span class="reserved">function</span>() {
|
223 |
|
|
<span class="reserved">if</span>(!_SARISSA_XMLHTTP_PROGID){
|
224 |
|
|
_SARISSA_XMLHTTP_PROGID = Sarissa.pickRecentProgID([<span class="literal">"Msxml2.XMLHTTP.6.0"</span>, <span class="literal">"MSXML2.XMLHTTP.3.0"</span>, <span class="literal">"MSXML2.XMLHTTP"</span>, <span class="literal">"Microsoft.XMLHTTP"</span>]);
|
225 |
|
|
};
|
226 |
|
|
<span class="reserved">return</span> new ActiveXObject(_SARISSA_XMLHTTP_PROGID);
|
227 |
|
|
};
|
228 |
|
|
};
|
229 |
|
|
<span class="comment"> // we dont need this anymore</span>
|
230 |
|
|
<span class="comment"> //============================================</span>
|
231 |
|
|
<span class="comment"> // Factory methods (IE)</span>
|
232 |
|
|
<span class="comment"> //============================================</span>
|
233 |
|
|
<span class="comment"> // see non-IE version</span>
|
234 |
|
|
Sarissa.getDomDocument = <span class="reserved">function</span>(sUri, sName){
|
235 |
|
|
<span class="reserved">if</span>(!_SARISSA_DOM_PROGID){
|
236 |
|
|
_SARISSA_DOM_PROGID = Sarissa.pickRecentProgID([<span class="literal">"Msxml2.DOMDocument.6.0"</span>, <span class="literal">"Msxml2.DOMDocument.3.0"</span>, <span class="literal">"MSXML2.DOMDocument"</span>, <span class="literal">"MSXML.DOMDocument"</span>, <span class="literal">"Microsoft.XMLDOM"</span>]);
|
237 |
|
|
};
|
238 |
|
|
var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
|
239 |
|
|
<span class="comment"> // if a root tag name was provided, we need to load it in the DOM object</span>
|
240 |
|
|
<span class="reserved">if</span> (sName){
|
241 |
|
|
<span class="comment"> // create an artifical namespace prefix </span>
|
242 |
|
|
<span class="comment"> // or reuse existing prefix if applicable</span>
|
243 |
|
|
var prefix = <span class="literal">""</span>;
|
244 |
|
|
<span class="reserved">if</span>(sUri){
|
245 |
|
|
<span class="reserved">if</span>(sName.indexOf(<span class="literal">":"</span>) > 1){
|
246 |
|
|
prefix = sName.substring(0, sName.indexOf(<span class="literal">":"</span>));
|
247 |
|
|
sName = sName.substring(sName.indexOf(<span class="literal">":"</span>)+1);
|
248 |
|
|
}<span class="reserved">else</span>{
|
249 |
|
|
prefix = <span class="literal">"a"</span> + (_sarissa_iNsCounter++);
|
250 |
|
|
};
|
251 |
|
|
};
|
252 |
|
|
<span class="comment"> // use namespaces if a namespace URI exists</span>
|
253 |
|
|
<span class="reserved">if</span>(sUri){
|
254 |
|
|
oDoc.loadXML(<span class="literal">'<'</span> + prefix+<span class="literal">':'</span>+sName + <span class="literal">" xmlns:"</span> + prefix + <span class="literal">"=\"</span><span class="literal">" + sUri + "</span>\<span class="literal">""</span> + <span class="literal">" />"</span>);
|
255 |
|
|
} <span class="reserved">else</span> {
|
256 |
|
|
oDoc.loadXML(<span class="literal">'<'</span> + sName + <span class="literal">" />"</span>);
|
257 |
|
|
};
|
258 |
|
|
};
|
259 |
|
|
<span class="reserved">return</span> oDoc;
|
260 |
|
|
};
|
261 |
|
|
<span class="comment"> // see non-IE version </span>
|
262 |
|
|
Sarissa.getParseErrorText = <span class="reserved">function</span> (oDoc) {
|
263 |
|
|
var parseErrorText = Sarissa.PARSED_OK;
|
264 |
|
|
<span class="reserved">if</span>(oDoc.parseError.errorCode != 0){
|
265 |
|
|
parseErrorText = <span class="literal">"XML Parsing Error: "</span> + oDoc.parseError.reason +
|
266 |
|
|
<span class="literal">"\nLocation: "</span> + oDoc.parseError.url +
|
267 |
|
|
<span class="literal">"\nLine Number "</span> + oDoc.parseError.line + <span class="literal">", Column "</span> +
|
268 |
|
|
oDoc.parseError.linepos +
|
269 |
|
|
<span class="literal">":\n"</span> + oDoc.parseError.srcText +
|
270 |
|
|
<span class="literal">"\n"</span>;
|
271 |
|
|
<span class="reserved">for</span>(var i = 0; i < oDoc.parseError.linepos;i++){
|
272 |
|
|
parseErrorText += <span class="literal">"-"</span>;
|
273 |
|
|
};
|
274 |
|
|
parseErrorText += <span class="literal">"^\n"</span>;
|
275 |
|
|
}
|
276 |
|
|
<span class="reserved">else</span> <span class="reserved">if</span>(oDoc.documentElement == null){
|
277 |
|
|
parseErrorText = Sarissa.PARSED_EMPTY;
|
278 |
|
|
};
|
279 |
|
|
<span class="reserved">return</span> parseErrorText;
|
280 |
|
|
};
|
281 |
|
|
<span class="comment"> // see non-IE version</span>
|
282 |
|
|
Sarissa.setXpathNamespaces = <span class="reserved">function</span>(oDoc, sNsSet) {
|
283 |
|
|
oDoc.setProperty(<span class="literal">"SelectionLanguage"</span>, <span class="literal">"XPath"</span>);
|
284 |
|
|
oDoc.setProperty(<span class="literal">"SelectionNamespaces"</span>, sNsSet);
|
285 |
|
|
};
|
286 |
|
|
<span class="comment">/**
|
287 |
|
|
* Basic implementation of Mozilla's XSLTProcessor for IE.
|
288 |
|
|
* Reuses the same XSLT stylesheet for multiple transforms
|
289 |
|
|
* <span class="attrib">@constructor</span>
|
290 |
|
|
*/</span>
|
291 |
|
|
XSLTProcessor = <span class="reserved">function</span>(){
|
292 |
|
|
<span class="reserved">if</span>(!_SARISSA_XSLTEMPLATE_PROGID){
|
293 |
|
|
_SARISSA_XSLTEMPLATE_PROGID = Sarissa.pickRecentProgID([<span class="literal">"Msxml2.XSLTemplate.6.0"</span>, <span class="literal">"MSXML2.XSLTemplate.3.0"</span>]);
|
294 |
|
|
};
|
295 |
|
|
<span class="reserved">this</span>.template = new ActiveXObject(_SARISSA_XSLTEMPLATE_PROGID);
|
296 |
|
|
<span class="reserved">this</span>.processor = null;
|
297 |
|
|
};
|
298 |
|
|
<span class="comment">/**
|
299 |
|
|
* Imports the given XSLT DOM and compiles it to a reusable transform
|
300 |
|
|
* <b>Note:</b> If the stylesheet was loaded from a URL and contains xsl:import or xsl:include elements,it will be reloaded to resolve those
|
301 |
|
|
* <span class="attrib">@argument</span> xslDoc The XSLT DOMDocument to import
|
302 |
|
|
*/</span>
|
303 |
|
|
XSLTProcessor.<span class="reserved">prototype</span>.importStylesheet = <span class="reserved">function</span>(xslDoc){
|
304 |
|
|
<span class="reserved">if</span>(!_SARISSA_THREADEDDOM_PROGID){
|
305 |
|
|
_SARISSA_THREADEDDOM_PROGID = Sarissa.pickRecentProgID([<span class="literal">"MSXML2.FreeThreadedDOMDocument.6.0"</span>, <span class="literal">"MSXML2.FreeThreadedDOMDocument.3.0"</span>]);
|
306 |
|
|
};
|
307 |
|
|
xslDoc.setProperty(<span class="literal">"SelectionLanguage"</span>, <span class="literal">"XPath"</span>);
|
308 |
|
|
xslDoc.setProperty(<span class="literal">"SelectionNamespaces"</span>, <span class="literal">"xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"</span>);
|
309 |
|
|
<span class="comment"> // convert stylesheet to free threaded</span>
|
310 |
|
|
var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);
|
311 |
|
|
<span class="comment"> // make included/imported stylesheets work if exist and xsl was originally loaded from url</span>
|
312 |
|
|
<span class="reserved">if</span>(xslDoc.url && xslDoc.selectSingleNode(<span class="literal">"//xsl:*[local-name() = 'import' or local-name() = 'include']"</span>) != null){
|
313 |
|
|
converted.async = false;
|
314 |
|
|
<span class="reserved">if</span> (_SARISSA_THREADEDDOM_PROGID == <span class="literal">"MSXML2.FreeThreadedDOMDocument.6.0"</span>) {
|
315 |
|
|
converted.setProperty(<span class="literal">"AllowDocumentFunction"</span>, true);
|
316 |
|
|
converted.resolveExternals = true;
|
317 |
|
|
}
|
318 |
|
|
converted.load(xslDoc.url);
|
319 |
|
|
} <span class="reserved">else</span> {
|
320 |
|
|
converted.loadXML(xslDoc.xml);
|
321 |
|
|
};
|
322 |
|
|
converted.setProperty(<span class="literal">"SelectionNamespaces"</span>, <span class="literal">"xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"</span>);
|
323 |
|
|
var output = converted.selectSingleNode(<span class="literal">"//xsl:output"</span>);
|
324 |
|
|
<span class="reserved">this</span>.outputMethod = output ? output.getAttribute(<span class="literal">"method"</span>) : <span class="literal">"html"</span>;
|
325 |
|
|
<span class="reserved">this</span>.template.stylesheet = converted;
|
326 |
|
|
<span class="reserved">this</span>.processor = <span class="reserved">this</span>.template.createProcessor();
|
327 |
|
|
<span class="comment"> // for getParameter and clearParameters</span>
|
328 |
|
|
<span class="reserved">this</span>.paramsSet = new Array();
|
329 |
|
|
};
|
330 |
|
|
|
331 |
|
|
<span class="comment">/**
|
332 |
|
|
* Transform the given XML DOM and return the transformation result as a new DOM document
|
333 |
|
|
* <span class="attrib">@argument</span> sourceDoc The XML DOMDocument to transform
|
334 |
|
|
* <span class="attrib">@return</span> The transformation result as a DOM Document
|
335 |
|
|
*/</span>
|
336 |
|
|
XSLTProcessor.<span class="reserved">prototype</span>.transformToDocument = <span class="reserved">function</span>(sourceDoc){
|
337 |
|
|
<span class="comment"> // fix for bug 1549749</span>
|
338 |
|
|
<span class="reserved">if</span>(_SARISSA_THREADEDDOM_PROGID){
|
339 |
|
|
<span class="reserved">this</span>.processor.input=sourceDoc;
|
340 |
|
|
var outDoc=new ActiveXObject(_SARISSA_DOM_PROGID);
|
341 |
|
|
<span class="reserved">this</span>.processor.output=outDoc;
|
342 |
|
|
<span class="reserved">this</span>.processor.transform();
|
343 |
|
|
<span class="reserved">return</span> outDoc;
|
344 |
|
|
}
|
345 |
|
|
<span class="reserved">else</span>{
|
346 |
|
|
<span class="reserved">if</span>(!_SARISSA_DOM_XMLWRITER){
|
347 |
|
|
_SARISSA_DOM_XMLWRITER = Sarissa.pickRecentProgID([<span class="literal">"Msxml2.MXXMLWriter.6.0"</span>, <span class="literal">"Msxml2.MXXMLWriter.3.0"</span>, <span class="literal">"MSXML2.MXXMLWriter"</span>, <span class="literal">"MSXML.MXXMLWriter"</span>, <span class="literal">"Microsoft.XMLDOM"</span>]);
|
348 |
|
|
};
|
349 |
|
|
<span class="reserved">this</span>.processor.input = sourceDoc;
|
350 |
|
|
var outDoc = new ActiveXObject(_SARISSA_DOM_XMLWRITER);
|
351 |
|
|
<span class="reserved">this</span>.processor.output = outDoc;
|
352 |
|
|
<span class="reserved">this</span>.processor.transform();
|
353 |
|
|
var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
|
354 |
|
|
oDoc.loadXML(outDoc.output+<span class="literal">""</span>);
|
355 |
|
|
<span class="reserved">return</span> oDoc;
|
356 |
|
|
};
|
357 |
|
|
};
|
358 |
|
|
|
359 |
|
|
<span class="comment">/**
|
360 |
|
|
* Transform the given XML DOM and return the transformation result as a new DOM fragment.
|
361 |
|
|
* <b>Note</b>: The xsl:output method must match the nature of the owner document (XML/HTML).
|
362 |
|
|
* <span class="attrib">@argument</span> sourceDoc The XML DOMDocument to transform
|
363 |
|
|
* <span class="attrib">@argument</span> ownerDoc The owner of the result fragment
|
364 |
|
|
* <span class="attrib">@return</span> The transformation result as a DOM Document
|
365 |
|
|
*/</span>
|
366 |
|
|
XSLTProcessor.<span class="reserved">prototype</span>.transformToFragment = <span class="reserved">function</span> (sourceDoc, ownerDoc) {
|
367 |
|
|
<span class="reserved">this</span>.processor.input = sourceDoc;
|
368 |
|
|
<span class="reserved">this</span>.processor.transform();
|
369 |
|
|
var s = <span class="reserved">this</span>.processor.output;
|
370 |
|
|
var f = ownerDoc.createDocumentFragment();
|
371 |
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.outputMethod == <span class="literal">'text'</span>) {
|
372 |
|
|
f.appendChild(ownerDoc.createTextNode(s));
|
373 |
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (ownerDoc.body && ownerDoc.body.innerHTML) {
|
374 |
|
|
var container = ownerDoc.createElement(<span class="literal">'div'</span>);
|
375 |
|
|
container.innerHTML = s;
|
376 |
|
|
<span class="reserved">while</span> (container.hasChildNodes()) {
|
377 |
|
|
f.appendChild(container.firstChild);
|
378 |
|
|
}
|
379 |
|
|
}
|
380 |
|
|
<span class="reserved">else</span> {
|
381 |
|
|
var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
|
382 |
|
|
<span class="reserved">if</span> (s.substring(0, 5) == <span class="literal">'<?xml'</span>) {
|
383 |
|
|
s = s.substring(s.indexOf(<span class="literal">'?>'</span>) + 2);
|
384 |
|
|
}
|
385 |
|
|
var xml = <span class="literal">''</span>.concat(<span class="literal">'<my>'</span>, s, <span class="literal">'</my>'</span>);
|
386 |
|
|
oDoc.loadXML(xml);
|
387 |
|
|
var container = oDoc.documentElement;
|
388 |
|
|
<span class="reserved">while</span> (container.hasChildNodes()) {
|
389 |
|
|
f.appendChild(container.firstChild);
|
390 |
|
|
}
|
391 |
|
|
}
|
392 |
|
|
<span class="reserved">return</span> f;
|
393 |
|
|
};
|
394 |
|
|
|
395 |
|
|
<span class="comment">/**
|
396 |
|
|
* Set global XSLT parameter of the imported stylesheet
|
397 |
|
|
* <span class="attrib">@argument</span> nsURI The parameter namespace URI
|
398 |
|
|
* <span class="attrib">@argument</span> name The parameter base name
|
399 |
|
|
* <span class="attrib">@argument</span> value The new parameter value
|
400 |
|
|
*/</span>
|
401 |
|
|
XSLTProcessor.<span class="reserved">prototype</span>.setParameter = <span class="reserved">function</span>(nsURI, name, value){
|
402 |
|
|
<span class="comment"> // nsURI is optional but cannot be null </span>
|
403 |
|
|
<span class="reserved">if</span>(nsURI){
|
404 |
|
|
<span class="reserved">this</span>.processor.addParameter(name, value, nsURI);
|
405 |
|
|
}<span class="reserved">else</span>{
|
406 |
|
|
<span class="reserved">this</span>.processor.addParameter(name, value);
|
407 |
|
|
};
|
408 |
|
|
<span class="comment"> // update updated params for getParameter </span>
|
409 |
|
|
<span class="reserved">if</span>(!<span class="reserved">this</span>.paramsSet[<span class="literal">""</span>+nsURI]){
|
410 |
|
|
<span class="reserved">this</span>.paramsSet[<span class="literal">""</span>+nsURI] = new Array();
|
411 |
|
|
};
|
412 |
|
|
<span class="reserved">this</span>.paramsSet[<span class="literal">""</span>+nsURI][name] = value;
|
413 |
|
|
};
|
414 |
|
|
<span class="comment">/**
|
415 |
|
|
* Gets a parameter if previously set by setParameter. Returns null
|
416 |
|
|
* otherwise
|
417 |
|
|
* <span class="attrib">@argument</span> name The parameter base name
|
418 |
|
|
* <span class="attrib">@argument</span> value The new parameter value
|
419 |
|
|
* <span class="attrib">@return</span> The parameter value if reviously set by setParameter, null otherwise
|
420 |
|
|
*/</span>
|
421 |
|
|
XSLTProcessor.<span class="reserved">prototype</span>.getParameter = <span class="reserved">function</span>(nsURI, name){
|
422 |
|
|
nsURI = nsURI || <span class="literal">""</span>;
|
423 |
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.paramsSet[nsURI] && <span class="reserved">this</span>.paramsSet[nsURI][name]){
|
424 |
|
|
<span class="reserved">return</span> <span class="reserved">this</span>.paramsSet[nsURI][name];
|
425 |
|
|
}<span class="reserved">else</span>{
|
426 |
|
|
<span class="reserved">return</span> null;
|
427 |
|
|
};
|
428 |
|
|
};
|
429 |
|
|
<span class="comment">/**
|
430 |
|
|
* Clear parameters (set them to default values as defined in the stylesheet itself)
|
431 |
|
|
*/</span>
|
432 |
|
|
XSLTProcessor.<span class="reserved">prototype</span>.clearParameters = <span class="reserved">function</span>(){
|
433 |
|
|
<span class="reserved">for</span>(var nsURI in <span class="reserved">this</span>.paramsSet){
|
434 |
|
|
<span class="reserved">for</span>(var name in <span class="reserved">this</span>.paramsSet[nsURI]){
|
435 |
|
|
<span class="reserved">if</span>(nsURI){
|
436 |
|
|
<span class="reserved">this</span>.processor.addParameter(name, null, nsURI);
|
437 |
|
|
}<span class="reserved">else</span>{
|
438 |
|
|
<span class="reserved">this</span>.processor.addParameter(name, null);
|
439 |
|
|
};
|
440 |
|
|
};
|
441 |
|
|
};
|
442 |
|
|
<span class="reserved">this</span>.paramsSet = new Array();
|
443 |
|
|
};
|
444 |
|
|
}<span class="reserved">else</span>{ <span class="comment">/* end IE initialization, try to deal with real browsers now ;-) */</span>
|
445 |
|
|
<span class="reserved">if</span>(_SARISSA_HAS_DOM_CREATE_DOCUMENT){
|
446 |
|
|
<span class="comment">/**
|
447 |
|
|
* <p>Ensures the document was loaded correctly, otherwise sets the
|
448 |
|
|
* parseError to -1 to indicate something went wrong. Internal use</p>
|
449 |
|
|
* <span class="attrib">@private</span>
|
450 |
|
|
*/</span>
|
451 |
|
|
Sarissa.__handleLoad__ = <span class="reserved">function</span>(oDoc){
|
452 |
|
|
Sarissa.__setReadyState__(oDoc, 4);
|
453 |
|
|
};
|
454 |
|
|
<span class="comment">/**
|
455 |
|
|
* <p>Attached by an event handler to the load event. Internal use.</p>
|
456 |
|
|
* <span class="attrib">@private</span>
|
457 |
|
|
*/</span>
|
458 |
|
|
_sarissa_XMLDocument_onload = <span class="reserved">function</span>(){
|
459 |
|
|
Sarissa.__handleLoad__(<span class="reserved">this</span>);
|
460 |
|
|
};
|
461 |
|
|
<span class="comment">/**
|
462 |
|
|
* <p>Sets the readyState property of the given DOM Document object.
|
463 |
|
|
* Internal use.</p>
|
464 |
|
|
* <span class="attrib">@private</span>
|
465 |
|
|
* <span class="attrib">@argument</span> oDoc the DOM Document object to fire the
|
466 |
|
|
* readystatechange event
|
467 |
|
|
* <span class="attrib">@argument</span> iReadyState the number to change the readystate property to
|
468 |
|
|
*/</span>
|
469 |
|
|
Sarissa.__setReadyState__ = <span class="reserved">function</span>(oDoc, iReadyState){
|
470 |
|
|
oDoc.readyState = iReadyState;
|
471 |
|
|
oDoc.readystate = iReadyState;
|
472 |
|
|
<span class="reserved">if</span> (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == <span class="literal">"function"</span>)
|
473 |
|
|
oDoc.onreadystatechange();
|
474 |
|
|
};
|
475 |
|
|
Sarissa.getDomDocument = <span class="reserved">function</span>(sUri, sName){
|
476 |
|
|
var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
|
477 |
|
|
<span class="reserved">if</span>(!oDoc.onreadystatechange){
|
478 |
|
|
|
479 |
|
|
<span class="comment">/**
|
480 |
|
|
* <p>Emulate IE's onreadystatechange attribute</p>
|
481 |
|
|
*/</span>
|
482 |
|
|
oDoc.onreadystatechange = null;
|
483 |
|
|
};
|
484 |
|
|
<span class="reserved">if</span>(!oDoc.readyState){
|
485 |
|
|
<span class="comment">/**
|
486 |
|
|
* <p>Emulates IE's readyState property, which always gives an integer from 0 to 4:</p>
|
487 |
|
|
* <ul><li>1 == LOADING,</li>
|
488 |
|
|
* <li>2 == LOADED,</li>
|
489 |
|
|
* <li>3 == INTERACTIVE,</li>
|
490 |
|
|
* <li>4 == COMPLETED</li></ul>
|
491 |
|
|
*/</span>
|
492 |
|
|
oDoc.readyState = 0;
|
493 |
|
|
};
|
494 |
|
|
oDoc.addEventListener(<span class="literal">"load"</span>, _sarissa_XMLDocument_onload, false);
|
495 |
|
|
<span class="reserved">return</span> oDoc;
|
496 |
|
|
};
|
497 |
|
|
<span class="reserved">if</span>(window.XMLDocument){
|
498 |
|
|
<span class="comment"> // do nothing</span>
|
499 |
|
|
}// TODO: check <span class="reserved">if</span> the new document has content before trying to copynodes, check <span class="reserved">for</span> error handling in DOM 3 LS
|
500 |
|
|
<span class="reserved">else</span> <span class="reserved">if</span>(_SARISSA_HAS_DOM_FEATURE && window.Document && !Document.<span class="reserved">prototype</span>.load && document.implementation.hasFeature(<span class="literal">'LS'</span>, <span class="literal">'3.0'</span>)){
|
501 |
|
|
<span class="comment"> //Opera 9 may get the XPath branch which gives creates XMLDocument, therefore it doesn't reach here which is good</span>
|
502 |
|
|
<span class="comment">/**
|
503 |
|
|
* <p>Factory method to obtain a new DOM Document object</p>
|
504 |
|
|
* <span class="attrib">@argument</span> sUri the namespace of the root node (if any)
|
505 |
|
|
* <span class="attrib">@argument</span> sUri the local name of the root node (if any)
|
506 |
|
|
* <span class="attrib">@returns</span> a new DOM Document
|
507 |
|
|
*/</span>
|
508 |
|
|
Sarissa.getDomDocument = <span class="reserved">function</span>(sUri, sName){
|
509 |
|
|
var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
|
510 |
|
|
<span class="reserved">return</span> oDoc;
|
511 |
|
|
};
|
512 |
|
|
}
|
513 |
|
|
<span class="reserved">else</span> {
|
514 |
|
|
Sarissa.getDomDocument = <span class="reserved">function</span>(sUri, sName){
|
515 |
|
|
var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
|
516 |
|
|
<span class="comment"> // looks like safari does not create the root element for some unknown reason</span>
|
517 |
|
|
<span class="reserved">if</span>(oDoc && (sUri || sName) && !oDoc.documentElement){
|
518 |
|
|
oDoc.appendChild(oDoc.createElementNS(sUri, sName));
|
519 |
|
|
};
|
520 |
|
|
<span class="reserved">return</span> oDoc;
|
521 |
|
|
};
|
522 |
|
|
};
|
523 |
|
|
};//<span class="reserved">if</span>(_SARISSA_HAS_DOM_CREATE_DOCUMENT)
|
524 |
|
|
};
|
525 |
|
|
<span class="comment">//==========================================</span>
|
526 |
|
|
<span class="comment">// Common stuff</span>
|
527 |
|
|
<span class="comment">//==========================================</span>
|
528 |
|
|
<span class="reserved">if</span>(!window.DOMParser){
|
529 |
|
|
<span class="reserved">if</span>(_SARISSA_IS_SAFARI){
|
530 |
|
|
<span class="comment">/*
|
531 |
|
|
* DOMParser is a utility class, used to construct DOMDocuments from XML strings
|
532 |
|
|
* <span class="attrib">@constructor</span>
|
533 |
|
|
*/</span>
|
534 |
|
|
DOMParser = <span class="reserved">function</span>() { };
|
535 |
|
|
<span class="comment">/**
|
536 |
|
|
* Construct a new DOM Document from the given XMLstring
|
537 |
|
|
* <span class="attrib">@param</span> sXml the given XML string
|
538 |
|
|
* <span class="attrib">@param</span> contentType the content type of the document the given string represents (one of text/xml, application/xml, application/xhtml+xml).
|
539 |
|
|
* <span class="attrib">@return</span> a new DOM Document from the given XML string
|
540 |
|
|
*/</span>
|
541 |
|
|
DOMParser.<span class="reserved">prototype</span>.parseFromString = <span class="reserved">function</span>(sXml, contentType){
|
542 |
|
|
var xmlhttp = new XMLHttpRequest();
|
543 |
|
|
xmlhttp.open(<span class="literal">"GET"</span>, <span class="literal">"data:text/xml;charset=utf-8,"</span> + encodeURIComponent(sXml), false);
|
544 |
|
|
xmlhttp.send(null);
|
545 |
|
|
<span class="reserved">return</span> xmlhttp.responseXML;
|
546 |
|
|
};
|
547 |
|
|
}<span class="reserved">else</span> <span class="reserved">if</span>(Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, <span class="literal">"bar"</span>).xml){
|
548 |
|
|
DOMParser = <span class="reserved">function</span>() { };
|
549 |
|
|
DOMParser.<span class="reserved">prototype</span>.parseFromString = <span class="reserved">function</span>(sXml, contentType){
|
550 |
|
|
var doc = Sarissa.getDomDocument();
|
551 |
|
|
doc.loadXML(sXml);
|
552 |
|
|
<span class="reserved">return</span> doc;
|
553 |
|
|
};
|
554 |
|
|
};
|
555 |
|
|
};
|
556 |
|
|
|
557 |
|
|
<span class="reserved">if</span>((typeof(document.importNode) == <span class="literal">"undefined"</span>) && _SARISSA_IS_IE){
|
558 |
|
|
try{
|
559 |
|
|
<span class="comment">/**
|
560 |
|
|
* Implementation of importNode for the context window document in IE
|
561 |
|
|
* <span class="attrib">@param</span> oNode the Node to import
|
562 |
|
|
* <span class="attrib">@param</span> bChildren whether to include the children of oNode
|
563 |
|
|
* <span class="attrib">@returns</span> the imported node for further use
|
564 |
|
|
*/</span>
|
565 |
|
|
document.importNode = <span class="reserved">function</span>(oNode, bChildren){
|
566 |
|
|
var tmp;
|
567 |
|
|
<span class="reserved">if</span>(oNode.nodeName == <span class="literal">"tbody"</span> || oNode.nodeName == <span class="literal">"tr"</span>){
|
568 |
|
|
tmp = document.createElement(<span class="literal">"table"</span>);
|
569 |
|
|
}
|
570 |
|
|
<span class="reserved">else</span> <span class="reserved">if</span>(oNode.nodeName == <span class="literal">"td"</span>){
|
571 |
|
|
tmp = document.createElement(<span class="literal">"tr"</span>);
|
572 |
|
|
}
|
573 |
|
|
<span class="reserved">else</span> <span class="reserved">if</span>(oNode.nodeName == <span class="literal">"option"</span>){
|
574 |
|
|
tmp = document.createElement(<span class="literal">"select"</span>);
|
575 |
|
|
}
|
576 |
|
|
<span class="reserved">else</span>{
|
577 |
|
|
tmp = document.createElement(<span class="literal">"div"</span>);
|
578 |
|
|
};
|
579 |
|
|
<span class="reserved">if</span>(bChildren){
|
580 |
|
|
tmp.innerHTML = oNode.xml ? oNode.xml : oNode.outerHTML;
|
581 |
|
|
}<span class="reserved">else</span>{
|
582 |
|
|
tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).outerHTML;
|
583 |
|
|
};
|
584 |
|
|
<span class="reserved">return</span> tmp.getElementsByTagName(<span class="literal">"*"</span>)[0];
|
585 |
|
|
};
|
586 |
|
|
}catch(e){ };
|
587 |
|
|
};
|
588 |
|
|
<span class="reserved">if</span>(!Sarissa.getParseErrorText){
|
589 |
|
|
<span class="comment">/**
|
590 |
|
|
* <p>Returns a human readable description of the parsing error. Usefull
|
591 |
|
|
* for debugging. Tip: append the returned error string in a &lt;pre&gt;
|
592 |
|
|
* element if you want to render it.</p>
|
593 |
|
|
* <p>Many thanks to Christian Stocker for the initial patch.</p>
|
594 |
|
|
* <span class="attrib">@argument</span> oDoc The target DOM document
|
595 |
|
|
* <span class="attrib">@returns</span> The parsing error description of the target Document in
|
596 |
|
|
* human readable form (preformated text)
|
597 |
|
|
*/</span>
|
598 |
|
|
Sarissa.getParseErrorText = <span class="reserved">function</span> (oDoc){
|
599 |
|
|
var parseErrorText = Sarissa.PARSED_OK;
|
600 |
|
|
<span class="reserved">if</span>(!oDoc.documentElement){
|
601 |
|
|
parseErrorText = Sarissa.PARSED_EMPTY;
|
602 |
|
|
} <span class="reserved">else</span> <span class="reserved">if</span>(oDoc.documentElement.tagName == <span class="literal">"parsererror"</span>){
|
603 |
|
|
parseErrorText = oDoc.documentElement.firstChild.data;
|
604 |
|
|
parseErrorText += <span class="literal">"\n"</span> + oDoc.documentElement.firstChild.nextSibling.firstChild.data;
|
605 |
|
|
} <span class="reserved">else</span> <span class="reserved">if</span>(oDoc.getElementsByTagName(<span class="literal">"parsererror"</span>).length > 0){
|
606 |
|
|
var parsererror = oDoc.getElementsByTagName(<span class="literal">"parsererror"</span>)[0];
|
607 |
|
|
parseErrorText = Sarissa.getText(parsererror, true)+<span class="literal">"\n"</span>;
|
608 |
|
|
} <span class="reserved">else</span> <span class="reserved">if</span>(oDoc.parseError && oDoc.parseError.errorCode != 0){
|
609 |
|
|
parseErrorText = Sarissa.PARSED_UNKNOWN_ERROR;
|
610 |
|
|
};
|
611 |
|
|
<span class="reserved">return</span> parseErrorText;
|
612 |
|
|
};
|
613 |
|
|
};
|
614 |
|
|
Sarissa.getText = <span class="reserved">function</span>(oNode, deep){
|
615 |
|
|
var s = <span class="literal">""</span>;
|
616 |
|
|
var nodes = oNode.childNodes;
|
617 |
|
|
<span class="reserved">for</span>(var i=0; i < nodes.length; i++){
|
618 |
|
|
var node = nodes[i];
|
619 |
|
|
var nodeType = node.nodeType;
|
620 |
|
|
<span class="reserved">if</span>(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){
|
621 |
|
|
s += node.data;
|
622 |
|
|
} <span class="reserved">else</span> <span class="reserved">if</span>(deep == true
|
623 |
|
|
&& (nodeType == Node.ELEMENT_NODE
|
624 |
|
|
|| nodeType == Node.DOCUMENT_NODE
|
625 |
|
|
|| nodeType == Node.DOCUMENT_FRAGMENT_NODE)){
|
626 |
|
|
s += Sarissa.getText(node, true);
|
627 |
|
|
};
|
628 |
|
|
};
|
629 |
|
|
<span class="reserved">return</span> s;
|
630 |
|
|
};
|
631 |
|
|
<span class="reserved">if</span>(!window.XMLSerializer
|
632 |
|
|
&& Sarissa.getDomDocument
|
633 |
|
|
&& Sarissa.getDomDocument(<span class="literal">""</span>,<span class="literal">"foo"</span>, null).xml){
|
634 |
|
|
<span class="comment">/**
|
635 |
|
|
* Utility class to serialize DOM Node objects to XML strings
|
636 |
|
|
* <span class="attrib">@constructor</span>
|
637 |
|
|
*/</span>
|
638 |
|
|
XMLSerializer = <span class="reserved">function</span>(){};
|
639 |
|
|
<span class="comment">/**
|
640 |
|
|
* Serialize the given DOM Node to an XML string
|
641 |
|
|
* <span class="attrib">@param</span> oNode the DOM Node to serialize
|
642 |
|
|
*/</span>
|
643 |
|
|
XMLSerializer.<span class="reserved">prototype</span>.serializeToString = <span class="reserved">function</span>(oNode) {
|
644 |
|
|
<span class="reserved">return</span> oNode.xml;
|
645 |
|
|
};
|
646 |
|
|
};
|
647 |
|
|
|
648 |
|
|
<span class="comment">/**
|
649 |
|
|
* strips tags from a markup string
|
650 |
|
|
*/</span>
|
651 |
|
|
Sarissa.stripTags = <span class="reserved">function</span> (s) {
|
652 |
|
|
<span class="reserved">return</span> s.replace(/<[^>]+>/g,<span class="literal">""</span>);
|
653 |
|
|
};
|
654 |
|
|
<span class="comment">/**
|
655 |
|
|
* <p>Deletes all child nodes of the given node</p>
|
656 |
|
|
* <span class="attrib">@argument</span> oNode the Node to empty
|
657 |
|
|
*/</span>
|
658 |
|
|
Sarissa.clearChildNodes = <span class="reserved">function</span>(oNode) {
|
659 |
|
|
<span class="comment"> // need to check for firstChild due to opera 8 bug with hasChildNodes</span>
|
660 |
|
|
<span class="reserved">while</span>(oNode.firstChild) {
|
661 |
|
|
oNode.removeChild(oNode.firstChild);
|
662 |
|
|
};
|
663 |
|
|
};
|
664 |
|
|
<span class="comment">/**
|
665 |
|
|
* <p> Copies the childNodes of nodeFrom to nodeTo</p>
|
666 |
|
|
* <p> <b>Note:</b> The second object's original content is deleted before
|
667 |
|
|
* the copy operation, unless you supply a true third parameter</p>
|
668 |
|
|
* <span class="attrib">@argument</span> nodeFrom the Node to copy the childNodes from
|
669 |
|
|
* <span class="attrib">@argument</span> nodeTo the Node to copy the childNodes to
|
670 |
|
|
* <span class="attrib">@argument</span> bPreserveExisting whether to preserve the original content of nodeTo, default is false
|
671 |
|
|
*/</span>
|
672 |
|
|
Sarissa.copyChildNodes = <span class="reserved">function</span>(nodeFrom, nodeTo, bPreserveExisting) {
|
673 |
|
|
<span class="reserved">if</span>((!nodeFrom) || (!nodeTo)){
|
674 |
|
|
throw <span class="literal">"Both source and destination nodes must be provided"</span>;
|
675 |
|
|
};
|
676 |
|
|
<span class="reserved">if</span>(!bPreserveExisting){
|
677 |
|
|
Sarissa.clearChildNodes(nodeTo);
|
678 |
|
|
};
|
679 |
|
|
var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
|
680 |
|
|
var nodes = nodeFrom.childNodes;
|
681 |
|
|
<span class="reserved">if</span>(typeof(ownerDoc.importNode) != <span class="literal">"undefined"</span>) {
|
682 |
|
|
<span class="reserved">for</span>(var i=0;i < nodes.length;i++) {
|
683 |
|
|
nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
|
684 |
|
|
};
|
685 |
|
|
} <span class="reserved">else</span> {
|
686 |
|
|
<span class="reserved">for</span>(var i=0;i < nodes.length;i++) {
|
687 |
|
|
nodeTo.appendChild(nodes[i].cloneNode(true));
|
688 |
|
|
};
|
689 |
|
|
};
|
690 |
|
|
};
|
691 |
|
|
|
692 |
|
|
<span class="comment">/**
|
693 |
|
|
* <p> Moves the childNodes of nodeFrom to nodeTo</p>
|
694 |
|
|
* <p> <b>Note:</b> The second object's original content is deleted before
|
695 |
|
|
* the move operation, unless you supply a true third parameter</p>
|
696 |
|
|
* <span class="attrib">@argument</span> nodeFrom the Node to copy the childNodes from
|
697 |
|
|
* <span class="attrib">@argument</span> nodeTo the Node to copy the childNodes to
|
698 |
|
|
* <span class="attrib">@argument</span> bPreserveExisting whether to preserve the original content of nodeTo, default is
|
699 |
|
|
*/</span>
|
700 |
|
|
Sarissa.moveChildNodes = <span class="reserved">function</span>(nodeFrom, nodeTo, bPreserveExisting) {
|
701 |
|
|
<span class="reserved">if</span>((!nodeFrom) || (!nodeTo)){
|
702 |
|
|
throw <span class="literal">"Both source and destination nodes must be provided"</span>;
|
703 |
|
|
};
|
704 |
|
|
<span class="reserved">if</span>(!bPreserveExisting){
|
705 |
|
|
Sarissa.clearChildNodes(nodeTo);
|
706 |
|
|
};
|
707 |
|
|
var nodes = nodeFrom.childNodes;
|
708 |
|
|
<span class="comment"> // if within the same doc, just move, else copy and delete</span>
|
709 |
|
|
<span class="reserved">if</span>(nodeFrom.ownerDocument == nodeTo.ownerDocument){
|
710 |
|
|
<span class="reserved">while</span>(nodeFrom.firstChild){
|
711 |
|
|
nodeTo.appendChild(nodeFrom.firstChild);
|
712 |
|
|
};
|
713 |
|
|
} <span class="reserved">else</span> {
|
714 |
|
|
var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
|
715 |
|
|
<span class="reserved">if</span>(typeof(ownerDoc.importNode) != <span class="literal">"undefined"</span>) {
|
716 |
|
|
<span class="reserved">for</span>(var i=0;i < nodes.length;i++) {
|
717 |
|
|
nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
|
718 |
|
|
};
|
719 |
|
|
}<span class="reserved">else</span>{
|
720 |
|
|
<span class="reserved">for</span>(var i=0;i < nodes.length;i++) {
|
721 |
|
|
nodeTo.appendChild(nodes[i].cloneNode(true));
|
722 |
|
|
};
|
723 |
|
|
};
|
724 |
|
|
Sarissa.clearChildNodes(nodeFrom);
|
725 |
|
|
};
|
726 |
|
|
};
|
727 |
|
|
|
728 |
|
|
<span class="comment">/**
|
729 |
|
|
* <p>Serialize any object to an XML string. All properties are serialized using the property name
|
730 |
|
|
* as the XML element name. Array elements are rendered as <code>array-item</code> elements,
|
731 |
|
|
* using their index/key as the value of the <code>key</code> attribute.</p>
|
732 |
|
|
* <span class="attrib">@argument</span> anyObject the object to serialize
|
733 |
|
|
* <span class="attrib">@argument</span> objectName a name for that object
|
734 |
|
|
* <span class="attrib">@return</span> the XML serializationj of the given object as a string
|
735 |
|
|
*/</span>
|
736 |
|
|
Sarissa.xmlize = <span class="reserved">function</span>(anyObject, objectName, indentSpace){
|
737 |
|
|
indentSpace = indentSpace?indentSpace:<span class="literal">''</span>;
|
738 |
|
|
var s = indentSpace + <span class="literal">'<'</span> + objectName + <span class="literal">'>'</span>;
|
739 |
|
|
var isLeaf = false;
|
740 |
|
|
<span class="reserved">if</span>(!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String
|
741 |
|
|
|| anyObject instanceof Boolean || anyObject instanceof Date){
|
742 |
|
|
s += Sarissa.escape(<span class="literal">""</span>+anyObject);
|
743 |
|
|
isLeaf = true;
|
744 |
|
|
}<span class="reserved">else</span>{
|
745 |
|
|
s += <span class="literal">"\n"</span>;
|
746 |
|
|
var itemKey = <span class="literal">''</span>;
|
747 |
|
|
var isArrayItem = anyObject instanceof Array;
|
748 |
|
|
<span class="reserved">for</span>(var name in anyObject){
|
749 |
|
|
s += Sarissa.xmlize(anyObject[name], (isArrayItem?<span class="literal">"array-item key=\"</span><span class="literal">"+name+"</span>\<span class="literal">""</span>:name), indentSpace + <span class="literal">" "</span>);
|
750 |
|
|
};
|
751 |
|
|
s += indentSpace;
|
752 |
|
|
};
|
753 |
|
|
<span class="reserved">return</span> s += (objectName.indexOf(<span class="literal">' '</span>)!=-1?<span class="literal">"</array-item>\n"</span>:<span class="literal">"</"</span> + objectName + <span class="literal">">\n"</span>);
|
754 |
|
|
};
|
755 |
|
|
|
756 |
|
|
<span class="comment">/**
|
757 |
|
|
* Escape the given string chacters that correspond to the five predefined XML entities
|
758 |
|
|
* <span class="attrib">@param</span> sXml the string to escape
|
759 |
|
|
*/</span>
|
760 |
|
|
Sarissa.escape = <span class="reserved">function</span>(sXml){
|
761 |
|
|
<span class="reserved">return</span> sXml.replace(/&/g, <span class="literal">"&amp;"</span>)
|
762 |
|
|
.replace(/</g, <span class="literal">"&lt;"</span>)
|
763 |
|
|
.replace(/>/g, <span class="literal">"&gt;"</span>)
|
764 |
|
|
.replace(/<span class="literal">"/g, "</span>&quot;<span class="literal">")
|
765 |
|
|
.replace(/'/g, "</span>&apos;<span class="literal">");
|
766 |
|
|
};
|
767 |
|
|
|
768 |
|
|
/**
|
769 |
|
|
* Unescape the given string. This turns the occurences of the predefined XML
|
770 |
|
|
* entities to become the characters they represent correspond to the five predefined XML entities
|
771 |
|
|
* @param sXml the string to unescape
|
772 |
|
|
*/
|
773 |
|
|
Sarissa.unescape = function(sXml){
|
774 |
|
|
return sXml.replace(/&apos;/g,"</span>'<span class="literal">")
|
775 |
|
|
.replace(/&quot;/g,"</span>\<span class="literal">""</span>)
|
776 |
|
|
.replace(/&gt;/g,<span class="literal">">"</span>)
|
777 |
|
|
.replace(/&lt;/g,<span class="literal">"<"</span>)
|
778 |
|
|
.replace(/&amp;/g,<span class="literal">"&"</span>);
|
779 |
|
|
};
|
780 |
|
|
<span class="comment">// EOF</span>
|
781 |
|
|
</pre>
|
782 |
|
|
<hr>
|
783 |
|
|
|
784 |
|
|
|
785 |
|
|
|
786 |
|
|
<!-- ========== START OF NAVBAR ========== -->
|
787 |
|
|
<a name="navbar_top"><!-- --></a>
|
788 |
|
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
789 |
|
|
<tr>
|
790 |
|
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
791 |
|
|
<a name="navbar_top_firstrow"><!-- --></a>
|
792 |
|
|
<table border="0" cellpadding="0" cellspacing="3">
|
793 |
|
|
<tr align="center" valign="top">
|
794 |
|
|
|
795 |
|
|
|
796 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
797 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
798 |
|
|
|
799 |
|
|
|
800 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
801 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
802 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
803 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
804 |
|
|
</tr>
|
805 |
|
|
</table>
|
806 |
|
|
</td>
|
807 |
|
|
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
|
808 |
|
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
809 |
|
|
</td>
|
810 |
|
|
</tr>
|
811 |
|
|
|
812 |
|
|
<tr>
|
813 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
814 |
|
|
PREV
|
815 |
|
|
NEXT</font></td>
|
816 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
817 |
|
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
818 |
|
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
819 |
|
|
|
820 |
|
|
<script>
|
821 |
|
|
<!--
|
822 |
|
|
if(window==top) {
|
823 |
|
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
824 |
|
|
}
|
825 |
|
|
//-->
|
826 |
|
|
</script>
|
827 |
|
|
<noscript>
|
828 |
|
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
829 |
|
|
</noscript>
|
830 |
|
|
</font></td>
|
831 |
|
|
</tr>
|
832 |
|
|
</table>
|
833 |
|
|
<!-- =========== END OF NAVBAR =========== -->
|
834 |
|
|
|
835 |
|
|
<hr>
|
836 |
|
|
<font size="-1">
|
837 |
|
|
|
838 |
|
|
</font>
|
839 |
|
|
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Sun Apr 27 20:30:54 2008</div>
|
840 |
|
|
</body>
|
841 |
|
|
</html>
|