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: interface nsIScriptError; michael@0: michael@0: /** michael@0: * This interface should be implemented by any content sink that wants michael@0: * to get output from expat and do something with it; in other words, michael@0: * by any sink that handles some sort of XML dialect. michael@0: */ michael@0: michael@0: [scriptable, uuid(f61c56b5-ea5b-42b4-ad3c-17416e72e238)] michael@0: interface nsIExpatSink : nsISupports michael@0: { michael@0: /** michael@0: * Called to handle the opening tag of an element. michael@0: * @param aName the fully qualified tagname of the element michael@0: * @param aAtts the array of attribute names and values. There are michael@0: * aAttsCount/2 names and aAttsCount/2 values, so the total number of michael@0: * elements in the array is aAttsCount. The names and values michael@0: * alternate. Thus, if we number attributes starting with 0, michael@0: * aAtts[2*k] is the name of the k-th attribute and aAtts[2*k+1] is michael@0: * the value of that attribute Both explicitly specified attributes michael@0: * and attributes that are defined to have default values in a DTD are michael@0: * present in aAtts. michael@0: * @param aAttsCount the number of elements in aAtts. michael@0: * @param aIndex If the element has an attribute of type ID, then michael@0: * aAtts[aIndex] is the name of that attribute. Otherwise, aIndex michael@0: * is -1 michael@0: * @param aLineNumber the line number of the start tag in the data stream. michael@0: */ michael@0: void HandleStartElement(in wstring aName, michael@0: [array, size_is(aAttsCount)] in wstring aAtts, michael@0: in unsigned long aAttsCount, michael@0: in long aIndex, michael@0: in unsigned long aLineNumber); michael@0: michael@0: /** michael@0: * Called to handle the closing tag of an element. michael@0: * @param aName the fully qualified tagname of the element michael@0: */ michael@0: void HandleEndElement(in wstring aName); michael@0: michael@0: /** michael@0: * Called to handle a comment michael@0: * @param aCommentText the text of the comment (not including the michael@0: * "") michael@0: */ michael@0: void HandleComment(in wstring aCommentText); michael@0: michael@0: /** michael@0: * Called to handle a CDATA section michael@0: * @param aData the text in the CDATA section. This is null-terminated. michael@0: * @param aLength the length of the aData string michael@0: */ michael@0: void HandleCDataSection([size_is(aLength)] in wstring aData, michael@0: in unsigned long aLength); michael@0: michael@0: /** michael@0: * Called to handle the doctype declaration michael@0: */ michael@0: void HandleDoctypeDecl(in AString aSubset, michael@0: in AString aName, michael@0: in AString aSystemId, michael@0: in AString aPublicId, michael@0: in nsISupports aCatalogData); michael@0: michael@0: /** michael@0: * Called to handle character data. Note that this does NOT get michael@0: * called for the contents of CDATA sections. michael@0: * @param aData the data to handle. aData is NOT NULL-TERMINATED. michael@0: * @param aLength the length of the aData string michael@0: */ michael@0: void HandleCharacterData([size_is(aLength)] in wstring aData, michael@0: in unsigned long aLength); michael@0: michael@0: /** michael@0: * Called to handle a processing instruction michael@0: * @param aTarget the PI target (e.g. xml-stylesheet) michael@0: * @param aData all the rest of the data in the PI michael@0: */ michael@0: void HandleProcessingInstruction(in wstring aTarget, michael@0: in wstring aData); michael@0: michael@0: /** michael@0: * Handle the XML Declaration. michael@0: * michael@0: * @param aVersion The version string, can be null if not specified. michael@0: * @param aEncoding The encoding string, can be null if not specified. michael@0: * @param aStandalone -1, 0, or 1 indicating respectively that there was no michael@0: * standalone parameter in the declaration, that it was michael@0: * given as no, or that it was given as yes. michael@0: */ michael@0: void HandleXMLDeclaration(in wstring aVersion, michael@0: in wstring aEncoding, michael@0: in long aStandalone); michael@0: michael@0: /** michael@0: * Ask the content sink if the expat driver should log an error to the console. michael@0: * michael@0: * @param aErrorText Error message to pass to content sink. michael@0: * @param aSourceText Source text of the document we're parsing. michael@0: * @param aError Script error object with line number & column number michael@0: * michael@0: * @retval True if the expat driver should report the error. michael@0: */ michael@0: boolean ReportError(in wstring aErrorText, michael@0: in wstring aSourceText, michael@0: in nsIScriptError aError); michael@0: };