1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6#include "nsISupports.idl" 7interface nsIScriptError; 8 9/** 10 * This interface should be implemented by any content sink that wants 11 * to get output from expat and do something with it; in other words, 12 * by any sink that handles some sort of XML dialect. 13 */ 14 15[scriptable, uuid(01f681af-0f22-4725-a914-0d396114daf0)] 16interface nsIExpatSink : nsISupports 17{ 18 /** 19 * Called to handle the opening tag of an element. 20 * @param aName the fully qualified tagname of the element 21 * @param aAtts the array of attribute names and values. There are 22 * aAttsCount/2 names and aAttsCount/2 values, so the total number of 23 * elements in the array is aAttsCount. The names and values 24 * alternate. Thus, if we number attributes starting with 0, 25 * aAtts[2*k] is the name of the k-th attribute and aAtts[2*k+1] is 26 * the value of that attribute Both explicitly specified attributes 27 * and attributes that are defined to have default values in a DTD are 28 * present in aAtts. 29 * @param aAttsCount the number of elements in aAtts. 30 * @param aLineNumber the line number of the start tag in the data stream. 31 */ 32 void HandleStartElement(in wstring aName, 33 [array, size_is(aAttsCount)] in wstring aAtts, 34 in unsigned long aAttsCount, 35 in unsigned long aLineNumber); 36 37 /** 38 * Called to handle the closing tag of an element. 39 * @param aName the fully qualified tagname of the element 40 */ 41 void HandleEndElement(in wstring aName); 42 43 /** 44 * Called to handle a comment 45 * @param aCommentText the text of the comment (not including the 46 * "<!--" and "-->") 47 */ 48 void HandleComment(in wstring aCommentText); 49 50 /** 51 * Called to handle a CDATA section 52 * @param aData the text in the CDATA section. This is null-terminated. 53 * @param aLength the length of the aData string 54 */ 55 void HandleCDataSection([size_is(aLength)] in wstring aData, 56 in unsigned long aLength); 57 58 /** 59 * Called to handle the doctype declaration 60 */ 61 void HandleDoctypeDecl(in AString aSubset, 62 in AString aName, 63 in AString aSystemId, 64 in AString aPublicId, 65 in nsISupports aCatalogData); 66 67 /** 68 * Called to handle character data. Note that this does NOT get 69 * called for the contents of CDATA sections. 70 * @param aData the data to handle. aData is NOT NULL-TERMINATED. 71 * @param aLength the length of the aData string 72 */ 73 void HandleCharacterData([size_is(aLength)] in wstring aData, 74 in unsigned long aLength); 75 76 /** 77 * Called to handle a processing instruction 78 * @param aTarget the PI target (e.g. xml-stylesheet) 79 * @param aData all the rest of the data in the PI 80 */ 81 void HandleProcessingInstruction(in wstring aTarget, 82 in wstring aData); 83 84 /** 85 * Handle the XML Declaration. 86 * 87 * @param aVersion The version string, can be null if not specified. 88 * @param aEncoding The encoding string, can be null if not specified. 89 * @param aStandalone -1, 0, or 1 indicating respectively that there was no 90 * standalone parameter in the declaration, that it was 91 * given as no, or that it was given as yes. 92 */ 93 void HandleXMLDeclaration(in wstring aVersion, 94 in wstring aEncoding, 95 in long aStandalone); 96 97 /** 98 * Ask the content sink if the expat driver should log an error to the console. 99 * 100 * @param aErrorText Error message to pass to content sink. 101 * @param aSourceText Source text of the document we're parsing. 102 * @param aError Script error object with line number & column number 103 * 104 * @retval True if the expat driver should report the error. 105 */ 106 boolean ReportError(in wstring aErrorText, 107 in wstring aSourceText, 108 in nsIScriptError aError); 109}; 110