1 /* 2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 // SAX DTD handler. 27 // http://www.saxproject.org 28 // No warranty; no copyright -- use this as you will. 29 // $Id: DTDHandler.java,v 1.2 2004/11/03 22:44:51 jsuttor Exp $ 30 31 package jdk.internal.org.xml.sax; 32 33 /** 34 * Receive notification of basic DTD-related events. 35 * 36 * <blockquote> 37 * <em>This module, both source code and documentation, is in the 38 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> 39 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a> 40 * for further information. 41 * </blockquote> 42 * 43 * <p>If a SAX application needs information about notations and 44 * unparsed entities, then the application implements this 45 * interface and registers an instance with the SAX parser using 46 * the parser's setDTDHandler method. The parser uses the 47 * instance to report notation and unparsed entity declarations to 48 * the application.</p> 49 * 50 * <p>Note that this interface includes only those DTD events that 51 * the XML recommendation <em>requires</em> processors to report: 52 * notation and unparsed entity declarations.</p> 53 * 54 * <p>The SAX parser may report these events in any order, regardless 55 * of the order in which the notations and unparsed entities were 56 * declared; however, all DTD events must be reported after the 57 * document handler's startDocument event, and before the first 58 * startElement event. 59 * (If the {@link org.xml.sax.ext.LexicalHandler LexicalHandler} is 60 * used, these events must also be reported before the endDTD event.) 61 * </p> 62 * 63 * <p>It is up to the application to store the information for 64 * future use (perhaps in a hash table or object tree). 65 * If the application encounters attributes of type "NOTATION", 66 * "ENTITY", or "ENTITIES", it can use the information that it 67 * obtained through this interface to find the entity and/or 68 * notation corresponding with the attribute value.</p> 69 * 70 * @since SAX 1.0 71 * @author David Megginson 72 * @see org.xml.sax.XMLReader#setDTDHandler 73 */ 74 public interface DTDHandler { 75 76 /** 77 * Receive notification of a notation declaration event. 78 * 79 * <p>It is up to the application to record the notation for later 80 * reference, if necessary; 81 * notations may appear as attribute values and in unparsed entity 82 * declarations, and are sometime used with processing instruction 83 * target names.</p> 84 * 85 * <p>At least one of publicId and systemId must be non-null. 86 * If a system identifier is present, and it is a URL, the SAX 87 * parser must resolve it fully before passing it to the 88 * application through this event.</p> 89 * 90 * <p>There is no guarantee that the notation declaration will be 91 * reported before any unparsed entities that use it.</p> 92 * 93 * @param name The notation name. 94 * @param publicId The notation's public identifier, or null if 95 * none was given. 96 * @param systemId The notation's system identifier, or null if 97 * none was given. 98 * @exception org.xml.sax.SAXException Any SAX exception, possibly 99 * wrapping another exception. 100 * @see #unparsedEntityDecl 101 * @see org.xml.sax.Attributes 102 */ 103 public abstract void notationDecl (String name, 104 String publicId, 105 String systemId) 106 throws SAXException; 107 108 109 /** 110 * Receive notification of an unparsed entity declaration event. 111 * 112 * <p>Note that the notation name corresponds to a notation 113 * reported by the {@link #notationDecl notationDecl} event. 114 * It is up to the application to record the entity for later 115 * reference, if necessary; 116 * unparsed entities may appear as attribute values. 117 * </p> 118 * 119 * <p>If the system identifier is a URL, the parser must resolve it 120 * fully before passing it to the application.</p> 121 * 122 * @exception org.xml.sax.SAXException Any SAX exception, possibly 123 * wrapping another exception. 124 * @param name The unparsed entity's name. 125 * @param publicId The entity's public identifier, or null if none 126 * was given. 127 * @param systemId The entity's system identifier. 128 * @param notationName The name of the associated notation. 129 * @see #notationDecl 130 * @see org.xml.sax.Attributes 131 */ 132 public abstract void unparsedEntityDecl (String name, 133 String publicId, 134 String systemId, 135 String notationName) 136 throws SAXException; 137 138 // from SAX2 extension DeclHandler 139 /** 140 * Receive notification of the start of DTD declarations. 141 * 142 * The start/endDTD events appear within the start/endDocument events 143 * from ContentHandler. 144 * 145 * @param name The document type name. 146 * @param publicId The declared public identifier for the 147 * external DTD subset, or null if none was declared. 148 * @param systemId The declared system identifier for the 149 * external DTD subset, or null if none was declared. 150 * (Note that this is not resolved against the document 151 * base URI.) 152 * @throws SAXException the event receiver may throw an exception during processing 153 */ 154 default public void startDTD (String name, String publicId, String systemId) 155 throws SAXException 156 { 157 // no op 158 } 159 160 // Custom API for the Properties 161 162 /** 163 * Receive notification of the start of DTD internal subset. 164 * 165 * @throws SAXException the event receiver may throw an exception during processing 166 */ 167 default public void startInternalSub () throws SAXException 168 { 169 // no op 170 } 171 } 172 173 // end of DTDHandler.java