286N/A/*
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation. Oracle designates this
286N/A * particular file as subject to the "Classpath" exception as provided
286N/A * by Oracle in the LICENSE file that accompanied this code.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
286N/A * or visit www.oracle.com if you need additional information or have any
286N/A * questions.
286N/A */
286N/A
286N/A/*
286N/A * This file is available under and governed by the GNU General Public
286N/A * License version 2 only, as published by the Free Software Foundation.
286N/A * However, the following notice accompanied the original version of this
286N/A * file and, per its terms, should not be removed:
286N/A *
286N/A * Copyright (c) 2004 World Wide Web Consortium,
286N/A *
286N/A * (Massachusetts Institute of Technology, European Research Consortium for
286N/A * Informatics and Mathematics, Keio University). All Rights Reserved. This
286N/A * work is distributed under the W3C(r) Software License [1] in the hope that
286N/A * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
286N/A * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
286N/A *
286N/A * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
286N/A */
286N/A
286N/Apackage org.w3c.dom.ls;
286N/A
286N/Aimport org.w3c.dom.Node;
286N/Aimport org.w3c.dom.Element;
286N/A
286N/A/**
286N/A * <code>LSParserFilter</code>s provide applications the ability to examine
286N/A * nodes as they are being constructed while parsing. As each node is
286N/A * examined, it may be modified or removed, or the entire parse may be
286N/A * terminated early.
286N/A * <p> At the time any of the filter methods are called by the parser, the
286N/A * owner Document and DOMImplementation objects exist and are accessible.
286N/A * The document element is never passed to the <code>LSParserFilter</code>
286N/A * methods, i.e. it is not possible to filter out the document element.
286N/A * <code>Document</code>, <code>DocumentType</code>, <code>Notation</code>,
286N/A * <code>Entity</code>, and <code>Attr</code> nodes are never passed to the
286N/A * <code>acceptNode</code> method on the filter. The child nodes of an
286N/A * <code>EntityReference</code> node are passed to the filter if the
286N/A * parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-entities'>
286N/A * entities</a>" is set to <code>false</code>. Note that, as described by the parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-entities'>
286N/A * entities</a>", unexpanded entity reference nodes are never discarded and are always
286N/A * passed to the filter.
286N/A * <p> All validity checking while parsing a document occurs on the source
286N/A * document as it appears on the input stream, not on the DOM document as it
286N/A * is built in memory. With filters, the document in memory may be a subset
286N/A * of the document on the stream, and its validity may have been affected by
286N/A * the filtering.
286N/A * <p> All default attributes must be present on elements when the elements
286N/A * are passed to the filter methods. All other default content must be
286N/A * passed to the filter methods.
286N/A * <p> DOM applications must not raise exceptions in a filter. The effect of
286N/A * throwing exceptions from a filter is DOM implementation dependent.
286N/A * <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
286N/Aand Save Specification</a>.
286N/A */
286N/Apublic interface LSParserFilter {
286N/A // Constants returned by startElement and acceptNode
286N/A /**
286N/A * Accept the node.
286N/A */
286N/A public static final short FILTER_ACCEPT = 1;
286N/A /**
286N/A * Reject the node and its children.
286N/A */
286N/A public static final short FILTER_REJECT = 2;
286N/A /**
286N/A * Skip this single node. The children of this node will still be
286N/A * considered.
286N/A */
286N/A public static final short FILTER_SKIP = 3;
286N/A /**
286N/A * Interrupt the normal processing of the document.
286N/A */
286N/A public static final short FILTER_INTERRUPT = 4;
286N/A
286N/A /**
286N/A * The parser will call this method after each <code>Element</code> start
286N/A * tag has been scanned, but before the remainder of the
286N/A * <code>Element</code> is processed. The intent is to allow the
286N/A * element, including any children, to be efficiently skipped. Note that
286N/A * only element nodes are passed to the <code>startElement</code>
286N/A * function.
286N/A * <br>The element node passed to <code>startElement</code> for filtering
286N/A * will include all of the Element's attributes, but none of the
286N/A * children nodes. The Element may not yet be in place in the document
286N/A * being constructed (it may not have a parent node.)
286N/A * <br>A <code>startElement</code> filter function may access or change
286N/A * the attributes for the Element. Changing Namespace declarations will
286N/A * have no effect on namespace resolution by the parser.
286N/A * <br>For efficiency, the Element node passed to the filter may not be
286N/A * the same one as is actually placed in the tree if the node is
286N/A * accepted. And the actual node (node object identity) may be reused
286N/A * during the process of reading in and filtering a document.
286N/A * @param elementArg The newly encountered element. At the time this
286N/A * method is called, the element is incomplete - it will have its
286N/A * attributes, but no children.
286N/A * @return
286N/A * <ul>
286N/A * <li> <code>FILTER_ACCEPT</code> if the <code>Element</code> should
286N/A * be included in the DOM document being built.
286N/A * </li>
286N/A * <li>
286N/A * <code>FILTER_REJECT</code> if the <code>Element</code> and all of
286N/A * its children should be rejected.
286N/A * </li>
286N/A * <li> <code>FILTER_SKIP</code> if the
286N/A * <code>Element</code> should be skipped. All of its children are
286N/A * inserted in place of the skipped <code>Element</code> node.
286N/A * </li>
286N/A * <li>
286N/A * <code>FILTER_INTERRUPT</code> if the filter wants to stop the
286N/A * processing of the document. Interrupting the processing of the
286N/A * document does no longer guarantee that the resulting DOM tree is
286N/A * XML well-formed. The <code>Element</code> is rejected.
286N/A * </li>
286N/A * </ul> Returning
286N/A * any other values will result in unspecified behavior.
286N/A */
286N/A public short startElement(Element elementArg);
286N/A
286N/A /**
286N/A * This method will be called by the parser at the completion of the
286N/A * parsing of each node. The node and all of its descendants will exist
286N/A * and be complete. The parent node will also exist, although it may be
286N/A * incomplete, i.e. it may have additional children that have not yet
286N/A * been parsed. Attribute nodes are never passed to this function.
286N/A * <br>From within this method, the new node may be freely modified -
286N/A * children may be added or removed, text nodes modified, etc. The state
286N/A * of the rest of the document outside this node is not defined, and the
286N/A * affect of any attempt to navigate to, or to modify any other part of
286N/A * the document is undefined.
286N/A * <br>For validating parsers, the checks are made on the original
286N/A * document, before any modification by the filter. No validity checks
286N/A * are made on any document modifications made by the filter.
286N/A * <br>If this new node is rejected, the parser might reuse the new node
286N/A * and any of its descendants.
286N/A * @param nodeArg The newly constructed element. At the time this method
286N/A * is called, the element is complete - it has all of its children
286N/A * (and their children, recursively) and attributes, and is attached
286N/A * as a child to its parent.
286N/A * @return
286N/A * <ul>
286N/A * <li> <code>FILTER_ACCEPT</code> if this <code>Node</code> should
286N/A * be included in the DOM document being built.
286N/A * </li>
286N/A * <li>
286N/A * <code>FILTER_REJECT</code> if the <code>Node</code> and all of its
286N/A * children should be rejected.
286N/A * </li>
286N/A * <li> <code>FILTER_SKIP</code> if the
286N/A * <code>Node</code> should be skipped and the <code>Node</code>
286N/A * should be replaced by all the children of the <code>Node</code>.
286N/A * </li>
286N/A * <li>
286N/A * <code>FILTER_INTERRUPT</code> if the filter wants to stop the
286N/A * processing of the document. Interrupting the processing of the
286N/A * document does no longer guarantee that the resulting DOM tree is
286N/A * XML well-formed. The <code>Node</code> is accepted and will be the
286N/A * last completely parsed node.
286N/A * </li>
286N/A * </ul>
286N/A */
286N/A public short acceptNode(Node nodeArg);
286N/A
286N/A /**
286N/A * Tells the <code>LSParser</code> what types of nodes to show to the
286N/A * method <code>LSParserFilter.acceptNode</code>. If a node is not shown
286N/A * to the filter using this attribute, it is automatically included in
286N/A * the DOM document being built. See <code>NodeFilter</code> for
286N/A * definition of the constants. The constants <code>SHOW_ATTRIBUTE</code>
286N/A * , <code>SHOW_DOCUMENT</code>, <code>SHOW_DOCUMENT_TYPE</code>,
286N/A * <code>SHOW_NOTATION</code>, <code>SHOW_ENTITY</code>, and
286N/A * <code>SHOW_DOCUMENT_FRAGMENT</code> are meaningless here. Those nodes
286N/A * will never be passed to <code>LSParserFilter.acceptNode</code>.
286N/A * <br> The constants used here are defined in [<a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>DOM Level 2 Traversal and Range</a>]
286N/A * .
286N/A */
286N/A public int getWhatToShow();
286N/A
286N/A}