286N/A/*
286N/A * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
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// LexicalHandler.java - optional handler for lexical parse events.
286N/A// http://www.saxproject.org
286N/A// Public Domain: no warranty.
286N/A// $Id: LexicalHandler.java,v 1.2 2004/11/03 22:49:08 jsuttor Exp $
286N/A
286N/Apackage org.xml.sax.ext;
286N/A
286N/Aimport org.xml.sax.SAXException;
286N/A
286N/A/**
286N/A * SAX2 extension handler for lexical events.
286N/A *
286N/A * <blockquote>
286N/A * <em>This module, both source code and documentation, is in the
286N/A * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
286N/A * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
286N/A * for further information.
286N/A * </blockquote>
286N/A *
286N/A * <p>This is an optional extension handler for SAX2 to provide
286N/A * lexical information about an XML document, such as comments
286N/A * and CDATA section boundaries.
286N/A * XML readers are not required to recognize this handler, and it
286N/A * is not part of core-only SAX2 distributions.</p>
286N/A *
286N/A * <p>The events in the lexical handler apply to the entire document,
286N/A * not just to the document element, and all lexical handler events
286N/A * must appear between the content handler's startDocument and
286N/A * endDocument events.</p>
286N/A *
286N/A * <p>To set the LexicalHandler for an XML reader, use the
286N/A * {@link org.xml.sax.XMLReader#setProperty setProperty} method
286N/A * with the property name
286N/A * <code>http://xml.org/sax/properties/lexical-handler</code>
286N/A * and an object implementing this interface (or null) as the value.
286N/A * If the reader does not report lexical events, it will throw a
286N/A * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
286N/A * when you attempt to register the handler.</p>
286N/A *
286N/A * @since SAX 2.0 (extensions 1.0)
286N/A * @author David Megginson
286N/A */
286N/Apublic interface LexicalHandler
286N/A{
286N/A
286N/A /**
286N/A * Report the start of DTD declarations, if any.
286N/A *
286N/A * <p>This method is intended to report the beginning of the
286N/A * DOCTYPE declaration; if the document has no DOCTYPE declaration,
286N/A * this method will not be invoked.</p>
286N/A *
286N/A * <p>All declarations reported through
286N/A * {@link org.xml.sax.DTDHandler DTDHandler} or
286N/A * {@link org.xml.sax.ext.DeclHandler DeclHandler} events must appear
286N/A * between the startDTD and {@link #endDTD endDTD} events.
286N/A * Declarations are assumed to belong to the internal DTD subset
286N/A * unless they appear between {@link #startEntity startEntity}
286N/A * and {@link #endEntity endEntity} events. Comments and
286N/A * processing instructions from the DTD should also be reported
286N/A * between the startDTD and endDTD events, in their original
286N/A * order of (logical) occurrence; they are not required to
286N/A * appear in their correct locations relative to DTDHandler
286N/A * or DeclHandler events, however.</p>
286N/A *
286N/A * <p>Note that the start/endDTD events will appear within
286N/A * the start/endDocument events from ContentHandler and
286N/A * before the first
286N/A * {@link org.xml.sax.ContentHandler#startElement startElement}
286N/A * event.</p>
286N/A *
286N/A * @param name The document type name.
286N/A * @param publicId The declared public identifier for the
286N/A * external DTD subset, or null if none was declared.
286N/A * @param systemId The declared system identifier for the
286N/A * external DTD subset, or null if none was declared.
286N/A * (Note that this is not resolved against the document
286N/A * base URI.)
286N/A * @exception SAXException The application may raise an
286N/A * exception.
286N/A * @see #endDTD
286N/A * @see #startEntity
286N/A */
286N/A public abstract void startDTD (String name, String publicId,
286N/A String systemId)
286N/A throws SAXException;
286N/A
286N/A
286N/A /**
286N/A * Report the end of DTD declarations.
286N/A *
286N/A * <p>This method is intended to report the end of the
286N/A * DOCTYPE declaration; if the document has no DOCTYPE declaration,
286N/A * this method will not be invoked.</p>
286N/A *
286N/A * @exception SAXException The application may raise an exception.
286N/A * @see #startDTD
286N/A */
286N/A public abstract void endDTD ()
286N/A throws SAXException;
286N/A
286N/A
286N/A /**
286N/A * Report the beginning of some internal and external XML entities.
286N/A *
286N/A * <p>The reporting of parameter entities (including
286N/A * the external DTD subset) is optional, and SAX2 drivers that
286N/A * report LexicalHandler events may not implement it; you can use the
286N/A * <code
286N/A * >http://xml.org/sax/features/lexical-handler/parameter-entities</code>
286N/A * feature to query or control the reporting of parameter entities.</p>
286N/A *
286N/A * <p>General entities are reported with their regular names,
286N/A * parameter entities have '%' prepended to their names, and
286N/A * the external DTD subset has the pseudo-entity name "[dtd]".</p>
286N/A *
286N/A * <p>When a SAX2 driver is providing these events, all other
286N/A * events must be properly nested within start/end entity
286N/A * events. There is no additional requirement that events from
286N/A * {@link org.xml.sax.ext.DeclHandler DeclHandler} or
286N/A * {@link org.xml.sax.DTDHandler DTDHandler} be properly ordered.</p>
286N/A *
286N/A * <p>Note that skipped entities will be reported through the
286N/A * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
286N/A * event, which is part of the ContentHandler interface.</p>
286N/A *
286N/A * <p>Because of the streaming event model that SAX uses, some
286N/A * entity boundaries cannot be reported under any
286N/A * circumstances:</p>
286N/A *
286N/A * <ul>
286N/A * <li>general entities within attribute values</li>
286N/A * <li>parameter entities within declarations</li>
286N/A * </ul>
286N/A *
286N/A * <p>These will be silently expanded, with no indication of where
286N/A * the original entity boundaries were.</p>
286N/A *
286N/A * <p>Note also that the boundaries of character references (which
286N/A * are not really entities anyway) are not reported.</p>
286N/A *
286N/A * <p>All start/endEntity events must be properly nested.
286N/A *
286N/A * @param name The name of the entity. If it is a parameter
286N/A * entity, the name will begin with '%', and if it is the
286N/A * external DTD subset, it will be "[dtd]".
286N/A * @exception SAXException The application may raise an exception.
286N/A * @see #endEntity
286N/A * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
286N/A * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
286N/A */
286N/A public abstract void startEntity (String name)
286N/A throws SAXException;
286N/A
286N/A
286N/A /**
286N/A * Report the end of an entity.
286N/A *
286N/A * @param name The name of the entity that is ending.
286N/A * @exception SAXException The application may raise an exception.
286N/A * @see #startEntity
286N/A */
286N/A public abstract void endEntity (String name)
286N/A throws SAXException;
286N/A
286N/A
286N/A /**
286N/A * Report the start of a CDATA section.
286N/A *
286N/A * <p>The contents of the CDATA section will be reported through
286N/A * the regular {@link org.xml.sax.ContentHandler#characters
286N/A * characters} event; this event is intended only to report
286N/A * the boundary.</p>
286N/A *
286N/A * @exception SAXException The application may raise an exception.
286N/A * @see #endCDATA
286N/A */
286N/A public abstract void startCDATA ()
286N/A throws SAXException;
286N/A
286N/A
286N/A /**
286N/A * Report the end of a CDATA section.
286N/A *
286N/A * @exception SAXException The application may raise an exception.
286N/A * @see #startCDATA
286N/A */
286N/A public abstract void endCDATA ()
286N/A throws SAXException;
286N/A
286N/A
286N/A /**
286N/A * Report an XML comment anywhere in the document.
286N/A *
286N/A * <p>This callback will be used for comments inside or outside the
286N/A * document element, including comments in the external DTD
286N/A * subset (if read). Comments in the DTD must be properly
286N/A * nested inside start/endDTD and start/endEntity events (if
286N/A * used).</p>
286N/A *
286N/A * @param ch An array holding the characters in the comment.
286N/A * @param start The starting position in the array.
286N/A * @param length The number of characters to use from the array.
286N/A * @exception SAXException The application may raise an exception.
286N/A */
286N/A public abstract void comment (char ch[], int start, int length)
286N/A throws SAXException;
286N/A
286N/A}
286N/A
286N/A// end of LexicalHandler.java