Simple Transformations: How deserialize xmlns attributes?
Hello all,
during deserializing Simple Transformations ignore surplus attributes in the xml input stream. With one exception: u201Exmlnsu201C (namespace) attributes apparently are not ignored.
Take for example the xml file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CITIES someattribute="XYZ">
<CITY>Hamburg</CITY>
<CITY>Berlin</CITY>
</CITIES>
This file can be processed successfully by the simple transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="CITIES"></tt:root>
<tt:template>
<CITIES>
<tt:loop ref="CITIES">
<CITY tt:value-ref="CITY"></CITY>
</tt:loop>
</CITIES>
</tt:template>
</tt:transform>
When trying to process the following xml file by the same transformation, however, a CX_ST_MATCH_ELEMENT error is thrown.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CITIES xmlns="XYZ">
<CITY>Hamburg</CITY>
<CITY>Berlin</CITY>
</CITIES>
How can xmlns attributes be deserialized (ignored) with simple transformations?
Thanks for any hint!
Simon
PS:
To reproduce the error the following ABAP can be used in combination with the quoted simple transformation:
REPORT ztestsd13.
TYPES: BEGIN OF lty_cities,
city(20) TYPE c,
END OF lty_cities.
DATA: ls_cities TYPE lty_cities,
lt_cities TYPE TABLE OF lty_cities,
lv_xml TYPE string,
lv_cities_element TYPE string,
lv_error TYPE string,
lo_error TYPE REF TO cx_transformation_error.
PARAMETERS: lp_incns TYPE boolean DEFAULT ''.
CASE lp_incns.
WHEN 'X'.
lv_cities_element = '<CITIES xmlns="XYZ">'.
WHEN OTHERS.
lv_cities_element = '<CITIES someattribute="XYZ">'.
ENDCASE.
CONCATENATE:
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
lv_cities_element
'<CITY>Hamburg</CITY>'
'<CITY>Berlin</CITY>'
'</CITIES>' INTO lv_xml.
TRY.
CALL TRANSFORMATION ('Z_CITIES')
SOURCE XML lv_xml
RESULT cities = lt_cities.
CATCH cx_transformation_error INTO lo_error.
lv_error = lo_error->get_text( ).
WRITE: 'Transformation not successful'.
SKIP.
WRITE: lv_error.
EXIT.
ENDTRY.
WRITE: 'Transformation successful'.
SKIP.
LOOP AT lt_cities INTO ls_cities.
WRITE: / ls_cities-city.
ENDLOOP.
Edited by: Simon Dähnhardt on Oct 20, 2009 6:04 PM
first of all your xml isn't well formatted
root element must be only one like
<?xml version="1.0" encoding="UTF-8"?>
<root>
<result xmlns="http://xmlns.oracle.com/oracleas/schema/dbserver_audittrail-11_2.xsd">
<DB_User>DBSNMP</DB_User>
<Userhost>localhost.localdomain</Userhost>
</result>
<result xmlns="http://xmlns.oracle.com/oracleas/schema/dbserver_audittrail-11_2.xsd">
<DB_User>DBSNMP</DB_User>
<Userhost>localhost.localdomain</Userhost>
</result>
</root>or may be in your case
<?xml version="1.0" encoding="UTF-8"?>
<result xmlns="http://xmlns.oracle.com/oracleas/schema/dbserver_audittrail-11_2.xsd">
<DB_User>DBSNMP</DB_User>
<Userhost>localhost.localdomain</Userhost>
</result>for remove you can use xslt as example for xmltransform
SQL> select * from v$version where rownum=1;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
SQL>
SQL> with t as
2 (select xmltype(
3 '<?xml version="1.0" encoding="UTF-8"?>
4 <result xmlns="http://xmlns.oracle.com/oracleas/schema/dbserver_audittrail-11_2.xsd">
5 <DB_User xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">DBSNMP</DB_User>
6 <Userhost xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">localhost.localdomain</Userhost>
7 </result>') xml from dual)
8 --
9 select xmltransform(t.xml, xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
10 <xsl:output method="xml" indent="no"/>
11 <xsl:template match="*">
12 <xsl:element name="{local-name()}">
13 <xsl:apply-templates select="node()"/>
14 </xsl:element>
15 </xsl:template>
16 </xsl:stylesheet>'))
17 from t
18 /
XMLTRANSFORM(T.XML,XMLTYPE('<X
<?xml version="1.0" encoding="utf-8"?>
<result><DB_User>DBSNMP</DB_User><Userhost>localhost.localdomain</Userhost></res
SQL> --add
or try add local-name() to your main xquery
Edited by: AlexAnd on Dec 12, 2012 12:05 AM
Similar Messages
-
Simple Transformation to deserialize an XML file into ABAP data structures?
I'm attempting to write my first simple transformation to deserialize
an XML file into ABAP data structures and I have a few questions.
My simple transformation contains code like the following
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns:pp="http://www.sap.com/abapxml/types/defined" >
<tt:type name="REPORT" line-type="?">
<tt:node name="COMPANY_ID" type="C" length="10" />
<tt:node name="JOB_ID" type="C" length="20" />
<tt:node name="TYPE_CSV" type="C" length="1" />
<tt:node name="TYPE_XLS" type="C" length="1" />
<tt:node name="TYPE_PDF" type="C" length="1" />
<tt:node name="IS_NEW" type="C" length="1" />
</tt:type>
<tt:root name="ROOT2" type="pp:REPORT" />
<QueryResponse>
<tt:loop ref="ROOT2" name="line">
<QueryResponseRow>
<CompanyID>
<tt:value ref="$line.COMPANY_ID" />
</CompanyID>
<JobID>
<tt:value ref="$line.JOB_ID" />
</JobID>
<ExportTypes>
<tt:loop>
<ExportType>
I don't know what to do here (see item 3, below)
</ExportType>
</tt:loop>
</ExportTypes>
<IsNew>
<tt:value ref="$line.IS_NEW"
map="val(' ') = xml('false'), val('X') = xml('true')" />
</IsNew>
</QueryResponseRow>
</tt:loop>
</QueryResponse>
</tt:loop>
1. In a DTD, an element can be designated as occurring zero or one
time, zero or more times, or one or more times. How do I write the
simple transformation to accommodate these possibilities?
2. In trying to accommodate the "zero or more times" case, I am trying
to use the <tt:loop> instruction. It occurs several layers deep in the
XML hierarchy, but at the top level of the ABAP table. The internal
table has a structure defined in the ABAP program, not in the data
dictionary. In the simple transformation, I used <tt:type> and
<tt:node> to define the structure of the internal table and then
tried to use <tt:loop ref="ROOT2" name="line"> around the subtree that
can occur zero or more times. But every variation I try seems to get
different errors. Can anyone supply a working example of this?
3. Among the fields in the internal table, I've defined three
one-character fields named TYPE_CSV, TYPE_XLS, and TYPE_PDF. In the
XML file, I expect zero to three elements of the form
<ExportType exporttype='csv' />
<ExportType exporttype='xls' />
<ExportType exporttype='pdf' />
I want to set field TYPE_CSV = 'X' if I find an ExportType element
with its exporttype attribute set to 'csv'. I want to set field
TYPE_XLS = 'X' if I find an ExportType element with its exporttype
attribute set to 'xls'. I want to set field TYPE_PDF = 'X' if I find
an ExportType element with its exporttype attribute set to 'pdf'. How
can I do that?
4. For an element that has a value like
<ErrorCode>123</ErrorCode>
in the simple transformation, the sequence
<ErrorCode> <tt:value ref="ROOT1.CODE" /> </ErrorCode>
seems to work just fine.
I have other situations where the XML reads
<IsNew value='true' />
I wanted to write
<IsNew>
<tt:value ref="$line.IS_NEW"
map="val(' ') = xml('false'), val('X') = xml('true')" />
</IsNew>
but I'm afraid that the <tt:value> fails to deal with the fact that in
the XML file the value is being passed as the value of an attribute
(named "value"), rather than the value of the element itself. How do
you handle this?Try this code below:
data l_xml_table2 type table of xml_line with header line.
W_filename - This is a Path.
if w_filename(02) = '
open dataset w_filename for output in binary mode.
if sy-subrc = 0.
l_xml_table2[] = l_xml_table[].
loop at l_xml_table2.
transfer l_xml_table2 to w_filename.
endloop.
endif.
close dataset w_filename.
else.
call method cl_gui_frontend_services=>gui_download
exporting
bin_filesize = l_xml_size
filename = w_filename
filetype = 'BIN'
changing
data_tab = l_xml_table
exceptions
others = 24.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif. -
ABAP Simple Transformation - How to save XML to file with CL_FX_WRITER?
Hello!
When calling a Simple Transformation program for transformation from ABAP to XML, it is possible to specify RESULT XML rxml as a class reference variable of type CL_FX_WRITER, which points to an XML writer.
How to handle CL_FX_WRITER in order to save XML to a file?
Thanks and regards,
AndreyHallo Rainer!
Many thanks. I have checked the profile parameter ztta/max_memreq_MB and it is set to 2048 MB in the development system. I hope, that won't be less on the client's machine. The only thing I did not clearly explained, is that I need to write XML data to the server. I am so sorry. Downloading to the local PC is very helpful for me also, but only for the test purposes.
Regards,
Andrey -
Questions concerning ST Simple Transformations
I got some questions concerning Simple Transformations:
1.) When editing a simple transformation, how to insert comments? In pure ABAP, a comment line must have as asterisk in the first column...
2.) I use <tt:loop>...</tt:loop> and want to use the index of the currently processed entry, like SY-TABIX when implementing a "LOOP AT itab" in ABAP. Is there a way?
Thanks for your answer, points will be rewared...
-MIKEHi Jack, please find some sample coding below that will solve your issue:
<tt:cond check="not-initial(ref('E1EDL20.INCO1'))">
<INCO1 tt:value-ref="E1EDL20.INCO1"/>
</tt:cond>
With the simple transformation tt cond statment you can make an XML tag optional. In below example during deserialisation xml tag <INCO1> will be skipped when not availabke in the xml and SAP data E1EDL20.INCO1 will not be filled by the transformation.
Regards. Please give points when usefull ! -
How to escape special characters in Simple Transformation
Hi Experts,
I have got a problem to get a well formed xml document from the below simple transformation. The content of maktx contains
special characters like & <, which are not allowed in a well formed XML-Document. But the result of the Simple Transformation
contains this charcters even after the transformation as you can the in the result below. Has anyone a hint how to escape the
characters included in the maktx.
The transformation for maktx, should be something like
Before: Material & < TEST
After: Material & < TEST
Report wihich calls the simple transformation
types:
BEGIN OF t_mat,
matnr type matnr,
maktx type maktx,
end of t_mat.
Data:
mat type t_mat,
xml_stream type xstring.
START-OF-SELECTION.
mat-matnr = '4711'.
mat-maktx = 'Material & < Test'.
CALL TRANSFORMATION ztest_st2
SOURCE mat = mat
RESULT XML xml_stream.
CALL FUNCTION 'DISPLAY_XML_STRING'
EXPORTING xml_string = xml_stream.
Simple Transformation
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="MAT"/>
<tt:template>
<Leistungsschild>
<CHARACT> MATNR </CHARACT>
<CHARACT_DESCR> Materialnummer </CHARACT_DESCR>
<VALUE tt:value-ref="MAT.MATNR"/>
<CHARACT> MAKTX </CHARACT>
<CHARACT_DESCR> Materialkurztext </CHARACT_DESCR>
<VALUE tt:value-ref="MAT.MAKTX" />
</Leistungsschild>
</tt:template>
</tt:transform>
RESULT
<?xml version="1.0" encoding="utf-8" ?>
<Leistungsschild>
<CHARACT>MATNR</CHARACT>
<CHARACT_DESCR>Materialnummer</CHARACT_DESCR>
<VALUE>4711</VALUE>
<CHARACT>MAKTX</CHARACT>
<CHARACT_DESCR>Materialkurztext</CHARACT_DESCR>
<VALUE>Material & < Test</VALUE> </Leistungsschild>Hi Sandra,
First of all thaks for your quick answer to my problem.
I see what you mean and get the same result, if I am using data-type string instead of xstring. But the recommendation in the XML-Books of SAP is to use XSTRING to save memory and circumflex problems between Codepages, when writing the XML-Stream to a filesystem.
As you can see in the code abvoe I am using a SAP-FM to display the XML-Stream and this FM works only with XSTRING´s,
that is one reason why I don´t understand that it displays it in the wrong way.
Even the Debugger shows me for the XSTRING the wrong result. Does all that mean that the escaping will not be applyed if you are working with XSTING´s?? -
Simple transformation : deserialize
Hi,
I have a simple transformation that works if I serialize table data, but it doesn't work when I wan't to deserialize.
Here is my ABAP program that calls the transformation:
TYPES: BEGIN OF flight,
f_id TYPE p LENGTH 5,
data TYPE c LENGTH 40,
END OF flight,
tt_flight TYPE STANDARD TABLE OF flight
WITH DEFAULT KEY.
DATA: data1 TYPE flight.
DATA: data2 TYPE flight.
DATA: xml_string TYPE string.
DATA: tab_data TYPE tt_flight.
data1-f_id = '00001'.
data1-data = 'before'.
APPEND data1 to tab_data.
data2-f_id = '00002'.
data2-data = 'before'.
APPEND data2 to tab_data.
concatenate '<?xml version="1.0" encoding="iso-8859-2"?><XY><flights>'
'<flight><id>11111</id><data>data1</data></flight>'
'<flight><id>22222</id><data>data2</data></flight>'
'</flights></XY>'
into xml_string.
CALL TRANSFORMATION ...
SOURCE XML xml_string
RESULT root = tab_data.
And the transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp_main">
<tt:root name="ROOT"/>
<tt:template name="temp_main">
<XY>
<flights>
<tt:loop name="line" ref="ROOT">
<flight>
<id>
<tt:value ref="f_id"/>
</id>
<data>
<tt:value ref="data">
</data>
</flight>
</tt:loop>
</flights>
</XY>
</tt:template>
</tt:transform>
It won't update or append the content of the xml to my table.
I would like to read many "<flight><id>.....</id><data>......</data></flight>" lines and write them into the table "tab_data".
Could somebody please help me?
Thanks in advance,
GregHi Greg,
try to address the root node with a period. Instead of
<tt:loop name="line" ref="ROOT">
use
<tt:loop name="line" ref=".ROOT">
Regards
Stephan -
How to skip XML tags in Simple transformation
Hi,
I am trying to convert an XML file to ABAP code using Simple Transformations.
I tired converting a small XML file to ABAP using it and it worked fine.
The problem is that the number of tags in the XML file I now want to parse is huge (over 200).
Is there any way that for the tag in XML corresponding tag is not created in ST? Is there any conditional tag to achieve this?
Also, is Simple Transformation a better way of parsing in such a scenario over XSLT and DOM parser?
Thanks and Regards,
Neha
Edited by: Neha Anand on Jun 2, 2008 1:19 PMHi Raja,
I have already looked through the code snippets and I am able to write a CALL TRANSFORMATION.
I want to find out if the number of tags is huge then if there is any way that some tags can be skipped for matching tags in XML which anyhow I dont need for manipulation.
Thanks and Regards,
Neha -
How to Create a Simple Transformation code Programatically
I have a requirement to convert an input xml string into a complex ABAP structure. I am thinking of using Simple Transformation (ST).
I want to find out if there is any program / function module which can "generate" the transformation code (ST program) by giving the ABAP structure name (ie, the SE11 name of the ABAP structure). That would save a lot of effort. Any ideas?
thanksHi Janet,
1. XML File -
> Internal table
2. I understand the above is ur requirement.
3. Below is my program.
It does three things :
a) selects data from T001 table
b) Converts into XML and puts it into a file.
c) In second phase,
It reads the file
and Populates the T001 table again (which has been cleareed explicitly)
4. See FIRST PHASE (itab to xml)
SECOND PHASE (xml to itab)
in my program
5.
REPORT abc.
DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
FIRST PHASE
FIRST PHASE
FIRST PHASE
Fetch Data
SELECT * FROM t001 INTO TABLE t001 WHERE bukrs = '1000'.
XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
Convert to TABLE
CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = xml_out
i_tabline_length = 100
TABLES
et_table = itab.
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:\xx.xml'
TABLES
data_tab = itab.
SECOND PHASE
SECOND PHASE
SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
BREAK-POINT.
regards,
amit . -
Using Simple Transformations with Objects tt:copy .. results in Exception
Question:
How can I serialize an ABAP-Object-Instanz with my own simple transformation?
In the sap-documentation I found the following solution for the serialisation of any data-objects.
"z_steffens_simple_transf":
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<root>
<tt:copy ref="ROOT"/>
</root>
</tt:template>
</tt:transform>
Following the example I wrote this report:
report zspahr_test_simple_transf.
class serializable definition.
public section.
interfaces if_serializable_object.
data attr type string value 'Attribute'.
endclass.
method main_serializable.
data: oref type ref to serializable,
xmlstr type xstring.
create object oref.
call transformation id
source root = oref
result xml xmlstr.
call function 'DISPLAY_XML_STRING'
exporting
xml_string = xmlstr.
call transformation z_steffens_simple_object
source root = oref
result xml xmlstr.
call function 'DISPLAY_XML_STRING'
exporting
xml_string = xmlstr.
endmethod. "main_
start-of-selection.
demo=>main_serializable( ).
Executing this report leads to an exception "CX_SY_REF_NOT_SUPPORTED".
The "standard" transformation "ID" ist working an translates my object-instance into an asXML representation:
<?xml version="1.0" encoding="utf-8" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
- <asx:values>
<ROOT href="#o3" />
</asx:values>
- <asx:heap xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abap="http://www.sap.com/abapxml/types/built-in" xmlns:cls="http://www.sap.com/abapxml/classes/global" xmlns:dic="http://www.sap.com/abapxml/types/dictionary">
- <prg:SERIALIZABLE xmlns:prg="http://www.sap.com/abapxml/classes/program/ZSPAHR_TEST_SIMPLE_TRANSF" id="o3">
- <local.SERIALIZABLE>
<ATTR>Attribute</ATTR>
</local.SERIALIZABLE>
</prg:SERIALIZABLE>
</asx:heap>
</asx:abap>
How can I do this with my own Simple Transformation "ZSPAHR_TEST_SIMPLE_TRANSF" ?
I want to serialize my object using my own xml-structure, not the asXML-structure !
Regards
SteffenHi,
try like this,i think it may help you.
ABAP:
CALL TRANSFORMATION ztrans_test
SOURCE
root = partab
RESULT XML lv_xstring.
Trnsformation:
<tt:root name="ROOT" type="?"/>
<tt:template>
<VALUES>
<VALUE_SOURCE>
<tt:value ref=".ROOT"/>
</VALUE_SOURCE>
<VALUE_PARAM>
<tt:value ref="NAME"/>
<tt:value ref="VALUE"/>
</VALUE_PARAM>
</VALUES>
Thanks,
Rajesh. -
Error in Simple transformation
Hi Guys,
I am very new to Simple transformation,there is an error in my ST,but I have no idea how to fix it,Please take a look at my simple transformation file.Thanks.
I want to deseralize the XML file to ABAp Structure
my xml file is like:
<Content>
<BookEntity name="A">
<Id>01</id>
<Title>My Book A</Title>
</BookEntity>
<BookEntity name="B">
<Id>02</id>
<Title>My Book B</Title>
<Author>Jamy</Author>
</BookEntity>
<BookEntity name="C">
<Id>03</id>
<Author>L</Author>
<Year>2007</Year>
<Group>C</Group>
</BookEntity>
</Content>
my structure likes:
DATA: BEGIN OF content,
BEGIN OF bookentity,
name TYPE string,
id TYPE string,
title TYPE string,
author TYPE string,
year TYPE string,
group TYPE string,
END OF contextentity,
END OF content.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT" />
<tt:template>
<Content>
<tt:loop ref=".ROOT" name="content" >
<BookEntity tt:ref="bookentity">
<tt:attribute name="name" value-ref="name" />
<tt:apply name="SUB">
<b> <tt:with-parameter name="NAME" ref="name"/></b> <--Error here
</tt:apply>
</ContextEntity>
</tt:loop>
</Content>
</tt:template>
<tt:template name="SUB">
<tt:context>
<tt:parameter name="NAME"/>
</tt:context>
<tt:switch-var>
<tt:cond-var check="NAME='A'">
<Id>
<tt:value ref="id"/>
</Id>
<Title>
<tt:value ref="title"/>
</Title>
</tt:cond-var>
<tt:cond-var check="NAME='B'">
<Id>
<tt:value ref="id"/>
</Id>
<Title>
<tt:value ref="title"/>
</Title>
<Author>
<tt:value ref="author"/>
</Author>
</tt:cond-var>
<tt:cond-var check="NAME='C'">
<Id>
<tt:value ref="id"/>
</Id>
<Author>
<tt:value ref="author"/>
</Author>
<Year>
<tt:value ref="year"/>
</Year>
<Group>
<tt:value ref="group"/>
</Group>
</tt:cond-var>
</tt:switch-var>
</tt:template>
</tt:transform>Check the flag "use SAP XML toolkit" for the operation mapping and try, if that works then.
Check the flag for all XSLT and Java mappings which is migrated from PI 7.0 -
Simple Transformation Exception
Hello,
I am tying to map XML to ABAP(deserialize) but receive a CX_ST_MATCH_ELEMENT Exception.
Below is my Simple Transformation, the calling method, and the XML snippet I am tying to deserialize.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<SndgInst>
<tt:value ref="ROOT"/>
</SndgInst>
</tt:template>
</tt:transform>
method PARSE_XML.
DATA:
sndginst(10) type c value ' ',
l_exception_error TYPE REF TO cx_st_error.
parse the xml content
TRY.
CLEAR: l_exception_error.
CALL TRANSFORMATION (i_st_name)
SOURCE XML i_xml_string
RESULT root = sndginst.
catch exception
CATCH: cx_st_error INTO l_exception_error.
ENDTRY.
endmethod.
<S2SCTScf:SndgInst ymlns:S2SCTScf="urn:S2SCTScf:xsd:$SCTScfBlkCredTrf">ZYDOFRP0</S2SCTScf:SndgInst>
I have tried adding a reference for the namespace 'S2SCTScf' but receive the same exception.
I think it must have something to do with the namespace prefix and I have tried several different versions of the Simple transformation, such as <S2SCTSCF:SndgInst> as my tag reference, to no avail.
The exception class does not provide a lot of useful information and since you cannot debug a Simple Transformation it is a guessing game.
Thanks in advance for your help.
Best Regards,
Mark Lengel
Edited by: Mark Lengel on Mar 31, 2009 11:32 AMI've exactly the same problem.
My XML Input Stream contains Namespaces in the root element for e.g.
<Measurement xmlns="es.xxx.com" xmlns:ns2="http://www.w3.org/1999/xlink" xmlns:ns3="http://www.w3.org/1998/Math/MathML">
The Simple Transformation always raise an CX_ST_MATCH_ELEMENT Exception.
If i delete the xmlns declarations, the Element will be found and everything is o.k.
I've also tried to avoid this by adding the tt:extensible="deep-dynamic" attribute but it doesn't matter.
<tt:template>
<Measurement tt:extensible="deep-dynamic">
I use WebAS 6.40, ERP 2004.
I hope the Community could help us. Maybe it's bug in the XML Libraries.. etc..
Kind Regards
Chris -
XSLT Mapping: Problem in appending xmlns attribute
Hi
This is my source message
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env= "http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<OrderID xmlns="http://dummyvalue">12345</OrderID>
</soap-env:Body>
My XSLT mapping
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<soap-env:Envelope>
<soap-env:Body>
<OrderID>
<xsl:attribute name = "xmlns" >
<xsl:value-of select="@xmlns"/>
</xsl:attribute>
<xsl:text>12345</xsl:text>
</OrderID>
</soap-env:Body>
</soap-env:Envelope>
</xsl:template>
</xsl:stylesheet>
I am getting the error message as
ERROR: Description: The value of the 'name' attribute may not be 'xmlns'.
Please help me how to append xmlns attribute in OrderID element ??Hi,
Use <xsl:element> to create a node in the output and specify the namespace.
<xsl:element
name="name"
namespace="URI"
use-attribute-sets="namelist"> <!-- Content:template --></xsl:element>
Thanks,
Beena. -
Upload xml file to internal table only using simple transformation
Hi Friends
How to write transformation code for the following xml data.. Please let me know immedately if any one know..
I have written as following but i encountered an eror staating -
Iam facing the following error
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not caught in
procedure "UPLOAD_XML" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The goal was to access variable "ROOT1". However, this access was not
possible.
Go through my xml file , the code and code in simple transformation.. Please reply(transformation code) me as soon as possible
- <Negara>
- <item>
- <COUNTRY>
<MANDT>600</MANDT>
<ZCODE>500</ZCODE>
<ZDESC>Pening Lalat</ZDESC>
<ZSAPCD>T1</ZSAPCD>
</COUNTRY>
</item>
- <item>
- <COUNTRY>
<MANDT>600</MANDT>
<ZCODE>600</ZCODE>
<ZDESC>Pening Lalat2</ZDESC>
<ZSAPCD>T2</ZSAPCD>
</COUNTRY>
</item>
</Negara>
DATA : BEGIN OF XDATA OCCURS 0,
STR(255) TYPE C,
END OF XDATA.
DATA: XMLUPL TYPE string .
DATA : BEGIN OF ITAB OCCURS 0,
MANDT(3) TYPE C,
ZCODE(3) TYPE C,
ZDESC(15) TYPE C,
ZSAPCD(2) TYPE C,
END OF ITAB.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\country.xml'
FILETYPE = 'BIN'
TABLES
DATA_TAB = XDATA.
LOOP AT XDATA.
CONCATENATE XMLUPL XDATA-STR INTO XMLUPL.
ENDLOOP.
CALL TRANSFORMATION ('Y_XMLCTRY')
SOURCE XML XMLUPL
result xml = ITAB[].
BREAK-POINT.
<?sap.transform simple?>
<tt:transform template="temp1"
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT1"/>
<tt:root name="ROOT2"/>
<tt:template name="temp1">
<Negara>
<tt:loop ref=".ROOT1" name="i">
<item>
<tt:loop ref=".ROOT2" name="c">
<COUNTRY>
<MANDT>
<tt:value ref="$c.nummer" />
</MANDT>
<ZCODE>
<tt:value ref="$c.nummer" />
</ZCODE>
<ZDESC>
<tt:value ref="$c.name" />
</ZDESC>
<ZSAPCD>
<tt:value ref="$c.name" />
</ZSAPCD>
</COUNTRY>
</tt:loop>
</item>
</tt:loop>
</Negara>
</tt:template>
</tt:transform>
Thanking You
DeviHi Friends
How to write transformation code for the following xml data.. Please let me know immedately if any one know..
I have written as following but i encountered an eror staating -
Iam facing the following error
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not caught in
procedure "UPLOAD_XML" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The goal was to access variable "ROOT1". However, this access was not
possible.
Go through my xml file , the code and code in simple transformation.. Please reply(transformation code) me as soon as possible
- <Negara>
- <item>
- <COUNTRY>
<MANDT>600</MANDT>
<ZCODE>500</ZCODE>
<ZDESC>Pening Lalat</ZDESC>
<ZSAPCD>T1</ZSAPCD>
</COUNTRY>
</item>
- <item>
- <COUNTRY>
<MANDT>600</MANDT>
<ZCODE>600</ZCODE>
<ZDESC>Pening Lalat2</ZDESC>
<ZSAPCD>T2</ZSAPCD>
</COUNTRY>
</item>
</Negara>
DATA : BEGIN OF XDATA OCCURS 0,
STR(255) TYPE C,
END OF XDATA.
DATA: XMLUPL TYPE string .
DATA : BEGIN OF ITAB OCCURS 0,
MANDT(3) TYPE C,
ZCODE(3) TYPE C,
ZDESC(15) TYPE C,
ZSAPCD(2) TYPE C,
END OF ITAB.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\country.xml'
FILETYPE = 'BIN'
TABLES
DATA_TAB = XDATA.
LOOP AT XDATA.
CONCATENATE XMLUPL XDATA-STR INTO XMLUPL.
ENDLOOP.
CALL TRANSFORMATION ('Y_XMLCTRY')
SOURCE XML XMLUPL
result xml = ITAB[].
BREAK-POINT.
<?sap.transform simple?>
<tt:transform template="temp1"
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT1"/>
<tt:root name="ROOT2"/>
<tt:template name="temp1">
<Negara>
<tt:loop ref=".ROOT1" name="i">
<item>
<tt:loop ref=".ROOT2" name="c">
<COUNTRY>
<MANDT>
<tt:value ref="$c.nummer" />
</MANDT>
<ZCODE>
<tt:value ref="$c.nummer" />
</ZCODE>
<ZDESC>
<tt:value ref="$c.name" />
</ZDESC>
<ZSAPCD>
<tt:value ref="$c.name" />
</ZSAPCD>
</COUNTRY>
</tt:loop>
</item>
</tt:loop>
</Negara>
</tt:template>
</tt:transform>
Thanking You
Devi -
Simple Transformation - XML to Internal Table Error
I have a webservice call that returns XML. I need to transform a portion of the response to an internal table, but my simple transformation is not working with loop processing. I have read through most posts regarding the topic but they're either too old or related to serialization. There aren't any exceptions thrown, but I don't get any data in the internal table (PAPERWORK root). Below are some code snippets. Any ideas on the problem with the XSLT template? Thanks.
Sample XML:
<?xml version="1.0" encoding="utf-8" ?>
<PrintVersionDataSet>
<Result>
<ReturnCode>W</ReturnCode>
<ReturnMessage>There are reports with later version(s)</ReturnMessage>
</Result>
<Paperwork>
<ReportCode>CVR</ReportCode>
<ReportName>Cover Sheet</ReportName>
<Version>2</Version>
<PrintedDateTime>2009-05-01T09:54:04.1-05:00</PrintedDateTime>
</Paperwork>
<Paperwork>
<ReportCode>SPS</ReportCode>
<ReportName>Sponsor Summary</ReportName>
<Version>2</Version>
<PrintedDateTime>2009-05-01T09:54:04.99-05:00</PrintedDateTime>
</Paperwork>
</PrintVersionDataSet>
XSLT Code:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="RESULT"/>
<tt:root name="PAPERWORK"/>
<tt:template>
<PrintVersionDataSet>
<Result tt:ref="RESULT">
<ReturnCode>
<tt:value ref="RETURNCODE"/>
</ReturnCode>
<ReturnMessage>
<tt:value ref="RETURNMESSAGE"/>
</ReturnMessage>
</Result>
<tt:deserialize>
<tt:loop ref=".PAPERWORK">
<Paperwork>
<ReportCode>
<tt:value ref="REPORTCODE"/>
</ReportCode>
<ReportName>
<tt:value ref="REPORTNAME"/>
</ReportName>
<Version>
<tt:value ref="VERSION"/>
</Version>
<PrintedDateTime>
<tt:value ref="PRINTEDDATETIME"/>
</PrintedDateTime>
</Paperwork>
</tt:loop>
</tt:deserialize>
</PrintVersionDataSet>
</tt:template>
</tt:transform>
ABAP Call to Transform Data:
TRY.
CALL TRANSFORMATION Z_GA_PAPERWORK_VERS_WEBSVC
SOURCE XML LS_RESPONSE-VERIFY_PRINT_VERSION_RESULT
RESULT RESULT = LS_RESULT
PAPERWORK = LT_PAPERWORK.
CATCH CX_ROOT INTO ROOT_EXCEPTION.
CALL METHOD ROOT_EXCEPTION->IF_MESSAGE~GET_TEXT
RECEIVING
RESULT = LV_MESSAGE.
ENDTRY.Upon further inspection and testing with a simple file and program, I can see that the XML structure isn't quite correct for the loop process. There needs to be a single <PAPERWORK> node, instead of one for each table line in the file. This should allow the loop to execute properly after a slight adjustment to the XSLT template.
-
Simple Transformation XML to ABAP Content of tag with subtrees to string field
Hi,
I have an requirement in which I have to do a transformation from an XML file to an structure.
I need get the value of a tag that have subtrees and move that to a field in my structure.
Example:
<TAG1>value1</TAG1>
<TAG2>value2</TAG2>
<TAG3>
<TAG4>value4</TAG4>
<TAG5>value5</TAG5>
</TAG3>
Result expected in ABAP Structure:
field1 -> tag1
field2 -> tag2
field3 -> <TAG4>value4</TAG4><TAG5>value5</TAG5>
The contents of the tag TAG3 is variable, so I want to store it as a string.
Can I make this with Simple Transformation?
In my tests I can move only the value of each child tag for the given field structure.
This syntax dont work:
<TAG3 tt:value-ref="STRUCTURE.FIELD3"/>
Thanks and Regards,
Miguel MottaHi Miguel
Have a look at below snippets. Here I have tried to escape the text inside TAG3 so that it gets treated as single node during transformation.
ABAP code
DATA: BEGIN OF result,
col1 TYPE string,
col2 TYPE string,
col3 TYPE string,
END OF result.
DATA: xml_string TYPE string VALUE
'<ROOT> <TAG1>value1</TAG1> <TAG2>value2</TAG2> <TAG3> <TAG4>value4</TAG4> <TAG5>value5</TAG5> </TAG3> </ROOT>',
part1 TYPE string,
part2 TYPE string,
part3 TYPE string.
* Escape the text inside TAG3 tag
FIND REGEX '(.*<TAG3>)(.*)(</TAG3>.*)' IN xml_string SUBMATCHES part1 part2 part3.
IF sy-subrc EQ 0.
part2 = escape( val = part2 format = cl_abap_format=>e_xml_text ).
* REPLACE ALL OCCURRENCES OF '<' IN part2 WITH '<'.
* REPLACE ALL OCCURRENCES OF '>' IN part2 WITH '>'.
xml_string = part1 && part2 && part3.
ENDIF.
TRY.
* Display xml
cl_abap_browser=>show_xml( EXPORTING xml_string = xml_string ).
* Deserialization
CALL TRANSFORMATION zmtest
SOURCE XML xml_string
RESULT para = result.
* Check result
WRITE:/ 'COL1=', result-col1,
/ 'COL2=', result-col2,
/ 'COL3=', result-col3.
CATCH cx_st_error.
* Error handling
MESSAGE 'Error in Simple Transformation'
TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
Transformation code
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp" version="0.1">
<tt:root name="PARA"/>
<tt:template name="temp">
<ROOT>
<TAG1>
<tt:value ref="PARA.COL1"/>
</TAG1>
<TAG2>
<tt:value ref="PARA.COL2"/>
</TAG2>
<TAG3>
<tt:value ref="PARA.COL3"/>
</TAG3>
</ROOT>
</tt:template>
</tt:transform>
Maybe you are looking for
-
How to create a Quarterly report only till selected month?
Hi I am trying to create a Quarterly Financial Report with HFM as data source but could not figure the logic. I want to have columns Q1, Q2, Q3, Q4 with month as User selected prompt. The columns should be populated only till the period user selects.
-
Hello everyone! I'm new around here and I registered solely and exclusively to help me I'm desperate! well I tell you my problem, I have a 9300 with virgin mobile plan but they only work with Opera Mini, well last week I desactualizo the whatsapp and
-
790FX overclocking limits questions
I currently have an AMD64 X2 5600+ stock 200Mhz OC'd to 217MHz (14x) At 100% utilization the cpus are running at around 54-56C (1.35V) TMPIN1 which is the northbridge I think, is around 46C TMPIN2 which judging by the heat coming off the plate, is th
-
Server is crashed with SDK1_3_06
Hi I am having one problem with my Sun Fire V880 system which is running on JAVA 1.2.2 with SDK1_3_06 and the problem is my server is getting rebooted every 6 hrs. I have checked the hardware and confirm with sun that it is "ok" status. Could anyone
-
Hi, would like to ask if it's possible to implement a time selector in a graph (line graph or bar graph) using the tabular data? I'm having problem displaying the timeSelector for some reason... managedBean: public List getLineGraphTabularData()