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

  1. The data attribute is the character data that implements this interface.
  2. The length attribute contains the number of 16 bit units that are available through the data attribute and the substringData methods.
  3. Methods

  4. The substringData(offset,count) method returns the specified substring.
  5. 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.
  6. The appendData(arg) method appends a string to the end of the character data of the node.
  7. Upon a successful invocation of the appendData(arg) method, the data attribute provides access to the concatenation of data and the specified DOMString.
  8. The insertData(offset,arg) method inserts a string at the specified 16-bit unit offset.
  9. The deleteData(offset,count) method remove a range of 16-bit units from the node.
  10. Upon successful invocation of the deleteData(offset,count) method, the data and length attributes reflect that change.
  11. 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.
  12. The replaceData(offset,count,arg) method replace the characters starting at the specified 16-bit unit offset with the specified string.
  13. If the sum of offset and count exceeds length then all the 16-bit units to the end of data are replaced.
  14. DOMExceptions

  15. The data attribute raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
  16. The appendData(arg) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
  17. The insertData(offset,arg) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
  18. The deleteData(offset,count) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
  19. The replaceData(offset,count,arg) method raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
  20. The data attribute raises a DOMSTRING_SIZE_ERR DOMException when it would returns more characters that fit in a DOMString.
  21. The substringData(offset,count), method raises an INDEX_SIZE_ERR xception if the specified offset is negative
  22. 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.
  23. The substringData(offset,count) method raises an INDEX_SIZE_ERR DOMException if the specified count is negative.
  24. The deleteData(offset,count), method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative.
  25. The deleteData(offset,count) method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the number of characters in data.
  26. The deleteData(offset,count) method raises an INDEX_SIZE_ERR DOMException if the specified count is negative.
  27. The replaceData(offset,count,arg) method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative.
  28. 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.
  29. The replaceData(offset,count,arg) method raises an INDEX_SIZE_ERR DOMException if the specified count is negative.
  30. The insertData(offset,arg) method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative.
  31. 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.
  32. The substringData(offset,count) method raises a DOMSTRING_SIZE_ERR DOMException if the specified range of text does not fit into a DOMString.

  33. If you have comments or suggestions, email me at mbrady@nist.gov