02-17-2017 4:38 AM
Hi Experts,
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)
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.
<!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd">
So anyone can guide me how can I add this line to the generated XML.
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=>create
exporting
input = g_xml_string_xstr "(xstring variable with xml)
receiving
conv = lr_conv.
call method lr_conv->read
importing
data = g_xml_string.
"(string variable with xml encoding utf-8)
append g_xml_string to it_xml.
Thanks,
Anuradha.
02-18-2017 2:46 PM
I see these solutions (my system's ABAP version is 7.31):
<xsl:template match="/">
<xsl:text disable-output-escaping="yes"><!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd">;</xsl:text>...
<xsl:output doctype-system="m2Data_Partner.dtd"/>
<xsl:template match="/">
02-18-2017 9:51 AM
02-18-2017 9:51 AM
02-18-2017 2:46 PM
I see these solutions (my system's ABAP version is 7.31):
<xsl:template match="/">
<xsl:text disable-output-escaping="yes"><!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd">;</xsl:text>...
<xsl:output doctype-system="m2Data_Partner.dtd"/>
<xsl:template match="/">
02-18-2017 2:51 PM
Note: instead of basic ABAP string manipulation, I guess it's possible to do it using iXML (class CL_IXML and so on)
02-18-2017 5:22 PM
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.
02-18-2017 6:16 PM
DATA(doctype) = '<!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd">'.
" insert the !DOCTYPE right before the root element (i.e. first < which is not <?)
REPLACE REGEX '(?!<\?)(?=<)' IN g_xml_string WITH doctype.
02-20-2017 5:07 AM
Thank you very much. I replace the string after call transformation.
replace all occurrences of '<?xml version="1.0" encoding="utf-8"?>' in g_xml_string with '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE SdDataSlice SYSTEM "m2Data_Partner.dtd">'.