CharacterData Interface
The CharacterData interface extends Node with a set of attributes and methods for accessing character data in the DOM.
IDL Definition
Interface CharacterData : Node {
attribute DOMString data;
// raises (DOMException) on setting
// raises (DOMException) on retrieval
readonly attribute unsigned long length;
DOMString substringData(in unsigned long offset,
in unsigned long count)
raises (DOMException);
void appendData(in DONString arg)
raises(DOMException);
void insertData(in unsigned long offset,
in DOMString arg)
raises(DOMException);
void deleteData(in unsigned long offset,
in unsigned long count)
raises (DOMException);
void replaceData(in unsigned long offset,
in unsigned long count,
in DOMString arg)
raises(DOMException);
};
Semantic Requirements
Attributes
- The data attribute is the character data that implements this interface.
- The length attribute contains the number of 16 bit units that are
available through the data attribute and the substringData methods.
Methods
- The substringData(offset,count) method returns the specified substring.
- If the sum of offset and count exceeds length then the
substringData(offset,count) method returns all 16-bit units to the end of the data.
- The appendData(arg) method appends a string to the end of the character data of the node.
- Upon a successful invocation of the appendData(arg) method, the data attribute provides access to the concatenation of data and the specified DOMString.
- The insertData(offset,arg) method inserts a string at the specified 16-bit unit offset.
- The deleteData(offset,count) method remove a range of 16-bit units from the node.
- Upon successful invocation of the deleteData(offset,count) method, the data and length attributes reflect that change.
- If the sum of offset and count exceeds length then all 16-bit units from the offset to the end of the data are deleted.
- The replaceData(offset,count,arg) method replace the characters starting at the specified 16-bit unit offset with the specified string.
- If the sum of offset and count exceeds length then all the 16-bit units to the end of data are replaced.
DOMExceptions
- The data attribute raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
- The appendData(arg) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
- The insertData(offset,arg) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
- The deleteData(offset,count) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
- The replaceData(offset,count,arg) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
- The data attribute raises a DOMSTRING_SIZE_ERR DOMException when it would returns more characters that fit in a DOMString.
- The substringData(offset,count), method raises an INDEX_SIZE_ERR xception if the specified offset is negative
- The substringData(offset,count) method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the number of 16-bit units in the data attribute.
- The substringData(offset,count) method raises an INDEX_SIZE_ERR DOMException if the specified count is negative.
- The deleteData(offset,count), method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative.
- The deleteData(offset,count) method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the number of characters in data.
- The deleteData(offset,count) method raises an INDEX_SIZE_ERR DOMException if the specified count is negative.
- The replaceData(offset,count,arg) method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative.
- The replaceData(offset,count,arg) method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the number of 16-bit units in data.
- The replaceData(offset,count,arg) method raises an INDEX_SIZE_ERR DOMException if the specified count is negative.
- The insertData(offset,arg) method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative.
- The insertData(offset,arg) method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the number of 16-bit units in data.
- The substringData(offset,count) method raises a DOMSTRING_SIZE_ERR DOMException if the specified range of text does not fit into a DOMString.
If you have comments or suggestions, email me at mbrady@nist.gov