GetTextNormalize

Description

Returns the text data contained within a PBDOM_ATTRIBUTE object with surrounding whitespace characters removed and internal whitespace characters replaced by a single space.

Syntax

pbdom_attribute_name.GetTextNormalize()

Argument

Description

pbdom_attribute_name

The name of the PBDOM_ATTRIBUTE


Return value

String.

Examples

  1. The GetTextNormalize method is invoked for the PBDOM_ATTRIBUTE of the following element:

    <abc ATTRIBUTE_1="  My     Attribute   ">

    The GetTextNormalize method returns the following string:

    My Attribute
  2. This example creates a PBDOM_DOCUMENT based on the following DOM tree, which has a Tab character between the words "My" and "Attribute" in the My_Attr attribute, specified by the &#9; entity reference. There are also several space characters:

    <abc  My_Attr="My&#9;Attribute     Value   ">
       <data>Data</data>
    </abc>

    The call to GetAttribute stores My_Attr in pbdom_attr. Calling GetText on pbdom_attr returns the entire string content of My_Attr, including the beginning Tab character. Calling GetTextNormalize returns the string with all surrounding whitespace characters removed, and the whitespace characters between the words, including the Tab character, replaced by a single space.

    PBDOM_BUILDER     pbdombuilder_new
    PBDOM_DOCUMENT    pbdom_doc
    PBDOM_ATTRIBUTE   pbdom_attr
    string strXML = "<abc  My_Attr=~"My&#9;Attribute      Value   ~"><data>Data</data></abc>"
    
    TRY
      pbdombuilder_new = Create PBDOM_Builder
      pbdom_doc = pbdombuilder_new.BuildFromString (strXML)
    
      pbdom_attr = pbdom_doc.GetRootElement(). &
         GetAttribute("My_Attr")
    
      MessageBox ("pbdom_attr text", "[" &
         "+ pbdom_attr.GetText() + "]")
      MessageBox ("pbdom_attr text normalize", "[" &
         "+ pbdom_attr.GetTextNormalize() + "]")
    
      Destroy pbdombuilder_new
      Destroy pbdom_doc
    
      CATCH (PBDOM_Exception except)
       MessageBox ("Exception Occurred", except.Text)
    END TRY
    

Usage

Surrounding whitespace characters are removed from the returned text data, and internal whitespace characters are normalized to a single space. The GetTextNormalize method returns an empty string if no text value exists for the PBDOM_ATTRIBUTE or if the text value contains only whitespace characters.

If this PBDOM_ATTRIBUTE contains any PBDOM_ENTITYREFERENCE objects, the name of the PBDOM_ENTITYREFERENCE object is returned as part of the normalized string.

JDOM does not provide a getTextNormalize method for its Attribute class.

See also

GetText

GetTextTrim

SetText