Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/xml/sax/ext/DeclHandler.java
48576 views
/*1* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.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 it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* 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 WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425// DeclHandler.java - Optional handler for DTD declaration events.26// http://www.saxproject.org27// Public Domain: no warranty.28// $Id: DeclHandler.java,v 1.2 2004/11/03 22:49:08 jsuttor Exp $2930package org.xml.sax.ext;3132import org.xml.sax.SAXException;333435/**36* SAX2 extension handler for DTD declaration events.37*38* <blockquote>39* <em>This module, both source code and documentation, is in the40* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>41* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>42* for further information.43* </blockquote>44*45* <p>This is an optional extension handler for SAX2 to provide more46* complete information about DTD declarations in an XML document.47* XML readers are not required to recognize this handler, and it48* is not part of core-only SAX2 distributions.</p>49*50* <p>Note that data-related DTD declarations (unparsed entities and51* notations) are already reported through the {@link52* org.xml.sax.DTDHandler DTDHandler} interface.</p>53*54* <p>If you are using the declaration handler together with a lexical55* handler, all of the events will occur between the56* {@link org.xml.sax.ext.LexicalHandler#startDTD startDTD} and the57* {@link org.xml.sax.ext.LexicalHandler#endDTD endDTD} events.</p>58*59* <p>To set the DeclHandler for an XML reader, use the60* {@link org.xml.sax.XMLReader#setProperty setProperty} method61* with the property name62* <code>http://xml.org/sax/properties/declaration-handler</code>63* and an object implementing this interface (or null) as the value.64* If the reader does not report declaration events, it will throw a65* {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}66* when you attempt to register the handler.</p>67*68* @since SAX 2.0 (extensions 1.0)69* @author David Megginson70*/71public interface DeclHandler72{7374/**75* Report an element type declaration.76*77* <p>The content model will consist of the string "EMPTY", the78* string "ANY", or a parenthesised group, optionally followed79* by an occurrence indicator. The model will be normalized so80* that all parameter entities are fully resolved and all whitespace81* is removed,and will include the enclosing parentheses. Other82* normalization (such as removing redundant parentheses or83* simplifying occurrence indicators) is at the discretion of the84* parser.</p>85*86* @param name The element type name.87* @param model The content model as a normalized string.88* @exception SAXException The application may raise an exception.89*/90public abstract void elementDecl (String name, String model)91throws SAXException;929394/**95* Report an attribute type declaration.96*97* <p>Only the effective (first) declaration for an attribute will98* be reported. The type will be one of the strings "CDATA",99* "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",100* "ENTITIES", a parenthesized token group with101* the separator "|" and all whitespace removed, or the word102* "NOTATION" followed by a space followed by a parenthesized103* token group with all whitespace removed.</p>104*105* <p>The value will be the value as reported to applications,106* appropriately normalized and with entity and character107* references expanded. </p>108*109* @param eName The name of the associated element.110* @param aName The name of the attribute.111* @param type A string representing the attribute type.112* @param mode A string representing the attribute defaulting mode113* ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if114* none of these applies.115* @param value A string representing the attribute's default value,116* or null if there is none.117* @exception SAXException The application may raise an exception.118*/119public abstract void attributeDecl (String eName,120String aName,121String type,122String mode,123String value)124throws SAXException;125126127/**128* Report an internal entity declaration.129*130* <p>Only the effective (first) declaration for each entity131* will be reported. All parameter entities in the value132* will be expanded, but general entities will not.</p>133*134* @param name The name of the entity. If it is a parameter135* entity, the name will begin with '%'.136* @param value The replacement text of the entity.137* @exception SAXException The application may raise an exception.138* @see #externalEntityDecl139* @see org.xml.sax.DTDHandler#unparsedEntityDecl140*/141public abstract void internalEntityDecl (String name, String value)142throws SAXException;143144145/**146* Report a parsed external entity declaration.147*148* <p>Only the effective (first) declaration for each entity149* will be reported.</p>150*151* <p>If the system identifier is a URL, the parser must resolve it152* fully before passing it to the application.</p>153*154* @param name The name of the entity. If it is a parameter155* entity, the name will begin with '%'.156* @param publicId The entity's public identifier, or null if none157* was given.158* @param systemId The entity's system identifier.159* @exception SAXException The application may raise an exception.160* @see #internalEntityDecl161* @see org.xml.sax.DTDHandler#unparsedEntityDecl162*/163public abstract void externalEntityDecl (String name, String publicId,164String systemId)165throws SAXException;166167}168169// end of DeclHandler.java170171172