Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | /** |
michael@0 | 9 | * SAX2 extension handler for lexical events. |
michael@0 | 10 | * |
michael@0 | 11 | * This is an extension handler for SAX2 to provide lexical |
michael@0 | 12 | * information about an XML document, such as comments and CDATA |
michael@0 | 13 | * section boundaries. |
michael@0 | 14 | * |
michael@0 | 15 | * The events in the lexical handler apply to the entire document, |
michael@0 | 16 | * not just to the document element, and all lexical handler events |
michael@0 | 17 | * must appear between the content handler's startDocument and |
michael@0 | 18 | * endDocument events. |
michael@0 | 19 | */ |
michael@0 | 20 | [scriptable, uuid(23c26a56-adff-440c-8caf-95c2dc2e399b)] |
michael@0 | 21 | interface nsISAXLexicalHandler : nsISupports { |
michael@0 | 22 | |
michael@0 | 23 | /** |
michael@0 | 24 | * Report an XML comment anywhere in the document. |
michael@0 | 25 | * |
michael@0 | 26 | * This callback will be used for comments inside or outside the |
michael@0 | 27 | * document element, including comments in the external DTD subset |
michael@0 | 28 | * (if read). Comments in the DTD must be properly nested inside |
michael@0 | 29 | * start/endDTD and start/endEntity events (if used). |
michael@0 | 30 | * |
michael@0 | 31 | * @param chars The characters in the comment. |
michael@0 | 32 | */ |
michael@0 | 33 | void comment(in AString chars); |
michael@0 | 34 | |
michael@0 | 35 | /** |
michael@0 | 36 | * Report the start of DTD declarations, if any. |
michael@0 | 37 | * |
michael@0 | 38 | * This method is intended to report the beginning of the |
michael@0 | 39 | * DOCTYPE declaration; if the document has no DOCTYPE declaration, |
michael@0 | 40 | * this method will not be invoked. |
michael@0 | 41 | * |
michael@0 | 42 | * All declarations reported through DTDHandler or DeclHandler |
michael@0 | 43 | * events must appear between the startDTD and endDTD events. |
michael@0 | 44 | * Declarations are assumed to belong to the internal DTD subset |
michael@0 | 45 | * unless they appear between startEntity and endEntity events. |
michael@0 | 46 | * Comments and processing instructions from the DTD should also be |
michael@0 | 47 | * reported between the startDTD and endDTD events, in their |
michael@0 | 48 | * original order of (logical) occurrence; they are not required to |
michael@0 | 49 | * appear in their correct locations relative to DTDHandler or |
michael@0 | 50 | * DeclHandler events, however. |
michael@0 | 51 | * |
michael@0 | 52 | * Note that the start/endDTD events will appear within the |
michael@0 | 53 | * start/endDocument events from ContentHandler and before the first |
michael@0 | 54 | * startElement event. |
michael@0 | 55 | * |
michael@0 | 56 | * @param name The document type name. |
michael@0 | 57 | * @param publicId The declared public identifier for the |
michael@0 | 58 | * external DTD subset, or null if none was declared. |
michael@0 | 59 | * @param systemId The declared system identifier for the |
michael@0 | 60 | * external DTD subset, or null if none was declared. |
michael@0 | 61 | * (Note that this is not resolved against the document |
michael@0 | 62 | * base URI.) |
michael@0 | 63 | */ |
michael@0 | 64 | void startDTD(in AString name, in AString publicId, in AString systemId); |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * Report the end of DTD declarations. |
michael@0 | 68 | * |
michael@0 | 69 | * This method is intended to report the end of the |
michael@0 | 70 | * DOCTYPE declaration; if the document has no DOCTYPE declaration, |
michael@0 | 71 | * this method will not be invoked. |
michael@0 | 72 | */ |
michael@0 | 73 | void endDTD(); |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * Report the start of a CDATA section. |
michael@0 | 77 | * |
michael@0 | 78 | * The contents of the CDATA section will be reported through the |
michael@0 | 79 | * regular characters event; this event is intended only to report |
michael@0 | 80 | * the boundary. |
michael@0 | 81 | */ |
michael@0 | 82 | void startCDATA(); |
michael@0 | 83 | |
michael@0 | 84 | /** |
michael@0 | 85 | * Report the end of a CDATA section. |
michael@0 | 86 | */ |
michael@0 | 87 | void endCDATA(); |
michael@0 | 88 | |
michael@0 | 89 | /** |
michael@0 | 90 | * Report the beginning of some internal and external XML entities. |
michael@0 | 91 | * |
michael@0 | 92 | * Because of the streaming event model that SAX uses, some |
michael@0 | 93 | * entity boundaries cannot be reported under any circumstances: |
michael@0 | 94 | * |
michael@0 | 95 | * 1.) general entities within attribute values |
michael@0 | 96 | * 2.) parameter entities within declarations |
michael@0 | 97 | * |
michael@0 | 98 | * These will be silently expanded, with no indication of where |
michael@0 | 99 | * the original entity boundaries were. |
michael@0 | 100 | * |
michael@0 | 101 | * Note also that the boundaries of character references (which |
michael@0 | 102 | * are not really entities anyway) are not reported. |
michael@0 | 103 | * |
michael@0 | 104 | * All start/endEntity events must be properly nested. |
michael@0 | 105 | * |
michael@0 | 106 | * @param name The name of the entity. If it is a parameter |
michael@0 | 107 | * entity, the name will begin with '%', and if it is the |
michael@0 | 108 | * external DTD subset, it will be "[dtd]". |
michael@0 | 109 | */ |
michael@0 | 110 | void startEntity(in AString name); |
michael@0 | 111 | |
michael@0 | 112 | /** |
michael@0 | 113 | * Report the end of an entity. |
michael@0 | 114 | * |
michael@0 | 115 | * @param name The name of the entity that is ending. |
michael@0 | 116 | */ |
michael@0 | 117 | void endEntity(in AString name); |
michael@0 | 118 | }; |