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

XML Schema generation

Former Member
0 Likes
2,270

Hi All,

     AM generating a XML document for a DDIC structure. I am able to generate the XML document but the customer requires the document in a specific format as shown below.

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

<Import xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <Row>

  <License>1234</License>

  <Distribution_Type>I</Distribution_Type>

  </Row>

I have used the Call transformation method by creating a id in TCODE strans. The issue is, the first two lines of the document is as not expected.

How to achieve this ???

The first 2 lines are expected to be

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

<Import xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

but I get the following in my file

<?xml version="1.0" encoding="ISO-8859-1"?>

Regards

Arun

1 ACCEPTED SOLUTION
Read only

AbhishekSharma
Active Contributor
0 Likes
1,421

Hi Arunkumar,

This seems to be because of some special characters, ISO-8859-1” is the Latin-1 (western European languages) encoding.

There is one class available CL_XML_DOCUMENT using which you can set your desired encoding as below:

CREATE OBJECT m_document.

   m_document->CREATE_EMPTY_DOCUMENT( ) .

   m_document->set_encoding( CHARSET = 'UTF-8' ).

If above two not work then try to change any special character like & with &amp; etc.

Below code taken from F1 help of CALL TRANSFORMATION

CALL TRANSFORMATION - transformation_options

Syntax

... OPTIONS [clear              = val]
            [data_refs          = val]
            [initial_components = val]
            [technical_types    = val]
            [value_handling     = val]
           [xml_header         = val] ... .

In OPTIONS of CALL TRANSFORMATION last parameter XML_HEADER

The transformation option xml_header controls the output of the XML header when transforming to XML and writing to a data object of type c, string, or to an internal table.

Possible ValuesMeaning
noNo XML header is output.
without_encodingAn XML header is output without specifying the encoding.
fullDefault setting; an XML header is output, specifying the encoding.

You can try passing this without_encoding option which will not generate any encoding.

Hope this will help.

Thanks-

Abhishek

Let's learn together as much as possible...
CodeInMins
3 REPLIES 3
Read only

AbhishekSharma
Active Contributor
0 Likes
1,422

Hi Arunkumar,

This seems to be because of some special characters, ISO-8859-1” is the Latin-1 (western European languages) encoding.

There is one class available CL_XML_DOCUMENT using which you can set your desired encoding as below:

CREATE OBJECT m_document.

   m_document->CREATE_EMPTY_DOCUMENT( ) .

   m_document->set_encoding( CHARSET = 'UTF-8' ).

If above two not work then try to change any special character like & with &amp; etc.

Below code taken from F1 help of CALL TRANSFORMATION

CALL TRANSFORMATION - transformation_options

Syntax

... OPTIONS [clear              = val]
            [data_refs          = val]
            [initial_components = val]
            [technical_types    = val]
            [value_handling     = val]
           [xml_header         = val] ... .

In OPTIONS of CALL TRANSFORMATION last parameter XML_HEADER

The transformation option xml_header controls the output of the XML header when transforming to XML and writing to a data object of type c, string, or to an internal table.

Possible ValuesMeaning
noNo XML header is output.
without_encodingAn XML header is output without specifying the encoding.
fullDefault setting; an XML header is output, specifying the encoding.

You can try passing this without_encoding option which will not generate any encoding.

Hope this will help.

Thanks-

Abhishek

Let's learn together as much as possible...
CodeInMins
Read only

0 Likes
1,421

Hi Abhishek,

     Thanks for your reply. The default code page in the system is ISO-8859-1.

      I have used the set_encoding method to and now the xml gets generated as below


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

      But, the customer wants it as shown below


     

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

<Import xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


     The first 2 lines should appear as shown above


Regards

Arun

Read only

0 Likes
1,421

Hi Arunkumar,

I checked the Class but could not find any relevant information on standalone = "yes" parameter.

Just curious why client needs this parameter do they use DTD instead of XML schema.

If they do use XML Schema then there is no meaning of defining standalone="yes". The default value for this parameter is "no".

From below second line I understood Client is using XML Schema and not DTD so I dont think you need standalone="yes".

REPLACE FIRST OCCURRENCE OF

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

  IN lv_xml

WITH

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

<Import xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

'.

This could be your final solution REPLACE.

Thanks-

Abhishek

Let's learn together as much as possible...
CodeInMins