3 Replies Latest reply on Sep 3, 2021 5:59 AM by Nico Heinze

    XMLW_31205 ... character that cannot be written to a valid XML file

    Alessandro Corti Seasoned Veteran

      POWERCENTER 10.4.0

       

      Sometime my mapping with an XML Target fails with the following error:

       

      XMLW_31205 failed to validate element value contains a character that cannot be written to a valid XML file

       

      Everytime there is that error, I can find a special character that element that I have to remove.

       

      I would like to trim all the special characters that "cannot be written to a valid XML file"

       

      Where is that list?

        • 1. Re: XMLW_31205 ... character that cannot be written to a valid XML file
          Lekha G M Active Member

          Hi,

           

          Please check if the following KB article helps:
          Support

          Thanks,

          Lekha

          1 of 1 people found this helpful
          • 2. Re: XMLW_31205 ... character that cannot be written to a valid XML file
            Alessandro Corti Seasoned Veteran

            It seems that the set of characters that cannot be written to a valid XML file is smaller than the set of characters matched by the regular expression [^[:print:]].

             

            For example,

            - the TAB character is matched with the [^[:print:]] but it can be written in a valid XML

             

            - the   (U+001A) cannot be written in a valid XML and it is matched with [^[:print:]]

             

            • 3. Re: XMLW_31205 ... character that cannot be written to a valid XML file
              Nico Heinze Guru

              As long as you can identify a "safe set" of characters, there is a way. A little complicated at first glance, but it works like a charm.

               

              Let's assume you have an EXP where you set up a variable port v_valid_chars of type String. This variable port must contain all valid characters that can be written to a XML target file. Havily simplified this character list contains all letters A-Z and a-z, the digits 0-9, and most of the ASCII special characters (like comma, dot, and so on).

               

              Now you have some input port in_Value which may or may not contain "dirty" characters which you want to remove. Do it this way:

               

              Below v_valid_chars, set up a variable port v_dirty of type String with this expression:

                ReplaceChr( 1, in_Value, v_valid_chars, '')

              Now set up an output port out_Value of type String with this expression:

                ReplaceChr( 1, In_Value, v_dirty, '')

               

              This way the variable port v_dirty will contain all "dirty" characters from the current input string.

              Then the output port will deliver all characters from the input value without the dirty characters.

               

              Once more thanks a million to Kieran for this great trick. You were and are a source of inspiration.

               

              Regards,

              Nico