cancel
Showing results for 
Search instead for 
Did you mean: 

BSP-XML: Encoding Problem

Former Member
0 Kudos

Hi All,

This question may sound out of forum. But I am having one BSP application which takes XML file as a input and transforms into another XML using a XSLT (using SAP XSLT processor). I have used call transformation method for the same which is working fine (i.e.its transforming correctly).

I noticed that the target system accepts XML file only with encoding 16 and the source file comes with encoding ISO.Is anyone aware of setting encoding in XSLT ? I tried to use <xsl:output encoding="UTF-16"/> but I guess SAP XSLT processor does'nt support that.

Thanks in advance.

Rajeev

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi,

the XSLT processor does support xsl:output/@encoding, but refuses to write anything but the system codepage into a STRING. You're able to choose another encoding if you write into an XSTRING.

Instead of using xsl:output, you may also supply an iXML output stream (IF_IXML_OSTREAM) as the transformation result and set an encoding on the stream.

Regards - Karsten

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I don't know if it would work or not but you could have the XSLT processor render its output into a string data type. You could then use the following code to cast to UTF-16 byte string and add the Byte Order Mark.


  data: lapp_type type char30.
****Set the application Type - character set for conversion from string to
****Binary String - Excel Requires UTF-16 with Little Endian
 lapp_type = 'text/unicode; charset=utf-16le'.

****Convert the string to Binary string (UTF-16le)
  call function 'SCMS_STRING_TO_XSTRING'
    exporting
      text     = r_string
      mimetype = lapp_type
    importing
      buffer   = r_xstring.

****Add the UTF-16 Little Endian Byte Order Mark to the begining of the file
  concatenate  cl_abap_char_utilities=>byte_order_mark_little
               r_xstring
               into r_xstring in byte mode.