Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | /** |
michael@0 | 9 | * Interface for a list of XML attributes. |
michael@0 | 10 | * |
michael@0 | 11 | * This interface allows access to a list of attributes in |
michael@0 | 12 | * three different ways: |
michael@0 | 13 | * |
michael@0 | 14 | * 1.) by attribute index; |
michael@0 | 15 | * 2.) by Namespace-qualified name; or |
michael@0 | 16 | * 3.) by XML qualified name. |
michael@0 | 17 | * |
michael@0 | 18 | * The list will not contain attributes that were declared #IMPLIED |
michael@0 | 19 | * but not specified in the start tag. It will also not contain |
michael@0 | 20 | * attributes used as Namespace declarations (xmlns*) unless the |
michael@0 | 21 | * http://xml.org/sax/features/namespace-prefixes feature |
michael@0 | 22 | * is set to true (it is false by default). |
michael@0 | 23 | * |
michael@0 | 24 | * The order of attributes in the list is unspecified. |
michael@0 | 25 | */ |
michael@0 | 26 | [scriptable, uuid(e347005e-6cd0-11da-be43-001422106990)] |
michael@0 | 27 | interface nsISAXAttributes : nsISupports |
michael@0 | 28 | { |
michael@0 | 29 | /** |
michael@0 | 30 | * Look up the index of an attribute by Namespace name. |
michael@0 | 31 | * @param uri The Namespace URI, or the empty string |
michael@0 | 32 | * if the name has no Namespace URI. |
michael@0 | 33 | * @param localName The attribute's local name. |
michael@0 | 34 | * @return The index of the attribute, or -1 |
michael@0 | 35 | * if it does not appear in the list. |
michael@0 | 36 | */ |
michael@0 | 37 | long getIndexFromName(in AString uri, in AString localName); |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * Look up the index of an attribute by XML qualified name. |
michael@0 | 41 | * @param qName The qualified name. |
michael@0 | 42 | * @return The index of the attribute, or -1 |
michael@0 | 43 | * if it does not appear in the list. |
michael@0 | 44 | */ |
michael@0 | 45 | long getIndexFromQName(in AString qName); |
michael@0 | 46 | |
michael@0 | 47 | /** |
michael@0 | 48 | * Return the number of attributes in the list. Once you know the |
michael@0 | 49 | * number of attributes, you can iterate through the list. |
michael@0 | 50 | * |
michael@0 | 51 | * @return The number of attributes in the list. |
michael@0 | 52 | */ |
michael@0 | 53 | readonly attribute long length; |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * Look up an attribute's local name by index. |
michael@0 | 57 | * @param index The attribute index (zero-based). |
michael@0 | 58 | * @return The local name, or null if the index is out of range. |
michael@0 | 59 | */ |
michael@0 | 60 | AString getLocalName(in unsigned long index); |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Look up an attribute's XML qualified name by index. |
michael@0 | 64 | * @param index The attribute index (zero-based). |
michael@0 | 65 | * @return The XML qualified name, or the empty string if none is |
michael@0 | 66 | * available, or null if the index is out of range. |
michael@0 | 67 | */ |
michael@0 | 68 | AString getQName(in unsigned long index); |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * Look up an attribute's type by index. The attribute type is one |
michael@0 | 72 | * of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", |
michael@0 | 73 | * "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper |
michael@0 | 74 | * case). If the parser has not read a declaration for the |
michael@0 | 75 | * attribute, or if the parser does not report attribute types, then |
michael@0 | 76 | * it must return the value "CDATA" as stated in the XML 1.0 |
michael@0 | 77 | * Recommendation (clause 3.3.3, "Attribute-Value |
michael@0 | 78 | * Normalization"). For an enumerated attribute that is not a |
michael@0 | 79 | * notation, the parser will report the type as "NMTOKEN". |
michael@0 | 80 | * |
michael@0 | 81 | * @param index The attribute index (zero-based). |
michael@0 | 82 | * @return The attribute's type as a string, or null if the index is |
michael@0 | 83 | * out of range. |
michael@0 | 84 | */ |
michael@0 | 85 | AString getType(in unsigned long index); |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * Look up an attribute's type by Namespace name. |
michael@0 | 89 | * @param uri The Namespace URI, or the empty string |
michael@0 | 90 | * if the name has no Namespace URI. |
michael@0 | 91 | * @param localName The attribute's local name. |
michael@0 | 92 | * @return The attribute type as a string, or null if the attribute |
michael@0 | 93 | * is not in the list. |
michael@0 | 94 | */ |
michael@0 | 95 | AString getTypeFromName(in AString uri, in AString localName); |
michael@0 | 96 | |
michael@0 | 97 | /** |
michael@0 | 98 | * Look up an attribute's type by XML qualified name. |
michael@0 | 99 | * @param qName The qualified name. |
michael@0 | 100 | * @return The attribute type as a string, or null if the attribute |
michael@0 | 101 | * is not in the list. |
michael@0 | 102 | */ |
michael@0 | 103 | AString getTypeFromQName(in AString qName); |
michael@0 | 104 | |
michael@0 | 105 | /** |
michael@0 | 106 | * Look up an attribute's Namespace URI by index. |
michael@0 | 107 | * @param index The attribute index (zero-based). |
michael@0 | 108 | * @return The Namespace URI, or the empty string if none is available, |
michael@0 | 109 | * or null if the index is out of range. |
michael@0 | 110 | */ |
michael@0 | 111 | AString getURI(in unsigned long index); |
michael@0 | 112 | |
michael@0 | 113 | /** |
michael@0 | 114 | * Look up an attribute's value by index. If the attribute value is |
michael@0 | 115 | * a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will |
michael@0 | 116 | * be concatenated into a single string with each token separated by |
michael@0 | 117 | * a single space. |
michael@0 | 118 | * |
michael@0 | 119 | * @param index The attribute index (zero-based). |
michael@0 | 120 | * @return The attribute's value as a string, or null if the index is |
michael@0 | 121 | * out of range. |
michael@0 | 122 | */ |
michael@0 | 123 | AString getValue(in unsigned long index); |
michael@0 | 124 | |
michael@0 | 125 | /** |
michael@0 | 126 | * Look up an attribute's value by Namespace name. If the attribute |
michael@0 | 127 | * value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the |
michael@0 | 128 | * tokens will be concatenated into a single string with each token |
michael@0 | 129 | * separated by a single space. |
michael@0 | 130 | * |
michael@0 | 131 | * @param uri The Namespace URI, or the empty string |
michael@0 | 132 | * if the name has no Namespace URI. |
michael@0 | 133 | * @param localName The attribute's local name. |
michael@0 | 134 | * @return The attribute's value as a string, or null if the attribute is |
michael@0 | 135 | * not in the list. |
michael@0 | 136 | */ |
michael@0 | 137 | AString getValueFromName(in AString uri, in AString localName); |
michael@0 | 138 | |
michael@0 | 139 | /** |
michael@0 | 140 | * Look up an attribute's value by XML qualified (prefixed) name. |
michael@0 | 141 | * If the attribute value is a list of tokens (IDREFS, ENTITIES, or |
michael@0 | 142 | * NMTOKENS), the tokens will be concatenated into a single string |
michael@0 | 143 | * with each token separated by a single space. |
michael@0 | 144 | * |
michael@0 | 145 | * @param qName The qualified (prefixed) name. |
michael@0 | 146 | * @return The attribute's value as a string, or null if the attribute is |
michael@0 | 147 | * not in the list. |
michael@0 | 148 | */ |
michael@0 | 149 | AString getValueFromQName(in AString qName); |
michael@0 | 150 | }; |