001: package net.sf.saxon.om;
002:
003: /**
004: * AttributeCollection represents the collection of attributes available on a particular element
005: * node. It is modelled on the SAX2 Attributes interface, but is extended firstly to work with
006: * Saxon NamePools, and secondly to provide type information as required by the XPath 2.0 data model.
007: */
008:
009: public interface AttributeCollection {
010:
011: /**
012: * Return the number of attributes in the list.
013: *
014: * @return The number of attributes in the list.
015: */
016:
017: int getLength();
018:
019: /**
020: * Get the namecode of an attribute (by position).
021: *
022: * @param index The position of the attribute in the list.
023: * @return The name code of the attribute, or -1 if there is no attribute at that position.
024: */
025:
026: int getNameCode(int index);
027:
028: /**
029: * Get the type annotation of an attribute (by position).
030: *
031: * @param index The position of the attribute in the list.
032: * @return The type annotation, as the fingerprint of the type name.
033: * The bit {@link net.sf.saxon.om.NodeInfo.IS_DTD_TYPE} represents a DTD-derived type.
034: */
035:
036: int getTypeAnnotation(int index);
037:
038: /**
039: * Get the locationID of an attribute (by position)
040: * @param index The position of the attribute in the list.
041: * @return The location identifier of the attribute. This can be supplied
042: * to a {@link net.sf.saxon.event.LocationProvider} in order to obtain the
043: * actual system identifier and line number of the relevant location
044: */
045:
046: int getLocationId(int index);
047:
048: /**
049: * Get the systemId part of the location of an attribute, at a given index.
050: *
051: * <p>Attribute location information is not available from a SAX parser, so this method
052: * is not useful for getting the location of an attribute in a source document. However,
053: * in a Saxon result document, the location information represents the location in the
054: * stylesheet of the instruction used to generate this attribute, which is useful for
055: * debugging.</p>
056: * @param index the required attribute
057: * @return the systemId of the location of the attribute
058: */
059:
060: String getSystemId(int index);
061:
062: /**
063: * Get the line number part of the location of an attribute, at a given index.
064: *
065: * <p>Attribute location information is not available from a SAX parser, so this method
066: * is not useful for getting the location of an attribute in a source document. However,
067: * in a Saxon result document, the location information represents the location in the
068: * stylesheet of the instruction used to generate this attribute, which is useful for
069: * debugging.</p>
070: * @param index the required attribute
071: * @return the line number of the location of the attribute
072: */
073:
074: int getLineNumber(int index);
075:
076: /**
077: * Get the properties of an attribute (by position)
078: * @param index The position of the attribute in the list.
079: * @return The properties of the attribute. This is a set
080: * of bit-settings defined in class {@link net.sf.saxon.event.ReceiverOptions}. The
081: * most interesting of these is {{@link net.sf.saxon.event.ReceiverOptions#DEFAULTED_ATTRIBUTE},
082: * which indicates an attribute that was added to an element as a result of schema validation.
083: */
084:
085: int getProperties(int index);
086:
087: /**
088: * Get the prefix of the name of an attribute (by position).
089: *
090: * @param index The position of the attribute in the list.
091: * @return The prefix of the attribute name as a string, or null if there
092: * is no attribute at that position. Returns "" for an attribute that
093: * has no prefix.
094: */
095:
096: String getPrefix(int index);
097:
098: /**
099: * Get the lexical QName of an attribute (by position).
100: *
101: * @param index The position of the attribute in the list.
102: * @return The lexical QName of the attribute as a string, or null if there
103: * is no attribute at that position.
104: */
105:
106: String getQName(int index);
107:
108: /**
109: * Get the local name of an attribute (by position).
110: *
111: * @param index The position of the attribute in the list.
112: * @return The local name of the attribute as a string, or null if there
113: * is no attribute at that position.
114: */
115:
116: String getLocalName(int index);
117:
118: /**
119: * Get the namespace URI of an attribute (by position).
120: *
121: * @param index The position of the attribute in the list.
122: * @return The local name of the attribute as a string, or null if there
123: * is no attribute at that position.
124: */
125:
126: String getURI(int index);
127:
128: /**
129: * Get the index of an attribute (by name).
130: *
131: * @param uri The namespace uri of the attribute.
132: * @param localname The local name of the attribute.
133: * @return The index position of the attribute
134: */
135:
136: int getIndex(String uri, String localname);
137:
138: /**
139: * Get the index, given the fingerprint
140: */
141:
142: int getIndexByFingerprint(int fingerprint);
143:
144: /**
145: * Get the attribute value using its fingerprint
146: */
147:
148: String getValueByFingerprint(int fingerprint);
149:
150: /**
151: * Get the value of an attribute (by name).
152: *
153: * @param uri The namespace uri of the attribute.
154: * @param localname The local name of the attribute.
155: * @return The index position of the attribute
156: */
157:
158: public String getValue(String uri, String localname);
159:
160: /**
161: * Get the value of an attribute (by position).
162: *
163: * @param index The position of the attribute in the list.
164: * @return The attribute value as a string, or null if
165: * there is no attribute at that position.
166: */
167:
168: String getValue(int index);
169:
170: /**
171: * Determine whether a given attribute has the is-ID property set
172: */
173:
174: boolean isId(int index);
175: }
176:
177: //
178: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
179: // you may not use this file except in compliance with the License. You may obtain a copy of the
180: // License at http://www.mozilla.org/MPL/
181: //
182: // Software distributed under the License is distributed on an "AS IS" basis,
183: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
184: // See the License for the specific language governing rights and limitations under the License.
185: //
186: // The Original Code is: all this file.
187: //
188: // The Initial Developer of the Original Code is Michael H. Kay.
189: //
190: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
191: //
192: // Contributor(s): none.
193: //
|