String information

The info attribute returns information about a string and assigns that information to a user variable.

The info attribute must have one of the following (case insensitive) values:

  • LENGTH — the assigned value is the number of Unicode characters in the string.

    The following example shows how to apply an optional compression to content that has a length exceeding 5 characters:

    <set var="MaxLength" value="5" />
    <set var="Length" string="{content}" info="length" />
    <switch>
      <case var="Length" target="{MaxLength}" test="greater">
        <Compress type="desc">{content}</Compress>
     </case>
     <case>{content}</case>
    </switch>
    
  • MEASURE — the assigned value is the minimum horizontal measure required to render the string. The measure is calculated using the current font specification, and is an integer expressed as decipoints (1/10 point).

    The following example shows how to apply an optional compression to content that has a measured width exceeding 35mm:

    <set var="MaxMeas" value="35mm" />
    <set var="DescMeas" string="{content}" info="measure" />
    <switch>
      <case var="DescMeas" target="{MaxMeas}" test="greater">
        <Compress type="desc">{content}</Compress>
     </case>
     <case>{content}</case>
    </switch>
    
  • WORDCOUNT — the assigned value is the number of white space separated words in the string.

    The following example shows how to apply an optional compression to content that contains a single word:

    <set var="Words" string="{content}" info="wordcount" />
    <switch>
      <case var="Words" target="1" >
        <Compress type="desc">{content}</Compress>
     </case>
     <case>{content}</case>
    </switch>
    

Restrictions

The following restrictions apply:

  • All entity references within the string are expanded before processing.

  • A warning will be reported and return a zero result when processing a string that contains structure (tags or custom markers) or is empty. A non-fatal error will be reported if the length of the referenced string exceeds the maximum permitted length for the content of an assigned variable.