cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error in groovy script - The entity "nbsp" was referenced, but not declared

nidhi_srivastava22
Active Contributor
0 Kudos
441

Hi Experts,

I have used a script which was running fine but suddenly there is an error seen as mentioned below-

 
Error Details
com.sap.xi.mapping.camel.XiMappingException: The entity "nbsp" was referenced, but not declared., cause: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 200; The entity "nbsp" was referenced, but not declared.
 
On checking the payload I can see a &nbsp character seen in the input which is causing the error.
Input Payload
<?xml version="1.0" encoding="UTF-8"?>
<ServiceNowIncident>
    <Incident>
        <ADONumber>40000</ADONumber>
        <State></State>
        <AssignedTo></AssignedTo>
        <AdditionalComments>SRIVASTAVA Nidhi (External) Hello Laurent, thank you for sharing the examples. We are investigating and come back to you with the solution.&nbsp;Best regards, Val</AdditionalComments>
    </Incident>
</ServiceNowIncident>
 
The groovy used is mentioned in the below blog, bit different but more or less the same. 
 
Please suggest if this can be achieved easily, as there are already many conditions checked in the script and adding more should not hamper the existing one as this is already running in production.
 
Thanks,
Nidhi Srivastava
 

Accepted Solutions (1)

Accepted Solutions (1)

Andrzej_Filusz
Contributor
0 Kudos

Hello,

You can add the following lines to your code:

    // Get the body of the message as a String
    def body = message.getBody(String)

    // the below code solves the non-breaking space issue
    String nbspHTML = '&nbsp;'
    String nbspXML = '&#160;'
    body = ((String)body).replaceAll(nbspHTML, nbspXML)

BR,

Andrzej

Answers (0)