001: /*
002: * The Apache Software License, Version 1.1
003: *
004: *
005: * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
006: * reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions and the following disclaimer in
017: * the documentation and/or other materials provided with the
018: * distribution.
019: *
020: * 3. The end-user documentation included with the redistribution,
021: * if any, must include the following acknowledgment:
022: * "This product includes software developed by the
023: * Apache Software Foundation (http://www.apache.org/)."
024: * Alternately, this acknowledgment may appear in the software itself,
025: * if and wherever such third-party acknowledgments normally appear.
026: *
027: * 4. The names "Xerces" and "Apache Software Foundation" must
028: * not be used to endorse or promote products derived from this
029: * software without prior written permission. For written
030: * permission, please contact apache@apache.org.
031: *
032: * 5. Products derived from this software may not be called "Apache",
033: * nor may "Apache" appear in their name, without prior written
034: * permission of the Apache Software Foundation.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: * ====================================================================
049: *
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the Apache Software Foundation and was
052: * originally based on software copyright (c) 1999, International
053: * Business Machines, Inc., http://www.apache.org. For more
054: * information on the Apache Software Foundation, please see
055: * <http://www.apache.org/>.
056: */
057:
058: package org.apache.xerces.framework;
059:
060: import org.apache.xerces.utils.QName;
061:
062: /**
063: * XMLValidator defines the interface that XMLDocumentScanner and XML
064: * EntityHandler have with an object that serves as a pluggable validator.
065: * This abstraction allows validators for XML grammar languages to be
066: * plugged in and queried for validity checks as the scanner processes
067: * a document.
068: * <p>
069: * The document scanner and entity handler need to ask the validator object
070: * for this information because the validator object is responsible for reading
071: * the grammar specification file (which contains markup declarations and entity
072: * declarations)
073: *
074: * @version $Id: XMLDocumentHandler.java,v 1.4 2000/05/26 18:59:02 andyc Exp $
075: */
076:
077: public interface XMLDocumentHandler {
078:
079: /**
080: * Callback for start of document
081: *
082: * If the there is no version info, encoding info, or standalone info,
083: * the corresponding argument will be set to -1.
084: *
085: * @exception java.lang.Exception
086: */
087: public void startDocument() throws Exception;
088:
089: /**
090: * callback for the end of document.
091: *
092: * @exception java.lang.Exception
093: */
094: public void endDocument() throws Exception;
095:
096: /**
097: * Signal the XML declaration of a document
098: *
099: * @param version the handle in the string pool for the version number
100: * @param encoding the handle in the string pool for the encoding
101: * @param standalong the handle in the string pool for the standalone value
102: * @exception java.lang.Exception
103: */
104: public void xmlDecl(int version, int encoding, int standalone)
105: throws Exception;
106:
107: /**
108: * Signal the Text declaration of an external entity.
109: *
110: * @exception java.lang.Exception
111: */
112: public void textDecl(int version, int encoding) throws Exception;
113:
114: /**
115: * callback for the start of a namespace declaration scope.
116: *
117: * @param prefix string pool index of the namespace prefix being declared
118: * @param uri string pool index of the namespace uri begin bound
119: * @param java.lang.Exception
120: */
121: public void startNamespaceDeclScope(int prefix, int uri)
122: throws Exception;
123:
124: /**
125: * callback for the end a namespace declaration scope.
126: *
127: * @param prefix string pool index of the namespace prefix being declared
128: * @exception java.lang.Exception
129: */
130: public void endNamespaceDeclScope(int prefix) throws Exception;
131:
132: /**
133: * callback for the start of element.
134: *
135: * @param elementType element handle for the element being scanned
136: * @param attrList attrList containing the attributes of the element
137: * @param attrListHandle handle into attrList. Allows attributes to be retreived.
138: * @exception java.lang.Exception
139: */
140: public void startElement(QName element, XMLAttrList attrList,
141: int attrListHandle) throws Exception;
142:
143: /**
144: * callback for end of element.
145: *
146: * @param elementType element handle for the element being scanned
147: * @exception java.lang.Exception
148: */
149: public void endElement(QName element) throws Exception;
150:
151: /**
152: * callback for start of entity reference.
153: *
154: * @param entityName string pool index of the entity name
155: * @param entityType the XMLEntityHandler.ENTITYTYPE_* type
156: * @see org.apache.xerces.readers.XMLEntityHandler
157: * @param entityContext the XMLEntityHandler.ENTITYREF_* type for where
158: * the entity reference appears
159: * @see org.apache.xerces.readers.XMLEntityHandler
160: * @exception java.lang.Exception
161: */
162: public void startEntityReference(int entityName, int entityType,
163: int entityContext) throws Exception;
164:
165: /**
166: * callback for end of entity reference.
167: *
168: * @param entityName string pool index of the entity anem
169: * @param entityType the XMLEntityHandler.ENTITYTYPE_* type
170: * @see org.apache.xerces.readers.XMLEntityHandler
171: * @param entityContext the XMLEntityHandler.ENTITYREF_* type for where
172: * the entity reference appears
173: * @see org.apache.xerces.readers.XMLEntityHandler
174: * @exception java.lang.Exception
175: */
176: public void endEntityReference(int entityName, int entityType,
177: int entityContext) throws Exception;
178:
179: /**
180: * callback for processing instruction.
181: *
182: * @param target string pool index of the PI target
183: * @param data string pool index of the PI data
184: * @exception java.lang.Exception
185: */
186: public void processingInstruction(int target, int data)
187: throws Exception;
188:
189: /**
190: * callback for comment.
191: *
192: * @param comment string pool index of the comment text
193: * @exception java.lang.Exception
194: */
195: public void comment(int comment) throws Exception;
196:
197: /**
198: * callback for characters (string pool form).
199: *
200: * @param data string pool index of the characters that were scanned
201: * @exception java.lang.Exception
202: */
203: public void characters(int data) throws Exception;
204:
205: /**
206: * callback for characters.
207: *
208: * @param ch character array containing the characters that were scanned
209: * @param start offset in ch where scanned characters begin
210: * @param length length of scanned characters in ch
211: * @exception java.lang.Exception
212: */
213: public void characters(char ch[], int start, int length)
214: throws Exception;
215:
216: /**
217: * callback for ignorable whitespace.
218: *
219: * @param data string pool index of ignorable whitespace
220: * @exception java.lang.Exception
221: */
222: public void ignorableWhitespace(int data) throws Exception;
223:
224: /**
225: * callback for ignorable whitespace.
226: *
227: * @param ch character array containing the whitespace that was scanned
228: * @param start offset in ch where scanned whitespace begins
229: * @param length length of scanned whitespace in ch
230: * @exception java.lang.Exception
231: */
232: public void ignorableWhitespace(char ch[], int start, int length)
233: throws Exception;
234:
235: /**
236: * callback for start of CDATA section.
237: * this callback marks the start of a CDATA section
238: *
239: * @exception java.lang.Exception
240: */
241: public void startCDATA() throws Exception;
242:
243: /**
244: * callback for end of CDATA section.
245: * this callback marks the end of a CDATA section
246: *
247: * @exception java.lang.Exception
248: */
249: public void endCDATA() throws Exception;
250:
251: //
252: // Additional DTD specific events.
253: //
254: public interface DTDHandler {
255: /**
256: * callback for the start of the DTD
257: * This function will be called when a <!DOCTYPE...> declaration is
258: * encountered.
259: *
260: * @param rootElementType element handle for the root element of the document
261: * @param publicId string pool index of the DTD's public ID
262: * @param systemId string pool index of the DTD's system ID
263: * @exception java.lang.Exception
264: */
265: public void startDTD(QName rootElement, int publicId,
266: int systemId) throws Exception;
267:
268: /**
269: * Supports DOM Level 2 internalSubset additions.
270: * Called when the internal subset is completely scanned.
271: */
272: public void internalSubset(int internalSubset) throws Exception;
273:
274: /**
275: * Signal the Text declaration of an external entity.
276: *
277: * @exception java.lang.Exception
278: */
279: public void textDecl(int version, int encoding)
280: throws Exception;
281:
282: /**
283: * callback for the end of the DTD
284: * This function will be called at the end of the DTD.
285: */
286: public void endDTD() throws Exception;
287:
288: /**
289: * callback for an element declaration.
290: *
291: * @param elementType element handle of the element being declared
292: * @param contentSpec contentSpec for the element being declared
293: * @see org.apache.xerces.framework.XMLContentSpec
294: * @exception java.lang.Exception
295: */
296: public void elementDecl(QName elementDecl, int contentSpecType,
297: int contentSpecIndex,
298: XMLContentSpec.Provider contentSpecProvider)
299: throws Exception;
300:
301: /**
302: * callback for an attribute list declaration.
303: *
304: * @param elementType element handle for the attribute's element
305: * @param attrName string pool index of the attribute name
306: * @param attType type of attribute
307: * @param enumString String representing the values of the enumeration,
308: * if the attribute is of enumerated type, or null if it is not.
309: * @param attDefaultType an integer value denoting the DefaultDecl value
310: * @param attDefaultValue string pool index of this attribute's default value
311: * or -1 if there is no defaultvalue
312: * @exception java.lang.Exception
313: */
314: public void attlistDecl(QName elementDecl, QName attributeDecl,
315: int attType, boolean attList, String enumString,
316: int attDefaultType, int attDefaultValue)
317: throws Exception;
318:
319: /**
320: * callback for an internal parameter entity declaration.
321: *
322: * @param entityName string pool index of the entity name
323: * @param entityValue string pool index of the entity replacement text
324: * @exception java.lang.Exception
325: */
326: public void internalPEDecl(int entityName, int entityValue)
327: throws Exception;
328:
329: /**
330: * callback for an external parameter entity declaration.
331: *
332: * @param entityName string pool index of the entity name
333: * @param publicId string pool index of the entity's public id.
334: * @param systemId string pool index of the entity's system id.
335: * @exception java.lang.Exception
336: */
337: public void externalPEDecl(int entityName, int publicId,
338: int systemId) throws Exception;
339:
340: /**
341: * callback for internal general entity declaration.
342: *
343: * @param entityName string pool index of the entity name
344: * @param entityValue string pool index of the entity replacement text
345: * @exception java.lang.Exception
346: */
347: public void internalEntityDecl(int entityName, int entityValue)
348: throws Exception;
349:
350: /**
351: * callback for external general entity declaration.
352: *
353: * @param entityName string pool index of the entity name
354: * @param publicId string pool index of the entity's public id.
355: * @param systemId string pool index of the entity's system id.
356: * @exception java.lang.Exception
357: */
358: public void externalEntityDecl(int entityName, int publicId,
359: int systemId) throws Exception;
360:
361: /**
362: * callback for an unparsed entity declaration.
363: *
364: * @param entityName string pool index of the entity name
365: * @param publicId string pool index of the entity's public id.
366: * @param systemId string pool index of the entity's system id.
367: * @param notationName string pool index of the notation name.
368: * @exception java.lang.Exception
369: */
370: public void unparsedEntityDecl(int entityName, int publicId,
371: int systemId, int notationName) throws Exception;
372:
373: /**
374: * callback for a notation declaration.
375: *
376: * @param notationName string pool index of the notation name
377: * @param publicId string pool index of the notation's public id.
378: * @param systemId string pool index of the notation's system id.
379: * @exception java.lang.Exception
380: */
381: public void notationDecl(int notationName, int publicId,
382: int systemId) throws Exception;
383:
384: /**
385: * Callback for processing instruction in DTD.
386: *
387: * @param target the string pool index of the PI's target
388: * @param data the string pool index of the PI's data
389: * @exception java.lang.Exception
390: */
391: public void processingInstruction(int targetIndex, int dataIndex)
392: throws Exception;
393:
394: /**
395: * Callback for comment in DTD.
396: *
397: * @param comment the string pool index of the comment text
398: * @exception java.lang.Exception
399: */
400: public void comment(int dataIndex) throws Exception;
401: }
402: }
|