Search code examples
xpathwso2apache-axisxpath-2.0wso2-esb

Adding a new line to the string


hi am working with wso2esb4.9.0,

I have a service which generates email in that i have property as mailbody which am using to pass as body of the email.

<property name="mailbody"
                   expression="fn:concat('You have received a new Ticket',':','TicketID-',get-property('Ticketid'),', ','TicketDetails-',get-property('Details'))"
                   scope="default"
                   type="STRING"/>

when am passing this property in my service am getting a mail and mail body looks like as shown below.

You have received a new Ticket: TicketID-3021668982752443, TicketDetails-Test ticket details

I want to add a new line in the value so that the mail body can look like below instead of a single line.

You have received a new Ticket: 

TicketID-3021668982752443, 
TicketDetails-Test ticket details

Is there any Xpath function or way to add new line to my string value.

I have tried to include \n and in fn-concat of mailbody property but it is not working.


Solution

  • As the XPath expression is inside of an XML document doing expression="fn:concat('You have received a new Ticket',':&#10;','TicketID-',get-property('Ticketid'),', ','TicketDetails-',get-property('Details'))" should suffice.

    If you really use XPath 2.0 then you can also use expression="fn:concat('You have received a new Ticket',':', codepoints-to-string(10),'TicketID-',get-property('Ticketid'),', ','TicketDetails-',get-property('Details'))".