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