1/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.  Oracle designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25/*
26 * This file is available under and governed by the GNU General Public
27 * License version 2 only, as published by the Free Software Foundation.
28 * However, the following notice accompanied the original version of this
29 * file and, per its terms, should not be removed:
30 *
31 * Copyright (c) 2004 World Wide Web Consortium,
32 *
33 * (Massachusetts Institute of Technology, European Research Consortium for
34 * Informatics and Mathematics, Keio University). All Rights Reserved. This
35 * work is distributed under the W3C(r) Software License [1] in the hope that
36 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
37 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
38 *
39 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
40 */
41
42package org.w3c.dom.ls;
43
44import org.w3c.dom.Document;
45import org.w3c.dom.DOMConfiguration;
46import org.w3c.dom.Node;
47import org.w3c.dom.DOMException;
48
49/**
50 *  An interface to an object that is able to build, or augment, a DOM tree
51 * from various input sources.
52 * <p> <code>LSParser</code> provides an API for parsing XML and building the
53 * corresponding DOM document structure. A <code>LSParser</code> instance
54 * can be obtained by invoking the
55 * <code>DOMImplementationLS.createLSParser()</code> method.
56 * <p> As specified in [<a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>DOM Level 3 Core</a>]
57 * , when a document is first made available via the LSParser:
58 * <ul>
59 * <li> there will
60 * never be two adjacent nodes of type NODE_TEXT, and there will never be
61 * empty text nodes.
62 * </li>
63 * <li> it is expected that the <code>value</code> and
64 * <code>nodeValue</code> attributes of an <code>Attr</code> node initially
65 * return the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#AVNormalize'>XML 1.0
66 * normalized value</a>. However, if the parameters "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-validate-if-schema'>
67 * validate-if-schema</a>" and "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-datatype-normalization'>
68 * datatype-normalization</a>" are set to <code>true</code>, depending on the attribute normalization
69 * used, the attribute values may differ from the ones obtained by the XML
70 * 1.0 attribute normalization. If the parameters "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-datatype-normalization'>
71 * datatype-normalization</a>" is set to <code>false</code>, the XML 1.0 attribute normalization is
72 * guaranteed to occur, and if the attributes list does not contain
73 * namespace declarations, the <code>attributes</code> attribute on
74 * <code>Element</code> node represents the property <b>[attributes]</b> defined in [<a href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204/'>XML Information Set</a>]
75 * .
76 * </li>
77 * </ul>
78 * <p> Asynchronous <code>LSParser</code> objects are expected to also
79 * implement the <code>events::EventTarget</code> interface so that event
80 * listeners can be registered on asynchronous <code>LSParser</code>
81 * objects.
82 * <p> Events supported by asynchronous <code>LSParser</code> objects are:
83 * <dl>
84 * <dt>load</dt>
85 * <dd>
86 *  The <code>LSParser</code> finishes to load the document. See also the
87 * definition of the <code>LSLoadEvent</code> interface. </dd>
88 * <dt>progress</dt>
89 * <dd> The
90 * <code>LSParser</code> signals progress as data is parsed.  This
91 * specification does not attempt to define exactly when progress events
92 * should be dispatched. That is intentionally left as
93 * implementation-dependent. Here is one example of how an application might
94 * dispatch progress events: Once the parser starts receiving data, a
95 * progress event is dispatched to indicate that the parsing starts. From
96 * there on, a progress event is dispatched for every 4096 bytes of data
97 * that is received and processed. This is only one example, though, and
98 * implementations can choose to dispatch progress events at any time while
99 * parsing, or not dispatch them at all.  See also the definition of the
100 * <code>LSProgressEvent</code> interface. </dd>
101 * </dl>
102 * <p ><b>Note:</b>  All events defined in this specification use the
103 * namespace URI <code>"http://www.w3.org/2002/DOMLS"</code>.
104 * <p> While parsing an input source, errors are reported to the application
105 * through the error handler (<code>LSParser.domConfig</code>'s "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-error-handler'>
106 * error-handler</a>" parameter). This specification does in no way try to define all possible
107 * errors that can occur while parsing XML, or any other markup, but some
108 * common error cases are defined. The types (<code>DOMError.type</code>) of
109 * errors and warnings defined by this specification are:
110 * <dl>
111 * <dt>
112 * <code>"check-character-normalization-failure" [error]</code> </dt>
113 * <dd> Raised if
114 * the parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-check-character-normalization'>
115 * check-character-normalization</a>" is set to true and a string is encountered that fails normalization
116 * checking. </dd>
117 * <dt><code>"doctype-not-allowed" [fatal]</code></dt>
118 * <dd> Raised if the
119 * configuration parameter "disallow-doctype" is set to <code>true</code>
120 * and a doctype is encountered. </dd>
121 * <dt><code>"no-input-specified" [fatal]</code></dt>
122 * <dd>
123 * Raised when loading a document and no input is specified in the
124 * <code>LSInput</code> object. </dd>
125 * <dt>
126 * <code>"pi-base-uri-not-preserved" [warning]</code></dt>
127 * <dd> Raised if a processing
128 * instruction is encountered in a location where the base URI of the
129 * processing instruction can not be preserved.  One example of a case where
130 * this warning will be raised is if the configuration parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-entities'>
131 * entities</a>" is set to <code>false</code> and the following XML file is parsed:
132 * <pre>
133 * &lt;!DOCTYPE root [ &lt;!ENTITY e SYSTEM 'subdir/myentity.ent' ]&gt;
134 * &lt;root&gt; &amp;e; &lt;/root&gt;</pre>
135 *  And <code>subdir/myentity.ent</code>
136 * contains:
137 * <pre>&lt;one&gt; &lt;two/&gt; &lt;/one&gt; &lt;?pi 3.14159?&gt;
138 * &lt;more/&gt;</pre>
139 * </dd>
140 * <dt><code>"unbound-prefix-in-entity" [warning]</code></dt>
141 * <dd> An
142 * implementation dependent warning that may be raised if the configuration
143 * parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-namespaces'>
144 * namespaces</a>" is set to <code>true</code> and an unbound namespace prefix is
145 * encountered in an entity's replacement text. Raising this warning is not
146 * enforced since some existing parsers may not recognize unbound namespace
147 * prefixes in the replacement text of entities. </dd>
148 * <dt>
149 * <code>"unknown-character-denormalization" [fatal]</code></dt>
150 * <dd> Raised if the
151 * configuration parameter "ignore-unknown-character-denormalizations" is
152 * set to <code>false</code> and a character is encountered for which the
153 * processor cannot determine the normalization properties. </dd>
154 * <dt>
155 * <code>"unsupported-encoding" [fatal]</code></dt>
156 * <dd> Raised if an unsupported
157 * encoding is encountered. </dd>
158 * <dt><code>"unsupported-media-type" [fatal]</code></dt>
159 * <dd>
160 * Raised if the configuration parameter "supported-media-types-only" is set
161 * to <code>true</code> and an unsupported media type is encountered. </dd>
162 * </dl>
163 * <p> In addition to raising the defined errors and warnings, implementations
164 * are expected to raise implementation specific errors and warnings for any
165 * other error and warning cases such as IO errors (file not found,
166 * permission denied,...), XML well-formedness errors, and so on.
167 * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407'>Document Object Model (DOM) Level 3 Load
168and Save Specification</a>.
169 *
170 * @since 1.5
171 */
172public interface LSParser {
173    /**
174     *  The <code>DOMConfiguration</code> object used when parsing an input
175     * source. This <code>DOMConfiguration</code> is specific to the parse
176     * operation. No parameter values from this <code>DOMConfiguration</code>
177     *  object are passed automatically to the <code>DOMConfiguration</code>
178     * object on the <code>Document</code> that is created, or used, by the
179     * parse operation. The DOM application is responsible for passing any
180     * needed parameter values from this <code>DOMConfiguration</code>
181     * object to the <code>DOMConfiguration</code> object referenced by the
182     * <code>Document</code> object.
183     * <br> In addition to the parameters recognized in on the <a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMConfiguration'>
184     * DOMConfiguration</a> interface defined in [<a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>DOM Level 3 Core</a>]
185     * , the <code>DOMConfiguration</code> objects for <code>LSParser</code>
186     * add or modify the following parameters:
187     * <dl>
188     * <dt>
189     * <code>"charset-overrides-xml-encoding"</code></dt>
190     * <dd>
191     * <dl>
192     * <dt><code>true</code></dt>
193     * <dd>[<em>optional</em>] (<em>default</em>) If a higher level protocol such as HTTP [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>] provides an
194     * indication of the character encoding of the input stream being
195     * processed, that will override any encoding specified in the XML
196     * declaration or the Text declaration (see also section 4.3.3,
197     * "Character Encoding in Entities", in [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>]).
198     * Explicitly setting an encoding in the <code>LSInput</code> overrides
199     * any encoding from the protocol. </dd>
200     * <dt><code>false</code></dt>
201     * <dd>[<em>required</em>] The parser ignores any character set encoding information from
202     * higher-level protocols. </dd>
203     * </dl></dd>
204     * <dt><code>"disallow-doctype"</code></dt>
205     * <dd>
206     * <dl>
207     * <dt>
208     * <code>true</code></dt>
209     * <dd>[<em>optional</em>] Throw a fatal <b>"doctype-not-allowed"</b> error if a doctype node is found while parsing the document. This is
210     * useful when dealing with things like SOAP envelopes where doctype
211     * nodes are not allowed. </dd>
212     * <dt><code>false</code></dt>
213     * <dd>[<em>required</em>] (<em>default</em>) Allow doctype nodes in the document. </dd>
214     * </dl></dd>
215     * <dt>
216     * <code>"ignore-unknown-character-denormalizations"</code></dt>
217     * <dd>
218     * <dl>
219     * <dt>
220     * <code>true</code></dt>
221     * <dd>[<em>required</em>] (<em>default</em>) If, while verifying full normalization when [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>] is
222     * supported, a processor encounters characters for which it cannot
223     * determine the normalization properties, then the processor will
224     * ignore any possible denormalizations caused by these characters.
225     * This parameter is ignored for [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>]. </dd>
226     * <dt>
227     * <code>false</code></dt>
228     * <dd>[<em>optional</em>] Report an fatal <b>"unknown-character-denormalization"</b> error if a character is encountered for which the processor cannot
229     * determine the normalization properties. </dd>
230     * </dl></dd>
231     * <dt><code>"infoset"</code></dt>
232     * <dd> See
233     * the definition of <code>DOMConfiguration</code> for a description of
234     * this parameter. Unlike in [<a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>DOM Level 3 Core</a>]
235     * , this parameter will default to <code>true</code> for
236     * <code>LSParser</code>. </dd>
237     * <dt><code>"namespaces"</code></dt>
238     * <dd>
239     * <dl>
240     * <dt><code>true</code></dt>
241     * <dd>[<em>required</em>] (<em>default</em>) Perform the namespace processing as defined in [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
242     *  and [<a href='http://www.w3.org/TR/2004/REC-xml-names11-20040204/'>XML Namespaces 1.1</a>]
243     * . </dd>
244     * <dt><code>false</code></dt>
245     * <dd>[<em>optional</em>] Do not perform the namespace processing. </dd>
246     * </dl></dd>
247     * <dt>
248     * <code>"resource-resolver"</code></dt>
249     * <dd>[<em>required</em>] A reference to a <code>LSResourceResolver</code> object, or null. If
250     * the value of this parameter is not null when an external resource
251     * (such as an external XML entity or an XML schema location) is
252     * encountered, the implementation will request that the
253     * <code>LSResourceResolver</code> referenced in this parameter resolves
254     * the resource. </dd>
255     * <dt><code>"supported-media-types-only"</code></dt>
256     * <dd>
257     * <dl>
258     * <dt>
259     * <code>true</code></dt>
260     * <dd>[<em>optional</em>] Check that the media type of the parsed resource is a supported media
261     * type. If an unsupported media type is encountered, a fatal error of
262     * type <b>"unsupported-media-type"</b> will be raised. The media types defined in [<a href='http://www.ietf.org/rfc/rfc3023.txt'>IETF RFC 3023</a>] must always
263     * be accepted. </dd>
264     * <dt><code>false</code></dt>
265     * <dd>[<em>required</em>] (<em>default</em>) Accept any media type. </dd>
266     * </dl></dd>
267     * <dt><code>"validate"</code></dt>
268     * <dd> See the definition of
269     * <code>DOMConfiguration</code> for a description of this parameter.
270     * Unlike in [<a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>DOM Level 3 Core</a>]
271     * , the processing of the internal subset is always accomplished, even
272     * if this parameter is set to <code>false</code>. </dd>
273     * <dt>
274     * <code>"validate-if-schema"</code></dt>
275     * <dd> See the definition of
276     * <code>DOMConfiguration</code> for a description of this parameter.
277     * Unlike in [<a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>DOM Level 3 Core</a>]
278     * , the processing of the internal subset is always accomplished, even
279     * if this parameter is set to <code>false</code>. </dd>
280     * <dt>
281     * <code>"well-formed"</code></dt>
282     * <dd> See the definition of
283     * <code>DOMConfiguration</code> for a description of this parameter.
284     * Unlike in [<a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>DOM Level 3 Core</a>]
285     * , this parameter cannot be set to <code>false</code>. </dd>
286     * </dl>
287     */
288    public DOMConfiguration getDomConfig();
289
290    /**
291     *  When a filter is provided, the implementation will call out to the
292     * filter as it is constructing the DOM tree structure. The filter can
293     * choose to remove elements from the document being constructed, or to
294     * terminate the parsing early.
295     * <br> The filter is invoked after the operations requested by the
296     * <code>DOMConfiguration</code> parameters have been applied. For
297     * example, if "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-validate'>
298     * validate</a>" is set to <code>true</code>, the validation is done before invoking the
299     * filter.
300     */
301    public LSParserFilter getFilter();
302    /**
303     *  When a filter is provided, the implementation will call out to the
304     * filter as it is constructing the DOM tree structure. The filter can
305     * choose to remove elements from the document being constructed, or to
306     * terminate the parsing early.
307     * <br> The filter is invoked after the operations requested by the
308     * <code>DOMConfiguration</code> parameters have been applied. For
309     * example, if "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-validate'>
310     * validate</a>" is set to <code>true</code>, the validation is done before invoking the
311     * filter.
312     */
313    public void setFilter(LSParserFilter filter);
314
315    /**
316     *  <code>true</code> if the <code>LSParser</code> is asynchronous,
317     * <code>false</code> if it is synchronous.
318     */
319    public boolean getAsync();
320
321    /**
322     *  <code>true</code> if the <code>LSParser</code> is currently busy
323     * loading a document, otherwise <code>false</code>.
324     */
325    public boolean getBusy();
326
327    /**
328     * Parse an XML document from a resource identified by a
329     * <code>LSInput</code>.
330     * @param input  The <code>LSInput</code> from which the source of the
331     *   document is to be read.
332     * @return  If the <code>LSParser</code> is a synchronous
333     *   <code>LSParser</code>, the newly created and populated
334     *   <code>Document</code> is returned. If the <code>LSParser</code> is
335     *   asynchronous, <code>null</code> is returned since the document
336     *   object may not yet be constructed when this method returns.
337     * @exception DOMException
338     *    INVALID_STATE_ERR: Raised if the <code>LSParser</code>'s
339     *   <code>LSParser.busy</code> attribute is <code>true</code>.
340     * @exception LSException
341     *    PARSE_ERR: Raised if the <code>LSParser</code> was unable to load
342     *   the XML document. DOM applications should attach a
343     *   <code>DOMErrorHandler</code> using the parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-error-handler'>
344     *   error-handler</a>" if they wish to get details on the error.
345     */
346    public Document parse(LSInput input)
347                          throws DOMException, LSException;
348
349    /**
350     *  Parse an XML document from a location identified by a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]. If the URI
351     * contains a fragment identifier (see section 4.1 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the
352     * behavior is not defined by this specification, future versions of
353     * this specification may define the behavior.
354     * @param uri The location of the XML document to be read.
355     * @return  If the <code>LSParser</code> is a synchronous
356     *   <code>LSParser</code>, the newly created and populated
357     *   <code>Document</code> is returned, or <code>null</code> if an error
358     *   occured. If the <code>LSParser</code> is asynchronous,
359     *   <code>null</code> is returned since the document object may not yet
360     *   be constructed when this method returns.
361     * @exception DOMException
362     *    INVALID_STATE_ERR: Raised if the <code>LSParser.busy</code>
363     *   attribute is <code>true</code>.
364     * @exception LSException
365     *    PARSE_ERR: Raised if the <code>LSParser</code> was unable to load
366     *   the XML document. DOM applications should attach a
367     *   <code>DOMErrorHandler</code> using the parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-error-handler'>
368     *   error-handler</a>" if they wish to get details on the error.
369     */
370    public Document parseURI(String uri)
371                             throws DOMException, LSException;
372
373    // ACTION_TYPES
374    /**
375     *  Append the result of the parse operation as children of the context
376     * node. For this action to work, the context node must be an
377     * <code>Element</code> or a <code>DocumentFragment</code>.
378     */
379    public static final short ACTION_APPEND_AS_CHILDREN = 1;
380    /**
381     *  Replace all the children of the context node with the result of the
382     * parse operation. For this action to work, the context node must be an
383     * <code>Element</code>, a <code>Document</code>, or a
384     * <code>DocumentFragment</code>.
385     */
386    public static final short ACTION_REPLACE_CHILDREN   = 2;
387    /**
388     *  Insert the result of the parse operation as the immediately preceding
389     * sibling of the context node. For this action to work the context
390     * node's parent must be an <code>Element</code> or a
391     * <code>DocumentFragment</code>.
392     */
393    public static final short ACTION_INSERT_BEFORE      = 3;
394    /**
395     *  Insert the result of the parse operation as the immediately following
396     * sibling of the context node. For this action to work the context
397     * node's parent must be an <code>Element</code> or a
398     * <code>DocumentFragment</code>.
399     */
400    public static final short ACTION_INSERT_AFTER       = 4;
401    /**
402     *  Replace the context node with the result of the parse operation. For
403     * this action to work, the context node must have a parent, and the
404     * parent must be an <code>Element</code> or a
405     * <code>DocumentFragment</code>.
406     */
407    public static final short ACTION_REPLACE            = 5;
408
409    /**
410     *  Parse an XML fragment from a resource identified by a
411     * <code>LSInput</code> and insert the content into an existing document
412     * at the position specified with the <code>context</code> and
413     * <code>action</code> arguments. When parsing the input stream, the
414     * context node (or its parent, depending on where the result will be
415     * inserted) is used for resolving unbound namespace prefixes. The
416     * context node's <code>ownerDocument</code> node (or the node itself if
417     * the node of type <code>DOCUMENT_NODE</code>) is used to resolve
418     * default attributes and entity references.
419     * <br> As the new data is inserted into the document, at least one
420     * mutation event is fired per new immediate child or sibling of the
421     * context node.
422     * <br> If the context node is a <code>Document</code> node and the action
423     * is <code>ACTION_REPLACE_CHILDREN</code>, then the document that is
424     * passed as the context node will be changed such that its
425     * <code>xmlEncoding</code>, <code>documentURI</code>,
426     * <code>xmlVersion</code>, <code>inputEncoding</code>,
427     * <code>xmlStandalone</code>, and all other such attributes are set to
428     * what they would be set to if the input source was parsed using
429     * <code>LSParser.parse()</code>.
430     * <br> This method is always synchronous, even if the
431     * <code>LSParser</code> is asynchronous (<code>LSParser.async</code> is
432     * <code>true</code>).
433     * <br> If an error occurs while parsing, the caller is notified through
434     * the <code>ErrorHandler</code> instance associated with the "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-error-handler'>
435     * error-handler</a>" parameter of the <code>DOMConfiguration</code>.
436     * <br> When calling <code>parseWithContext</code>, the values of the
437     * following configuration parameters will be ignored and their default
438     * values will always be used instead: "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-validate'>
439     * validate</a>", "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-validate-if-schema'>
440     * validate-if-schema</a>", and "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-element-content-whitespace'>
441     * element-content-whitespace</a>". Other parameters will be treated normally, and the parser is expected
442     * to call the <code>LSParserFilter</code> just as if a whole document
443     * was parsed.
444     * @param input  The <code>LSInput</code> from which the source document
445     *   is to be read. The source document must be an XML fragment, i.e.
446     *   anything except a complete XML document (except in the case where
447     *   the context node of type <code>DOCUMENT_NODE</code>, and the action
448     *   is <code>ACTION_REPLACE_CHILDREN</code>), a DOCTYPE (internal
449     *   subset), entity declaration(s), notation declaration(s), or XML or
450     *   text declaration(s).
451     * @param contextArg  The node that is used as the context for the data
452     *   that is being parsed. This node must be a <code>Document</code>
453     *   node, a <code>DocumentFragment</code> node, or a node of a type
454     *   that is allowed as a child of an <code>Element</code> node, e.g. it
455     *   cannot be an <code>Attribute</code> node.
456     * @param action  This parameter describes which action should be taken
457     *   between the new set of nodes being inserted and the existing
458     *   children of the context node. The set of possible actions is
459     *   defined in <code>ACTION_TYPES</code> above.
460     * @return  Return the node that is the result of the parse operation. If
461     *   the result is more than one top-level node, the first one is
462     *   returned.
463     * @exception DOMException
464     *   HIERARCHY_REQUEST_ERR: Raised if the content cannot replace, be
465     *   inserted before, after, or as a child of the context node (see also
466     *   <code>Node.insertBefore</code> or <code>Node.replaceChild</code> in [<a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>DOM Level 3 Core</a>]
467     *   ).
468     *   <br> NOT_SUPPORTED_ERR: Raised if the <code>LSParser</code> doesn't
469     *   support this method, or if the context node is of type
470     *   <code>Document</code> and the DOM implementation doesn't support
471     *   the replacement of the <code>DocumentType</code> child or
472     *   <code>Element</code> child.
473     *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is a
474     *   read only node and the content is being appended to its child list,
475     *   or if the parent node of the context node is read only node and the
476     *   content is being inserted in its child list.
477     *   <br> INVALID_STATE_ERR: Raised if the <code>LSParser.busy</code>
478     *   attribute is <code>true</code>.
479     * @exception LSException
480     *    PARSE_ERR: Raised if the <code>LSParser</code> was unable to load
481     *   the XML fragment. DOM applications should attach a
482     *   <code>DOMErrorHandler</code> using the parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-error-handler'>
483     *   error-handler</a>" if they wish to get details on the error.
484     */
485    public Node parseWithContext(LSInput input,
486                                 Node contextArg,
487                                 short action)
488                                 throws DOMException, LSException;
489
490    /**
491     *  Abort the loading of the document that is currently being loaded by
492     * the <code>LSParser</code>. If the <code>LSParser</code> is currently
493     * not busy, a call to this method does nothing.
494     */
495    public void abort();
496
497}
498