michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsISAXAttributes; michael@0: michael@0: /** michael@0: * Receive notification of the logical content of a document. michael@0: * michael@0: * This is the main interface that most SAX applications implement: if michael@0: * the application needs to be informed of basic parsing events, it michael@0: * implements this interface and registers an instance with the SAX michael@0: * parser. The parser uses the instance to report basic michael@0: * document-related events like the start and end of elements and michael@0: * character data. michael@0: * michael@0: * The order of events in this interface is very important, and michael@0: * mirrors the order of information in the document itself. For michael@0: * example, all of an element's content (character data, processing michael@0: * instructions, and/or subelements) will appear, in order, between michael@0: * the startElement event and the corresponding endElement event. michael@0: */ michael@0: [scriptable, uuid(2a99c757-dfee-4806-bff3-f721440412e0)] michael@0: interface nsISAXContentHandler : nsISupports michael@0: { michael@0: /** michael@0: * Receive notification of the beginning of a document. michael@0: * michael@0: * The SAX parser will invoke this method only once, before any michael@0: * other event callbacks. michael@0: */ michael@0: void startDocument(); michael@0: michael@0: /** michael@0: * Receive notification of the end of a document. michael@0: * michael@0: * There is an apparent contradiction between the documentation for michael@0: * this method and the documentation for ErrorHandler.fatalError(). michael@0: * Until this ambiguity is resolved in a future major release, michael@0: * clients should make no assumptions about whether endDocument() michael@0: * will or will not be invoked when the parser has reported a michael@0: * fatalError() or thrown an exception. michael@0: * michael@0: * The SAX parser will invoke this method only once, and it will be michael@0: * the last method invoked during the parse. The parser shall not michael@0: * invoke this method until it has either abandoned parsing (because michael@0: * of an unrecoverable error) or reached the end of input. michael@0: */ michael@0: void endDocument(); michael@0: michael@0: /** michael@0: * Receive notification of the beginning of an element. michael@0: * michael@0: * The Parser will invoke this method at the beginning of every michael@0: * element in the XML document; there will be a corresponding michael@0: * endElement event for every startElement event (even when the michael@0: * element is empty). All of the element's content will be reported, michael@0: * in order, before the corresponding endElement event. michael@0: * michael@0: * This event allows up to three name components for each element: michael@0: * michael@0: * 1.) the Namespace URI; michael@0: * 2.) the local name; and michael@0: * 3.) the qualified (prefixed) name. michael@0: * michael@0: * Any or all of these may be provided, depending on the values of michael@0: * the http://xml.org/sax/features/namespaces and the michael@0: * http://xml.org/sax/features/namespace-prefixes properties: michael@0: * michael@0: * The Namespace URI and local name are required when the namespaces michael@0: * property is true (the default), and are optional when the michael@0: * namespaces property is false (if one is specified, both must be); michael@0: * michael@0: * The qualified name is required when the namespace-prefixes michael@0: * property is true, and is optional when the namespace-prefixes michael@0: * property is false (the default). michael@0: * michael@0: * Note that the attribute list provided will contain only michael@0: * attributes with explicit values (specified or defaulted): michael@0: * #IMPLIED attributes will be omitted. The attribute list will michael@0: * contain attributes used for Namespace declarations (xmlns* michael@0: * attributes) only if the michael@0: * http://xml.org/sax/features/namespace-prefixes property is true michael@0: * (it is false by default, and support for a true value is michael@0: * optional). michael@0: * michael@0: * @param uri the Namespace URI, or the empty string if the michael@0: * element has no Namespace URI or if Namespace michael@0: * processing is not being performed michael@0: * @param localName the local name (without prefix), or the michael@0: * empty string if Namespace processing is not being michael@0: * performed michael@0: * @param qName the qualified name (with prefix), or the michael@0: * empty string if qualified names are not available michael@0: * @param atts the attributes attached to the element. If michael@0: * there are no attributes, it shall be an empty michael@0: * SAXAttributes object. The value of this object after michael@0: * startElement returns is undefined michael@0: */ michael@0: void startElement(in AString uri, in AString localName, michael@0: in AString qName, in nsISAXAttributes attributes); michael@0: michael@0: /** michael@0: * Receive notification of the end of an element. michael@0: * michael@0: * The SAX parser will invoke this method at the end of every michael@0: * element in the XML document; there will be a corresponding michael@0: * startElement event for every endElement event (even when the michael@0: * element is empty). michael@0: * michael@0: * For information on the names, see startElement. michael@0: * michael@0: * @param uri the Namespace URI, or the empty string if the michael@0: * element has no Namespace URI or if Namespace michael@0: * processing is not being performed michael@0: * @param localName the local name (without prefix), or the michael@0: * empty string if Namespace processing is not being michael@0: * performed michael@0: * @param qName the qualified XML name (with prefix), or the michael@0: * empty string if qualified names are not available michael@0: */ michael@0: void endElement(in AString uri, in AString localName, in AString qName); michael@0: michael@0: /** michael@0: * Receive notification of character data. michael@0: * michael@0: * The Parser will call this method to report each chunk of michael@0: * character data. SAX parsers may return all contiguous character michael@0: * data in a single chunk, or they may split it into several chunks; michael@0: * however, all of the characters in any single event must come from michael@0: * the same external entity so that the Locator provides useful michael@0: * information. michael@0: * michael@0: * Note that some parsers will report whitespace in element michael@0: * content using the ignorableWhitespace method rather than this one michael@0: * (validating parsers must do so). michael@0: * michael@0: * @param value the characters from the XML document michael@0: */ michael@0: void characters(in AString value); michael@0: michael@0: /** michael@0: * Receive notification of a processing instruction. michael@0: * michael@0: * The Parser will invoke this method once for each processing michael@0: * instruction found: note that processing instructions may occur michael@0: * before or after the main document element. michael@0: * michael@0: * A SAX parser must never report an XML declaration (XML 1.0, michael@0: * section 2.8) or a text declaration (XML 1.0, section 4.3.1) using michael@0: * this method. michael@0: * michael@0: * @param target the processing instruction target michael@0: * @param data the processing instruction data, or null if michael@0: * none was supplied. The data does not include any michael@0: * whitespace separating it from the target michael@0: */ michael@0: void processingInstruction(in AString target, in AString data); michael@0: michael@0: /** michael@0: * Receive notification of ignorable whitespace in element content. michael@0: * michael@0: * Validating Parsers must use this method to report each chunk of michael@0: * whitespace in element content (see the W3C XML 1.0 michael@0: * recommendation, section 2.10): non-validating parsers may also michael@0: * use this method if they are capable of parsing and using content michael@0: * models. michael@0: * michael@0: * SAX parsers may return all contiguous whitespace in a single michael@0: * chunk, or they may split it into several chunks; however, all of michael@0: * the characters in any single event must come from the same michael@0: * external entity, so that the Locator provides useful information. michael@0: * michael@0: * @param whitespace the characters from the XML document michael@0: */ michael@0: void ignorableWhitespace(in AString whitespace); michael@0: michael@0: /** michael@0: * Begin the scope of a prefix-URI Namespace mapping. michael@0: * michael@0: * The information from this event is not necessary for normal michael@0: * Namespace processing: the SAX XML reader will automatically michael@0: * replace prefixes for element and attribute names when the michael@0: * http://xml.org/sax/features/namespaces feature is michael@0: * true (the default). michael@0: * michael@0: * There are cases, however, when applications need to use prefixes michael@0: * in character data or in attribute values, where they cannot michael@0: * safely be expanded automatically; the start/endPrefixMapping michael@0: * event supplies the information to the application to expand michael@0: * prefixes in those contexts itself, if necessary. michael@0: * michael@0: * Note that start/endPrefixMapping events are not guaranteed to be michael@0: * properly nested relative to each other: all startPrefixMapping michael@0: * events will occur immediately before the corresponding michael@0: * startElement event, and all endPrefixMapping events will occur michael@0: * immediately after the corresponding endElement event, but their michael@0: * order is not otherwise guaranteed. michael@0: * michael@0: * There should never be start/endPrefixMapping events for the michael@0: * "xml" prefix, since it is predeclared and immutable. michael@0: * michael@0: * @param prefix The Namespace prefix being declared. An empty michael@0: * string is used for the default element namespace, michael@0: * which has no prefix. michael@0: * @param uri The Namespace URI the prefix is mapped to. michael@0: */ michael@0: void startPrefixMapping(in AString prefix, in AString uri); michael@0: michael@0: /** michael@0: * End the scope of a prefix-URI mapping. michael@0: * michael@0: * See startPrefixMapping for details. These events will always michael@0: * occur immediately after the corresponding endElement event, but michael@0: * the order of endPrefixMapping events is not otherwise guaranteed. michael@0: * michael@0: * @param prefix The prefix that was being mapped. This is the empty michael@0: * string when a default mapping scope ends. michael@0: */ michael@0: void endPrefixMapping(in AString prefix); michael@0: //XXX documentLocator michael@0: };