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

UTF -8 encoding in XML

Former Member
0 Likes
1,439

Hi all,

I am trying to get XML utf 8 but i get UTF 16.. and we are unable to view the output... i also wrote this:

<xsl:output encoding="UTF-8"/>

but nothing is working here..

can anyone help?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,201

Hi,

Can you try:

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

Best regards,

Leandro Mengue

9 REPLIES 9
Read only

Former Member
0 Likes
1,202

Hi,

Can you try:

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

Best regards,

Leandro Mengue

Read only

0 Likes
1,201

yes i did write the above satemetn... but in my output i am getting UTF-16 only.

Also i am unable to get the output properly.. the tags are not sisplaying in the output...

please see my transformation:

<xsl:template match="/">

<xsl:for-each select ="/it_final">

<it_final>

<ordernr>

<xsl:value-of select="ordernr"/>

<customer>

<xsl:value-of select="customer"/>

</customer>

<destination>

<xsl:value-of select="destination"/>

</destination>

<supplier>

<xsl:value-of select="supplier"/>

</supplier>

<brukare>

<xsl:value-of select="brukare"/>

</brukare>

<source>

<xsl:value-of select="source"/>

</source>

<hu>

<id>

<xsl:value-of select="id"/>

</id>

<type>

<xsl:value-of select="type"/>

</type>

<sortiment>

<xsl:value-of select="sortiment"/>

</sortiment>

<weight>

<xsl:value-of select="weight"/>

</weight>

<volume>

<xsl:value-of select="volume"/>

</volume>

<floorspace>

<xsl:value-of select="floorspace"/>

</floorspace>

<status>

<xsl:value-of select="status"/>

</status>

<workunitid>

<xsl:value-of select="workunitid"/>

</workunitid>

</hu>

<hazmat>

<ununit>

<unnum>

<xsl:value-of select="unnum"/>

</unnum>

<packagetypecode>

<xsl:value-of select="packagetypecode"/>

</packagetypecode>

<unweight>

<xsl:value-of select="unweight"/>

</unweight>

<unvolume>

<xsl:value-of select="unvolume"/>

</unvolume>

<unqty>

<xsl:value-of select="unqty"/>

</unqty>

</ununit>

</hazmat>

</ordernr>

</it_final>

</xsl:for-each>

need your help...

Read only

0 Likes
1,201

ok.. now i used simple transforamtion and i am getting the output as below:

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

- <ORDERNR>

2000286000

<CUSTOMER>0000255411</CUSTOMER>

<DESTINATION>0000255411</DESTINATION>

<SUPPLIER />

<BRUKARE>0</BRUKARE>

<SOURCE>300</SOURCE>

<ID />

<TYPE />

<SORTIMENT />

<WEIGHT>0</WEIGHT>

<VOLUME>0</VOLUME>

<FLOORSPACE />

<STATUS>9</STATUS>

<WORKUNITID>0000000000</WORKUNITID>

<HAZMAT />

<UNNUM />

<PACKAGETYPECODE />

<UNWEIGHT>0</UNWEIGHT>

<UNVOLUME>0</UNVOLUME>

<UNQTY>0</UNQTY>

</ORDERNR>

If we see here... in some places... we can see only the end tag... maybe because there is no value there.... any help here.. where if the value is blank i want the tags to be present... the start tag....

can any one help me here... also the UTF is showing as 16....

Please Please help

Read only

0 Likes
1,201

Hi,

What function you are using to generate the XML?

Can you post a part of your code?

Best regards,

Leandro Mengue

Read only

0 Likes
1,201

Hi,

This code i have written in transformation:

<?sap.transform simple?>

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary">

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

<tt:root name="root"/>

<tt:template>

<tt:loop ref=".root">

<ORDERNR>

<tt:value ref="ordernr"/>

<CUSTOMER>

<tt:value ref="customer"/>

</CUSTOMER>

<DESTINATION>

<tt:value ref="destination"/>

</DESTINATION>

<SUPPLIER>

<tt:value ref="supplier"/>

</SUPPLIER>

<BRUKARE>

<tt:value ref="brukare"/>

</BRUKARE>

<SOURCE>

<tt:value ref="source"/>

</SOURCE>

<ID>

<tt:value ref="id"/>

</ID>

<TYPE>

<tt:value ref="type"/>

</TYPE>

<SORTIMENT>

<tt:value ref="sortiment"/>

</SORTIMENT>

<WEIGHT>

<tt:value ref="weight"/>

</WEIGHT>

<VOLUME>

<tt:value ref="volume"/>

</VOLUME>

<FLOORSPACE>

<tt:value ref="floorspace"/>

</FLOORSPACE>

<STATUS>

<tt:value ref="status"/>

</STATUS>

<WORKUNITID>

<tt:value ref="workunitid"/>

</WORKUNITID>

<HAZMAT>

<tt:value ref="hazmat"/>

</HAZMAT>

<UNNUM>

<tt:value ref="unnum"/>

</UNNUM>

<PACKAGETYPECODE>

<tt:value ref="packagetypecode"/>

</PACKAGETYPECODE>

<UNWEIGHT>

<tt:value ref="unweight"/>

</UNWEIGHT>

<UNVOLUME>

<tt:value ref="unvolume"/>

</UNVOLUME>

<UNQTY>

<tt:value ref="unqty"/>

</UNQTY>

</ORDERNR>

</tt:loop>

</tt:template>

</tt:transform>

and in my prgrm i have written :

CALL TRANSFORMATION ZTEST "ZEWM_DEV_I_004_TRANSFORMATION1

SOURCE root = it_final

RESULT XML xml_string.

these starting tags are not displaying if there is no value in that partivular field....

Please help

Read only

0 Likes
1,201

Hi,

Try this in the tags that you do not want to "compress" when blank:

        <CUSTOMER>

          <tt:cond check="initial(CUSTOMER)">  <tt:text> </tt:text>  </tt:cond>
          
          <tt:value ref="customer"/>
          
        </CUSTOMER>

Best regards,

Leandro Mengue

Read only

0 Likes
1,201

I did this. and it works when i debug the code and see... but when i view it in XML browser.. it again compressess the start tag...

any suggestions?

Read only

0 Likes
1,201

Hi,

This is the normal behavior in XML browser.

If you save to a file you see that it will have the start and end tag (open with notepad).

Best regards,

Leandro Mengue

Read only

0 Likes
1,201

i have saved it in application server.

what are the steps to download it in notepad.. when i download it in html.. its gives me some meta data error.

Please help