3 Replies Latest reply on Sep 13, 2005 7:58 AM by charles poulsen - oracle

    padding strings

    charles poulsen - oracle
      does anyone know how i can pad a string using xpath functions?

      i need to pad 3 strings to certain lengths, and concatenate them into one
      before inserting into a field.

      thanks in advance!
      charles poulsen
        • 1. Re: padding strings
          Antony Reynolds-Oracle
          Not pretty but how about

          concat(string1, substring(padding1, string-length(string1)),
          string2, substring(padding2, string-length(string2)),
          string3, substring(padding3, string-length(string3)))

          string1, string2 and string3 would be expressions to the 3 initial strings.
          padding1, padding2, and padding3 would be three strings consisting of the number of padding characters required.

          Then the substring operation would return enough padding characters to make the the length of the string and its padding the same length as the original padding string.

          Of course I may be missing a more elegant solution. I don't consider writing my own XPath function to pad strings elegant!
          • 2. Re: padding strings
            <assign name="AssignConcat">
            <from expression="concat(&quot;Test 1&quot;,&quot;Test 2&quot;,&quot;Test 3&quot;)"/>
            <to variable="varVal"/>
            • 3. Re: padding strings
              charles poulsen - oracle
              thanks for the response..
              at the moment it seems like this is the most elegant solution.

              thanks for the help.