<?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: XML deserialization: error tt:skip and namespaces in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470113#M2000894</link>
    <description>&lt;P&gt;Great, that's it.&lt;/P&gt;&lt;P&gt;Thank you Sandra!&lt;/P&gt;&lt;P&gt;(still think that "skip" should work with default namespaces and that this is a kernel bug)&lt;/P&gt;</description>
    <pubDate>Tue, 28 Sep 2021 17:28:24 GMT</pubDate>
    <dc:creator>UweFetzer_se38</dc:creator>
    <dc:date>2021-09-28T17:28:24Z</dc:date>
    <item>
      <title>XML deserialization: error tt:skip and namespaces</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470110#M2000891</link>
      <description>&lt;P&gt;To ignore some of the incoming XML elements I'm using the &amp;lt;tt:skip&amp;gt; pattern. This works fine like in the following example:&lt;/P&gt;
  &lt;P&gt;1. Example: don't skip any elements &lt;/P&gt;
  &lt;P&gt;Transformation template&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform xmlns:tt="http://www.sap.com/transformation-templates"&amp;gt;
  &amp;lt;tt:root name="ROOT"/&amp;gt;
  &amp;lt;tt:template&amp;gt;
    &amp;lt;data&amp;gt;
      &amp;lt;X1&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_A "/&amp;gt;
      &amp;lt;/X1&amp;gt;
      &amp;lt;X2&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_B "/&amp;gt;
      &amp;lt;/X2&amp;gt;
      &amp;lt;X3&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_C"/&amp;gt;
      &amp;lt;/X3&amp;gt;
    &amp;lt;/data&amp;gt;
  &amp;lt;/tt:template&amp;gt;
&amp;lt;/tt:transform&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Report&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;    DATA(xml) = |&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&amp;gt;\n| &amp;amp;
                |&amp;lt;data&amp;gt;\n| &amp;amp;
                |    &amp;lt;X1&amp;gt;aaa&amp;lt;/X1&amp;gt;\n| &amp;amp;
                |    &amp;lt;X2&amp;gt;bbb&amp;lt;/X2&amp;gt;\n| &amp;amp;
                |    &amp;lt;X3&amp;gt;ccc&amp;lt;/X3&amp;gt;\n| &amp;amp;
                |&amp;lt;/data&amp;gt;\n|.

    DATA: BEGIN OF result,
            col_a TYPE string,
            col_b TYPE string,
            col_c TYPE string,
          END OF result.

    TRY.
        CALL TRANSFORMATION ztmp_fuw
          SOURCE XML xml
          RESULT root = result.

        cl_demo_output=&amp;gt;display( result ).

      CATCH cx_st_match_text
            cx_st_match_element
            cx_sy_conversion_data_loss
            INTO DATA(lcx).

        cl_demo_output=&amp;gt;display( lcx-&amp;gt;get_text( ) ).
    ENDTRY.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Result&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;COL_A COL_B COL_C 
aaa   bbb   ccc 
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;2. Example: skip element X2 &lt;/P&gt;
  &lt;P&gt; Transformation template&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform xmlns:tt="http://www.sap.com/transformation-templates"&amp;gt;
  &amp;lt;tt:root name="ROOT"/&amp;gt;
  &amp;lt;tt:template&amp;gt;
    &amp;lt;data&amp;gt;
      &amp;lt;X1&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_A "/&amp;gt;
      &amp;lt;/X1&amp;gt;
      &amp;lt;tt:skip name="X2"/&amp;gt;
      &amp;lt;X3&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_C"/&amp;gt;
      &amp;lt;/X3&amp;gt;
    &amp;lt;/data&amp;gt;
  &amp;lt;/tt:template&amp;gt;
&amp;lt;/tt:transform&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;No changes in report. &lt;/P&gt;
  &lt;P&gt;Result &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;COL_A COL_B COL_C 
aaa         ccc 
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;No surprises so far, everything works as expected. &lt;/P&gt;
  &lt;P&gt;Now we have to process a standarized XML with a namespace in it and the transformation (the skip) doesn't work anymore. &lt;/P&gt;
  &lt;P&gt;Changed transformation template:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform xmlns:tt="http://www.sap.com/transformation-templates"&amp;gt;
  &amp;lt;tt:root name="ROOT"/&amp;gt;
  &amp;lt;tt:template&amp;gt;
    &amp;lt;data xmlns="urn:mynamespace"&amp;gt;
      &amp;lt;X1&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_A "/&amp;gt;
      &amp;lt;/X1&amp;gt;
      &amp;lt;tt:skip name="X2"/&amp;gt;
      &amp;lt;X3&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_C"/&amp;gt;
      &amp;lt;/X3&amp;gt;
    &amp;lt;/data&amp;gt;
  &amp;lt;/tt:template&amp;gt;
