I am getting error "Invalid XML input: Character reference &#x1a is an invalid XML character" while

satyabratasatyabrata Posts: 4

Hi All,

I need the data to stored in xml data bank , so that i can compare with REST response.

The query is running fine without xml databank and giving the invalid xml error after adding the result as XML databank.

Please let me know how to fix this issue.

satyabrata Das


  • OmarROmarR Posts: 224 admin

    Hello Satyabrata,

    Do you see the same error after enabling the "Encode XML characters" option in your DB tool?
    See the following:

  • benken_parasoftbenken_parasoft Posts: 890 ✭✭✭

    &#x1a is a control character. Control characters are illegal in XML 1.0. Control characters, aside from the null character, are legal in XML 1.1 when expressed as a character reference. You may have to modify the XML prior to sending it to the data bank, either stripping "&#x1a" or modifying the XML version in the prolog from 1.0 to 1.1.

  • OmarROmarR Posts: 224 admin

    In XML 1.0, control characters and characters out of the Unicode ranges are not allowed. However, control characters are allowed in XML 1.1, but are discouraged.
    See https://stackoverflow.com/a/28152666 for more information on this.

    As @benken_parasoft stated above, You can modify the XML prior to passing it though the databank. You can do this by chaining an extension tool to the DB tool to remove the illegal characters OR change the XML version="1.0" to version="1.1.".
    The setup would look like the following:

    Below is a groovy script to do this.

    import com.parasoft.api.*;
    public String Replace(Object data){
    data = data.toString().replaceAll("", "");
    //data = data.toString().replaceAll("version=\"1.0\"", "version=\"1.1\"");
    return data.toString();
  • satyabratasatyabrata Posts: 4
    edited January 2018

    Thank you,Still I am not getting the results in XML databank and getting error Invalid XML input: Content is not allowed in prolog.

    Please let me know how to proceed

  • benken_parasoftbenken_parasoft Posts: 890 ✭✭✭
    edited January 2018

    Thank you,Still I am not getting the results in XML databank and getting error Invalid XML input: Content is not allowed in prolog.

    The suggestion from Omar is correct. Please keep in mind that his example is stripping out one particular illegal entity reference. There may be others you also need to strip out. Alternatively, you can consider modifying the script to change the XML version from 1.0 to 1.1 (the line Omar has commented out). You might also consider contacting Parasoft Support if you are having trouble implementing his suggestion.

    To clarify, the behavior in question is a known limitation with the XML output from the DB Tool, where it may build entity references that are illegal for XML 1.0. In other areas of the product we automatically strip out illegal control characters as opposed to building illegal entity references. For now, I recommend following Omar's description for how to strip out the illegal control characters with a script prior to sending the output to the Data Bank.

Sign In or Register to comment.