pdk.flow.xml.XmlCharacterData

contains functions to operate with XML CharacterData variables

This functions are based on Java org.w3c.dom package classes.

https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/package-summary.html

You can always rely on Java documentation and examples!

You can use functions from the pdk.floe.xml.XmlNode package for variables of type CharacterData, as the pdk.net.xml.CharacterData structure extends the pdk.net.xml.Node.

Text strings in the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In the following, the term 16-bit units is used whenever necessary to indicate that indexing on CharacterData is done in 16-bit units.

All functions


appendData

Append the string to the end of the character data of the node. Upon success, data provides access to the concatenation of data and the DOMString specified.

Arguments:

Result:

  • No variable is returned. The input characterData has arg data.

Possible exceptions

Example:

XML Document

<order id="1">
    <book id="b_1">
        Harry Potter and the Philosopher's Stone
    </book>
</order>
attr :: pdk.net.xml.CharacterData = "Harry Potter and the Philosopher's Stone"
arg :: pdk.core.String = " chapter 2"

XmlCharacterData.appendData(attr, arg) :: Void ->
attr = "Harry Potter and the Philosopher's Stone chapter 2"

deleteData

Removes a range of 16-bit units from the node. Upon success, data and length reflect the change.

Arguments:

  • characterData :: pdk.net.xml.CharacterData

  • offset :: pdk.core.Integer - The offset from which to start removing.

  • limit :: pdk.core.Integer - The number of 16-bit units to delete. If the sum of offset and count exceeds length then all 16-bit units from offset to the end of the data are deleted.

Result:

  • No variable is returned. The input characterData has updated value.

Possible exceptions

Example:

XML Document

<order id="1">
    <book id="b_1">
        Harry Potter and the Philosopher's Stone
    </book>
</order>
attr :: pdk.net.xml.CharacterData = "Harry Potter and the Philosopher's Stone"
offset :: pdk.core.Integer = 12
limit :: pdk.core.Integer = 3

XmlCharacterData.deleteData(attr, offset, limit) :: Void ->
attr = "Harry Potter  the Philosopher's Stone"

getData

The character data of the node. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a CharacterData node. However, implementation limits may mean that the entirety of a node's data may not fit into a single DOMString. In such cases, the user may call substringData to retrieve the data in appropriately sized pieces.

Arguments:

Result:

Possible exceptions

  • NullPointerException - throws if the input characterData is NULL

  • DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.

Example:

XML Document

<order id="1">
    <book id="b_1">
        Harry Potter and the Philosopher's Stone
    </book>
</order>
attr :: pdk.net.xml.CharacterData = "Harry Potter and the Philosopher's Stone"

XmlCharacterData.getData(attr) :: pdk.core.String ->
output = "Harry Potter and the Philosopher's Stone"

getLength

The number of 16-bit units that are available through data and the substringData functions below. This may have the value zero, i.e., CharacterData nodes may be empty.

Arguments:

Result:

Possible exceptions

Example:

XML Document

<order id="1">
    <book id="b_1">
        Harry Potter and the Philosopher's Stone
    </book>
</order>
attr :: pdk.net.xml.CharacterData = "Harry Potter and the Philosopher's Stone"

XmlCharacterData.getLength(attr) :: pdk.core.Integer ->
output = 40

insertData

Insert a string at the specified 16-bit unit offset.

Arguments:

Result:

  • No variable is returned. The input characterData has updated value.

Possible exceptions

  • NullPointerException - throws if the input characterData or offset or arg is NULL

  • DOMException - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

Example:

XML Document

<order id="1">
    <book id="b_1">
        Harry Potter and the Philosopher's Stone
    </book>
</order>
attr :: pdk.net.xml.CharacterData = "Harry Potter Philosopher's Stone"
offset :: pdk.core.Integer = 12
arg :: pdk.core.String = "and the "

XmlCharacterData.insertData(attr, offset, arg) :: Void ->
attr = "Harry Potter and the Philosopher's Stone"

replaceData

Replace the characters starting at the specified 16-bit unit offset with the specified string.

Arguments:

  • characterData :: pdk.net.xml.CharacterData

  • offset :: pdk.core.Integer - The offset from which to start replacing.

  • count :: pdk.core.Integer - The number of 16-bit units to replace. If the sum of offset and count exceeds length, then all 16-bit units to the end of the data are replaced; (i.e., the effect is the same as a remove function call with the same range, followed by an appendData function invocation).

  • arg :: pdk.core.String - The DOMString with which the range must be replaced.

Result:

  • No variable is returned. The input characterData has updated value.

Possible exceptions

  • NullPointerException - throws if the input characterData or offset or arg is NULL

  • DOMException - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

Example:

XML Document

<order id="1">
    <book id="b_1">
        Harry Potter and the Philosopher's Stone
    </book>
</order>
attr :: pdk.net.xml.CharacterData = "Harry Potter and the Philosopher's Stone"
offset :: pdk.core.Integer = 21
count :: pdk.core.Integer = 19
arg :: pdk.core.String = "Chamber of Secrets"

XmlCharacterData.replaceData(attr, offset, count, arg) :: Void ->
attr = "Harry Potter and the Chamber of Secrets"

setData

Sets the character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a CharacterData node.

Arguments:

Result:

  • No variable is returned. The input characterData has updated value.

Possible exceptions

Example:

XML Document

<order id="1">
    <book id="b_1">
        Harry Potter and the Philosopher's Stone
    </book>
</order>
attr :: pdk.net.xml.CharacterData = "Harry Potter and the Philosopher's Stone"
data :: pdk.core.String = "Harry Potter and the Chamber of Secrets"

XmlCharacterData.setData(attr, data) :: Void ->
attr = "Harry Potter and the Chamber of Secrets"

substringData

Extracts a range of data from the node.

Arguments:

Result:

  • output :: pdk.core.String - The specified substring. If the sum of offset and count exceeds the length, then all 16-bit units to the end of the data are returned.

Possible exceptions

  • NullPointerException - throws if the input characterData or offset or arg is NULL

  • DOMException - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative. DOMSTRING_SIZE_ERR: Raised if the specified range of text does not fit into a DOMString.

Example:

XML Document

<order id="1">
    <book id="b_1">
        Harry Potter and the Philosopher's Stone
    </book>
</order>
attr :: pdk.net.xml.CharacterData = "Harry Potter and the Philosopher's Stone"
offset :: pdk.core.Integer = 21
count :: pdk.core.Integer = 19

XmlCharacterData.substringData(attr, offset, count) :: pdk.core.String ->
output = "Philosopher's Stone"

Last updated