KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > xml > client > impl > XMLParserImplSafari


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.xml.client.impl;
17
18 import com.google.gwt.core.client.JavaScriptObject;
19
20 /**
21  * This class is Safari implementation of the XMLParser interface.
22  */

23 class XMLParserImplSafari extends XMLParserImplStandard {
24
25   protected native JavaScriptObject getElementsByTagNameImpl(JavaScriptObject o,
26       String JavaDoc tagName) /*-{
27     return o.getElementsByTagName(tagName);
28   }-*/
;
29   
30   /**
31    * <html><body><parsererror style="white-space: pre; border: 2px solid #c77;
32    * padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black" >
33    * <h3>This page contains the following errors:</h3>
34    * <div style="font-family:monospace;font-size:12px" >error on line 1 at
35    * column 2: xmlParseStartTag: invalid element name </div>
36    * <h3>Below is a rendering of the page up to the first error.</h3>
37    * </parsererror></body></html> is all you get from Safari. Hope that nobody
38    * wants to send one of those error reports over the wire to be parsed by
39    * safari...
40    *
41    * @param contents contents
42    * @return parsed JavaScript object
43    * @see com.google.gwt.xml.client.impl.XMLParserImpl#parseImpl(java.lang.String)
44    */

45   protected native JavaScriptObject parseImpl(String JavaDoc contents) /*-{
46     var domParser =
47       this.@com.google.gwt.xml.client.impl.XMLParserImplStandard::domParser;
48     var result = domParser.parseFromString(contents,"text/xml");
49     var parseerrors = result.getElementsByTagName("parsererror");
50     if (parseerrors.length > 0) {
51       var err = parseerrors.item(0);
52       var safariErrStyle = "white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black";
53       if(err.getAttribute("style") == safariErrStyle) {
54         throw new Error(err.item(1).innerHTML);
55       }
56     }
57     return result;
58   }-*/
;
59 }
60
Popular Tags