01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 the IE6 implementation of the XMLParser interface.
22: */
23: class XMLParserImplIE6 extends XMLParserImpl {
24:
25: @Override
26: protected native JavaScriptObject createDocumentImpl() /*-{
27: var doc = new ActiveXObject("MSXML2.DOMDocument");
28: doc.preserveWhiteSpace = true;
29: doc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
30: doc.setProperty("SelectionLanguage", "XPath");
31: return doc;
32: }-*/;
33:
34: @Override
35: protected native JavaScriptObject getElementByIdImpl(
36: JavaScriptObject o, String elementId) /*-{
37: var out = o.nodeFromID(elementId);
38: return (out == null) ? null : out;
39: }-*/;
40:
41: @Override
42: protected native JavaScriptObject getElementsByTagNameImpl(
43: JavaScriptObject o, String tagName) /*-{
44: return o.selectNodes(".//*[local-name()='" + tagName + "']");
45: }-*/;
46:
47: @Override
48: protected native String getPrefixImpl(JavaScriptObject jsObject) /*-{
49: return jsObject.prefix;
50: }-*/;
51:
52: @Override
53: protected native JavaScriptObject importNodeImpl(
54: JavaScriptObject o, JavaScriptObject importedNode,
55: boolean deep) /*-{
56: // IE6 does not seem to need or want nodes to be imported
57: // as appends from different docs work perfectly
58: // and this method is not supplied until MSXML5.0
59: return importedNode;
60: }-*/;
61:
62: @Override
63: protected native JavaScriptObject parseImpl(String contents) /*-{
64: var doc = this.@com.google.gwt.xml.client.impl.XMLParserImplIE6::createDocumentImpl()();
65: if(!doc.loadXML(contents)) {
66: var err = doc.parseError;
67: throw new Error("line " + err.line + ", char " + err.linepos + ":" + err.reason);
68: } else {
69: return doc;
70: }
71: }-*/;
72:
73: }
|