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: /** michael@0: * Interface for a list of XML attributes. michael@0: * michael@0: * This interface allows access to a list of attributes in michael@0: * three different ways: michael@0: * michael@0: * 1.) by attribute index; michael@0: * 2.) by Namespace-qualified name; or michael@0: * 3.) by XML qualified name. michael@0: * michael@0: * The list will not contain attributes that were declared #IMPLIED michael@0: * but not specified in the start tag. It will also not contain michael@0: * attributes used as Namespace declarations (xmlns*) unless the michael@0: * http://xml.org/sax/features/namespace-prefixes feature michael@0: * is set to true (it is false by default). michael@0: * michael@0: * The order of attributes in the list is unspecified. michael@0: */ michael@0: [scriptable, uuid(e347005e-6cd0-11da-be43-001422106990)] michael@0: interface nsISAXAttributes : nsISupports michael@0: { michael@0: /** michael@0: * Look up the index of an attribute by Namespace name. michael@0: * @param uri The Namespace URI, or the empty string michael@0: * if the name has no Namespace URI. michael@0: * @param localName The attribute's local name. michael@0: * @return The index of the attribute, or -1 michael@0: * if it does not appear in the list. michael@0: */ michael@0: long getIndexFromName(in AString uri, in AString localName); michael@0: michael@0: /** michael@0: * Look up the index of an attribute by XML qualified name. michael@0: * @param qName The qualified name. michael@0: * @return The index of the attribute, or -1 michael@0: * if it does not appear in the list. michael@0: */ michael@0: long getIndexFromQName(in AString qName); michael@0: michael@0: /** michael@0: * Return the number of attributes in the list. Once you know the michael@0: * number of attributes, you can iterate through the list. michael@0: * michael@0: * @return The number of attributes in the list. michael@0: */ michael@0: readonly attribute long length; michael@0: michael@0: /** michael@0: * Look up an attribute's local name by index. michael@0: * @param index The attribute index (zero-based). michael@0: * @return The local name, or null if the index is out of range. michael@0: */ michael@0: AString getLocalName(in unsigned long index); michael@0: michael@0: /** michael@0: * Look up an attribute's XML qualified name by index. michael@0: * @param index The attribute index (zero-based). michael@0: * @return The XML qualified name, or the empty string if none is michael@0: * available, or null if the index is out of range. michael@0: */ michael@0: AString getQName(in unsigned long index); michael@0: michael@0: /** michael@0: * Look up an attribute's type by index. The attribute type is one michael@0: * of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", michael@0: * "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper michael@0: * case). If the parser has not read a declaration for the michael@0: * attribute, or if the parser does not report attribute types, then michael@0: * it must return the value "CDATA" as stated in the XML 1.0 michael@0: * Recommendation (clause 3.3.3, "Attribute-Value michael@0: * Normalization"). For an enumerated attribute that is not a michael@0: * notation, the parser will report the type as "NMTOKEN". michael@0: * michael@0: * @param index The attribute index (zero-based). michael@0: * @return The attribute's type as a string, or null if the index is michael@0: * out of range. michael@0: */ michael@0: AString getType(in unsigned long index); michael@0: michael@0: /** michael@0: * Look up an attribute's type by Namespace name. michael@0: * @param uri The Namespace URI, or the empty string michael@0: * if the name has no Namespace URI. michael@0: * @param localName The attribute's local name. michael@0: * @return The attribute type as a string, or null if the attribute michael@0: * is not in the list. michael@0: */ michael@0: AString getTypeFromName(in AString uri, in AString localName); michael@0: michael@0: /** michael@0: * Look up an attribute's type by XML qualified name. michael@0: * @param qName The qualified name. michael@0: * @return The attribute type as a string, or null if the attribute michael@0: * is not in the list. michael@0: */ michael@0: AString getTypeFromQName(in AString qName); michael@0: michael@0: /** michael@0: * Look up an attribute's Namespace URI by index. michael@0: * @param index The attribute index (zero-based). michael@0: * @return The Namespace URI, or the empty string if none is available, michael@0: * or null if the index is out of range. michael@0: */ michael@0: AString getURI(in unsigned long index); michael@0: michael@0: /** michael@0: * Look up an attribute's value by index. If the attribute value is michael@0: * a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will michael@0: * be concatenated into a single string with each token separated by michael@0: * a single space. michael@0: * michael@0: * @param index The attribute index (zero-based). michael@0: * @return The attribute's value as a string, or null if the index is michael@0: * out of range. michael@0: */ michael@0: AString getValue(in unsigned long index); michael@0: michael@0: /** michael@0: * Look up an attribute's value by Namespace name. If the attribute michael@0: * value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the michael@0: * tokens will be concatenated into a single string with each token michael@0: * separated by a single space. michael@0: * michael@0: * @param uri The Namespace URI, or the empty string michael@0: * if the name has no Namespace URI. michael@0: * @param localName The attribute's local name. michael@0: * @return The attribute's value as a string, or null if the attribute is michael@0: * not in the list. michael@0: */ michael@0: AString getValueFromName(in AString uri, in AString localName); michael@0: michael@0: /** michael@0: * Look up an attribute's value by XML qualified (prefixed) name. michael@0: * If the attribute value is a list of tokens (IDREFS, ENTITIES, or michael@0: * NMTOKENS), the tokens will be concatenated into a single string michael@0: * with each token separated by a single space. michael@0: * michael@0: * @param qName The qualified (prefixed) name. michael@0: * @return The attribute's value as a string, or null if the attribute is michael@0: * not in the list. michael@0: */ michael@0: AString getValueFromQName(in AString qName); michael@0: };