&amp;lt;/tt:transform&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Changed XML in the report:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;    DATA(xml) = |&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&amp;gt;\n| &amp;amp;
                |&amp;lt;data xmlns="urn:mynamespace"&amp;gt;\n| &amp;amp;
                |    &amp;lt;X1&amp;gt;aaa&amp;lt;/X1&amp;gt;\n| &amp;amp;
                |    &amp;lt;X2&amp;gt;bbb&amp;lt;/X2&amp;gt;\n| &amp;amp;
                |    &amp;lt;X3&amp;gt;ccc&amp;lt;/X3&amp;gt;\n| &amp;amp;
                |&amp;lt;/data&amp;gt;\n|.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Result: &lt;/P&gt;
  &lt;P&gt; Exception &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;Element '{urn:mynamespace}X3' expected &lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I've tested this behaviour in 7.50 and 7.52, same result. &lt;/P&gt;
  &lt;P&gt;What am I doing wrong here? Or is it a kernel bug? &lt;/P&gt;
  &lt;P&gt; Any idea how to use the skip pattern with custom xml namespaces? Or are there any patterns I could use to ignore specific elements - deserialization should work whether they are present or not. &lt;/P&gt;
  &lt;P&gt;Thank you in advance for your ideas. &lt;/P&gt;
  &lt;P&gt;Cheers, Uwe&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 14:45:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470110#M2000891</guid>
      <dc:creator>UweFetzer_se38</dc:creator>
      <dc:date>2021-09-28T14:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: XML deserialization: error tt:skip and namespaces</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470111#M2000892</link>
      <description>&lt;P&gt;I guess that the skip doesn't work because of missing namespace in name="X2".&lt;/P&gt;&lt;P&gt;You must indicate a namespace prefix before X2 e.g. name="aaaaaaa:X2" with aaaaaaa being any text and xmlns:aaaaaaa="same URI as default namespace" defined in the same node or a node above.&lt;/P&gt;&lt;P&gt;(I don't know how to directly indicate to use the default namespace without using a dummy prefix)&lt;/P&gt;&lt;P&gt;The below code solves your issue:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform xmlns:tt="http://www.sap.com/transformation-templates"&amp;gt;
  &amp;lt;tt:root name="ROOT"/&amp;gt;
  &amp;lt;tt:template&amp;gt;
    &amp;lt;data xmlns="urn:mynamespace" xmlns:aaaaaaa="urn:mynamespace"&amp;gt;
      &amp;lt;X1&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_A "/&amp;gt;
      &amp;lt;/X1&amp;gt;
      &amp;lt;tt:skip name="aaaaaaa:X2"/&amp;gt;
      &amp;lt;X3&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_C"/&amp;gt;
      &amp;lt;/X3&amp;gt;
    &amp;lt;/data&amp;gt;
  &amp;lt;/tt:template&amp;gt;
&amp;lt;/tt:transform&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Sep 2021 15:12:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470111#M2000892</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-09-28T15:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: XML deserialization: error tt:skip and namespaces</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470112#M2000893</link>
      <description>&lt;P&gt;To make all elements optional, you may use tt:extensible="on" or "deep-static" or "deep-dynamic":&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform xmlns:tt="http://www.sap.com/transformation-templates"&amp;gt;
  &amp;lt;tt:root name="ROOT"/&amp;gt;
  &amp;lt;tt:template&amp;gt;
    &amp;lt;data tt:extensible="deep-dynamic" xmlns="urn:mynamespace"&amp;gt;
      &amp;lt;X1&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_A "/&amp;gt;
      &amp;lt;/X1&amp;gt;
      &amp;lt;X3&amp;gt;
        &amp;lt;tt:value ref=".ROOT.COL_C"/&amp;gt;
      &amp;lt;/X3&amp;gt;
    &amp;lt;/data&amp;gt;
  &amp;lt;/tt:template&amp;gt;
&amp;lt;/tt:transform&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Sep 2021 17:13:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470112#M2000893</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-09-28T17:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: XML deserialization: error tt:skip and namespaces</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470113#M2000894</link>
      <description>&lt;P&gt;Great, that's it.&lt;/P&gt;&lt;P&gt;Thank you Sandra!&lt;/P&gt;&lt;P&gt;(still think that "skip" should work with default namespaces and that this is a kernel bug)&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 17:28:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-deserialization-error-tt-skip-and-namespaces/m-p/12470113#M2000894</guid>
      <dc:creator>UweFetzer_se38</dc:creator>
      <dc:date>2021-09-28T17:28:24Z</dc:date>
    </item>
  </channel>
</rss>

