<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DOCTYPE Declaration in XML when Transformation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323821#M5010</link>
    <description>&lt;P&gt;I see these solutions (my system's ABAP version is 7.31):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you use a Simple Transformation (&amp;lt;tt:...&amp;gt;), then I couldn't succeed using the transformation itself, nor with sXML (both seem to be able to work only on classic XML element nodes). So I guess the only way is to insert the DTD (&amp;lt;!DOCTYPE...&amp;gt;) to the string after the transformation (using a classic ABAP string manipulation).&lt;/LI&gt;&lt;LI&gt;If you use a XSLT (&amp;lt;xsl:...&amp;gt;), then I could only do it via the transformation and using CALL TRANSFORMATION ... RESULT XML string (it didn't work with RESULT XML sXMLwriter) using the solution mentioned in &lt;A href="http://stackoverflow.com/questions/3387127/set-html5-doctype-with-xslt"&gt;http://stackoverflow.com/questions/3387127/set-html5-doctype-with-xslt&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Solution 1, using XSLT + xsl:text :&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xsl:template match="/"&amp;gt;
  &amp;lt;xsl:text disable-output-escaping="yes"&amp;gt;&amp;lt;!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd"&amp;gt;;&amp;lt;/xsl:text&amp;gt;...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;Solution 2, using XSLT + xsl:output : if your transformation generates root element "SdDataSlice", then you may also use &amp;lt;xsl:output doctype-system"m2Data_Partner.dtd"/&amp;gt; (note: &amp;lt;xsl:output type="SdDataSlice" is useless because it's always superseded with the target root element): &lt;/LI&gt;&lt;LI&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xsl:output doctype-system="m2Data_Partner.dtd"/&amp;gt;
&amp;lt;xsl:template match="/"&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Sat, 18 Feb 2017 14:46:35 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2017-02-18T14:46:35Z</dc:date>
    <item>
      <title>DOCTYPE Declaration in XML when Transformation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323818#M5007</link>
      <description>&lt;P&gt;Hi Experts, &lt;/P&gt;&lt;P&gt;This is regarding XML generating from ABAP. I'm Trying to convert the Outbound Delivery ( Advice Note ) to a XML file. For that I'm using STRANS Transaction and to create my XML format using a my Defined structure from SE11 (ZSSDPACK_XML)&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/21055-structure.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/21056-strans.jpg" /&gt;&lt;/P&gt;&lt;P&gt;Then I'm using bellow code segment to generate this XML to utf-8 format. For this I want to add this line to XML.&lt;/P&gt;&lt;P&gt;&amp;lt;!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd"&amp;gt;&lt;/P&gt;&lt;P&gt;So anyone can guide me how can I add this line to the generated XML.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  refresh it_xml.
  call transformation zsd_packing_xml
  source sddataslice = it_final
  result xml g_xml_string_xstr.

  data lr_conv type ref to cl_abap_conv_in_ce.

  call method cl_abap_conv_in_ce=&amp;gt;create
    exporting
      input = g_xml_string_xstr "(xstring variable with xml)
    receiving
      conv  = lr_conv.

  call method lr_conv-&amp;gt;read
    importing
      data = g_xml_string.
  "(string variable with xml encoding utf-8)
  append g_xml_string to it_xml.


Thanks,
Anuradha.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Feb 2017 04:38:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323818#M5007</guid>
      <dc:creator>anuradha_wijesinghe</dc:creator>
      <dc:date>2017-02-17T04:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: DOCTYPE Declaration in XML when Transformation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323819#M5008</link>
      <description>&lt;P&gt;Can anyone help me please ?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 09:51:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323819#M5008</guid>
      <dc:creator>anuradha_wijesinghe</dc:creator>
      <dc:date>2017-02-18T09:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: DOCTYPE Declaration in XML when Transformation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323820#M5009</link>
      <description>&lt;P&gt;Can anyone help me please ?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 09:51:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323820#M5009</guid>
      <dc:creator>anuradha_wijesinghe</dc:creator>
      <dc:date>2017-02-18T09:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: DOCTYPE Declaration in XML when Transformation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323821#M5010</link>
      <description>&lt;P&gt;I see these solutions (my system's ABAP version is 7.31):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you use a Simple Transformation (&amp;lt;tt:...&amp;gt;), then I couldn't succeed using the transformation itself, nor with sXML (both seem to be able to work only on classic XML element nodes). So I guess the only way is to insert the DTD (&amp;lt;!DOCTYPE...&amp;gt;) to the string after the transformation (using a classic ABAP string manipulation).&lt;/LI&gt;&lt;LI&gt;If you use a XSLT (&amp;lt;xsl:...&amp;gt;), then I could only do it via the transformation and using CALL TRANSFORMATION ... RESULT XML string (it didn't work with RESULT XML sXMLwriter) using the solution mentioned in &lt;A href="http://stackoverflow.com/questions/3387127/set-html5-doctype-with-xslt"&gt;http://stackoverflow.com/questions/3387127/set-html5-doctype-with-xslt&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Solution 1, using XSLT + xsl:text :&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xsl:template match="/"&amp;gt;
  &amp;lt;xsl:text disable-output-escaping="yes"&amp;gt;&amp;lt;!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd"&amp;gt;;&amp;lt;/xsl:text&amp;gt;...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;Solution 2, using XSLT + xsl:output : if your transformation generates root element "SdDataSlice", then you may also use &amp;lt;xsl:output doctype-system"m2Data_Partner.dtd"/&amp;gt; (note: &amp;lt;xsl:output type="SdDataSlice" is useless because it's always superseded with the target root element): &lt;/LI&gt;&lt;LI&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xsl:output doctype-system="m2Data_Partner.dtd"/&amp;gt;
&amp;lt;xsl:template match="/"&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Sat, 18 Feb 2017 14:46:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323821#M5010</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2017-02-18T14:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: DOCTYPE Declaration in XML when Transformation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323822#M5011</link>
      <description>&lt;P&gt;Note: instead of basic ABAP string manipulation, I guess it's possible to do it using iXML (class CL_IXML and so on)&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 14:51:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323822#M5011</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2017-02-18T14:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: DOCTYPE Declaration in XML when Transformation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323823#M5012</link>
      <description>&lt;P&gt;Thanks for the Reply. But I'm still having a doubt about this since I'm not much experienced XML, and i have not use XSLT, can u simplify this please.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 17:22:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323823#M5012</guid>
      <dc:creator>anuradha_wijesinghe</dc:creator>
      <dc:date>2017-02-18T17:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: DOCTYPE Declaration in XML when Transformation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323824#M5013</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;DATA(doctype) = '&amp;lt;!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd"&amp;gt;'.

" insert the !DOCTYPE right before the root element (i.e. first &amp;lt; which is not &amp;lt;?)&lt;BR /&gt;REPLACE REGEX '(?!&amp;lt;\?)(?=&amp;lt;)' IN g_xml_string WITH doctype.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Feb 2017 18:16:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323824#M5013</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2017-02-18T18:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: DOCTYPE Declaration in XML when Transformation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323825#M5014</link>
      <description>&lt;P&gt;Thank you very much. I replace the string after call transformation.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;replace all occurrences of '&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;' in g_xml_string with '&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&amp;lt;!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd"&amp;gt;'.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Feb 2017 05:07:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doctype-declaration-in-xml-when-transformation/m-p/323825#M5014</guid>
      <dc:creator>anuradha_wijesinghe</dc:creator>
      <dc:date>2017-02-20T05:07:10Z</dc:date>
    </item>
  </channel>
</rss>

