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 nsIInputStream; michael@0: interface nsIDOMDocument; michael@0: interface nsIURI; michael@0: interface nsIPrincipal; michael@0: interface nsIScriptGlobalObject; michael@0: michael@0: /** michael@0: * The nsIDOMParser interface is a non-SAX interface that can be used michael@0: * to parse a string or byte stream containing XML or HTML content michael@0: * to a DOM document. Parsing is always synchronous - a document is always michael@0: * returned from the parsing methods. This is as opposed to loading and michael@0: * parsing with the XMLHttpRequest interface, which can be used for michael@0: * asynchronous (callback-based) loading. michael@0: */ michael@0: [scriptable, uuid(5677f36e-1842-4c6f-a39c-2e5576ab8b40)] michael@0: interface nsIDOMParser : nsISupports michael@0: { michael@0: /** michael@0: * The string passed in is parsed into a DOM document. michael@0: * michael@0: * @param str The UTF16 string to be parsed michael@0: * @param contentType The content type of the string (see parseFromStream) michael@0: * @returns The DOM document created as a result of parsing the michael@0: * string michael@0: */ michael@0: nsIDOMDocument parseFromString(in wstring str, in string contentType); michael@0: michael@0: /** michael@0: * The buffer is parsed into a DOM document. michael@0: * The charset is determined from the xml entity decl. michael@0: * michael@0: * @param buf The octet array data to be parsed michael@0: * @param bufLen Length (in bytes) of the data michael@0: * @param contentType The content type of the data (see parseFromStream) michael@0: * @returns The DOM document created as a result of parsing the michael@0: * string michael@0: */ michael@0: nsIDOMDocument parseFromBuffer([const,array,size_is(bufLen)] in octet buf, michael@0: in uint32_t bufLen, in string contentType); michael@0: michael@0: /** michael@0: * The byte stream passed in is parsed into a DOM document. michael@0: * michael@0: * Not accessible from web content. michael@0: * michael@0: * @param stream The byte stream whose contents are parsed michael@0: * @param charset The character set that was used to encode the byte michael@0: * stream. NULL if not specified. michael@0: * @param contentLength The number of bytes in the input stream. michael@0: * @param contentType The content type of the string - either text/xml, michael@0: * application/xml, or application/xhtml+xml. michael@0: * Must not be NULL. michael@0: * @returns The DOM document created as a result of parsing the michael@0: * stream michael@0: */ michael@0: nsIDOMDocument parseFromStream(in nsIInputStream stream, michael@0: in string charset, michael@0: in long contentLength, michael@0: in string contentType); michael@0: michael@0: /** michael@0: * Initialize the principal and document and base URIs that the parser should michael@0: * use for documents it creates. If this is not called, then a null michael@0: * principal and its URI will be used. When creating a DOMParser via the JS michael@0: * constructor, this will be called automatically. This method may only be michael@0: * called once. If this method fails, all following parse attempts will michael@0: * fail. michael@0: * michael@0: * @param principal The principal to use for documents we create. michael@0: * If this is null, a codebase principal will be created michael@0: * based on documentURI; in that case the documentURI must michael@0: * be non-null. michael@0: * @param documentURI The documentURI to use for the documents we create. michael@0: * If null, the principal's URI will be used; michael@0: * in that case, the principal must be non-null and its michael@0: * URI must be non-null. michael@0: * @param baseURI The baseURI to use for the documents we create. michael@0: * If null, the documentURI will be used. michael@0: * @param scriptObject The object from which the context for event handling michael@0: * can be got. michael@0: */ michael@0: [noscript] void init(in nsIPrincipal principal, michael@0: in nsIURI documentURI, michael@0: in nsIURI baseURI, michael@0: in nsIScriptGlobalObject scriptObject); michael@0: }; michael@0: michael@0: %{ C++ michael@0: #define NS_DOMPARSER_CID \ michael@0: { /* 3a8a3a50-512c-11d4-9a54-000064657374 */ \ michael@0: 0x3a8a3a50, 0x512c, 0x11d4, \ michael@0: {0x9a, 0x54, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} } michael@0: #define NS_DOMPARSER_CONTRACTID \ michael@0: "@mozilla.org/xmlextras/domparser;1" michael@0: %}