Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CALL TRANSFORMATION - XSLT encoding not settable?

Former Member
0 Likes
1,234

Hello fellow ABAPer,

I have a problem creating an XML file from an simple itab, using XSLT transformation (CALL TRANSFORMATION).

Here's what I'm doing: I have a simple itab it_person type tt_person:


TYPES: BEGIN OF tt_person,
  id(4) TYPE n,
  firstname(20) TYPE c,
  lastname(20)  TYPE c,
END OF tt_person.

I'm filling it_person with test-data:


gs_person-id   = '1'.
gs_person-firstname = 'John'.
gs_person-lastname  = 'Smith'.
APPEND wa_person TO it_person.

Now I'm getting the reference of my itab for the CALL TRANSFORMATION command and I'm finally doing the actual transformation like this:


CALL TRANSFORMATION z_test_transformation
    SOURCE (it_source_tab)
    RESULT XML it_xml.

The Transformation (XSLT Program) looks like this:

http://uploading.com/files/775c1d31/trans.txt/

(sorry, I tried to post the transformation's code here, but that's not working, it screws the whole formating of this posting, that's why I had to upload it)

When I'm gui_downloading the XML file it looks like this:


<?xml version="1.0" encoding="iso-8859-1"?>
<CUSTOMERS>
  <item>
    <id>1</id>
    <first_name>John</first_name>
    <last_name>Smith</last_name>
  </item>
</CUSTOMERS>

So everything is fine, until now: I need a different encoding, the other system's parser is not able to read ISO-8859-1 encoded files. So I need the first line of my XML to look like this:


<?xml version="1.0" encoding="UTF-8" standalone="no"?>

... and this is where I'm stuck right now, I can't get that to work.

I can change the line in my transformation to:


<xsl:output encoding="uft-8" indent="yes" method="xml" version="1.0" standalone="no"/>

but the resulting XML file is still ISO-8859-1. The "standalone" tag, that I need as well, doesn't work either.

So, what am I doing wrong? Is it not possible to create other XMLs than ISO-8859-1 with the XSLT-Transformation?

Thanks alot, any help would be highly appreciated.

AJ

4 REPLIES 4
Read only

rainer_hbenthal
Active Contributor
0 Likes
674

I guess it_xml is an internal table cotaining chars?

i'm using

xxml                    TYPE xstring,

and

CALL TRANSFORMATION z_abap_to_xml_root
      PARAMETERS mestyp = c_mestyp nsuri = c_namespace
      SOURCE filename = fname table = it_out
      RESULT XML xxml.

and i'm getting the xml encoding like

<?xml version="1.0" encoding="utf-8" ?>

Directly after your transformation insert the following call if your report can run interactively:

CALL FUNCTION 'DISPLAY_XML_STRING'
      EXPORTING
        xml_string            = xxml
*         TITLE                 =
*         STARTING_X            = 5
*         STARTING_Y            = 5
      EXCEPTIONS
        no_xml_document       = 1
        OTHERS                = 2.

This displays the XML so you can check the encoding to be sure that the data is not tempered elsewhere.

Downloading the XML String even if its xstring should be no problem.

Read only

0 Likes
674

Hello Rainer, thanks for taking time to reply.

I guess it_xml is an internal table cotaining chars?

Yes, it's defined as:


DATA it_xml TYPE STANDARD TABLE OF char2048.

I tried what you said:


DATA xxml TYPE xstring.

CALL TRANSFORMATION z_test_transformation
    SOURCE (it_source_tab)
    RESULT XML xxml.

CALL FUNCTION 'DISPLAY_XML_STRING'
      EXPORTING
        xml_string            = xxml
      EXCEPTIONS
        no_xml_document       = 1
        OTHERS                = 2.

Unfortunately it's still ISO...

I don't think it has something to do with the data-declaration of it_xml, maybe something's wrong with the XSLT or the CALL TRANSFORMATION command? I don't know ... but even if that would have worked, I still have to get:


standalone="no"

into that XML.

Another idea? Thanks ...

Read only

0 Likes
674

I never tried an internal table as result, but i noticed that changing xstring to string will change the encoding from UTF-8 to UTF-16, so thats why i suggested this.

Just to make sure, you are on a unicode system?

Read only

0 Likes
674

Just to make sure, you are on a unicode system?

I just asked one of our admins, apparently unicode is disabled here (WebAS 7.0) - so that's why I can't create UTF encoded XML files?

Strangely enough creating UTF-XMLs using the iXML interface is not a problem at all.