<?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 XML node in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936005#M61966</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create an xml-file from ABAP data through a simple transformation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have read info about "Transformation Editor" in the SAP Library and the examples given in the help all use hardcoded XML-nodes like &amp;lt;XMLNODE&amp;gt;....&amp;lt;/XMLNODE&amp;gt;. At the moment I also have all XML-nodes hard coded in my transformation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question: How do I get a value from the root (some id) into the name of the XML-node?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Sep 2005 11:34:23 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-09-12T11:34:23Z</dc:date>
    <item>
      <title>XML node</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936005#M61966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create an xml-file from ABAP data through a simple transformation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have read info about "Transformation Editor" in the SAP Library and the examples given in the help all use hardcoded XML-nodes like &amp;lt;XMLNODE&amp;gt;....&amp;lt;/XMLNODE&amp;gt;. At the moment I also have all XML-nodes hard coded in my transformation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question: How do I get a value from the root (some id) into the name of the XML-node?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2005 11:34:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936005#M61966</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-12T11:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: XML node</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936006#M61967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, you can use 'name()' to get the name of XML node.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:variable name="segment" select="name()"/&amp;gt;&lt;/P&gt;&lt;P&gt;the above XSLT code define a var named 'segment', and set its value with the name of current node.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'$segment' ,  you can use this statement to reference the var you defined in XSLT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope it will be helpful&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2005 13:37:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936006#M61967</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-12T13:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: XML node</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936007#M61968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well actually I would like to do it the other way around, I would like to dynamicly name the node of the xml-file I am creating. &lt;/P&gt;&lt;P&gt;The name must be an id which comes from a record of the internal table I am converting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example here: &lt;A href="http://www.xml.com/pub/a/2000/10/04/linking/" target="test_blank"&gt;http://www.xml.com/pub/a/2000/10/04/linking/&lt;/A&gt; they put the isbn code to the node of an book entry in the xml file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Fred Sterk&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2005 13:56:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936007#M61968</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-12T13:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: XML node</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936008#M61969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, the way I offer you can create a node with dynamic name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assume you have already set the value to 'segment', you can do like this:&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:element name="{$segment}"/&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;segment is a var you defined, and you can set its value dynmamically.&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:variable name="segment" select="name()"/&amp;gt;&lt;/P&gt;&lt;P&gt;is only a sample, you can use other value other than 'name()'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if it is still not enough, please make me know the actually XML file and what do you want in details.&lt;/P&gt;&lt;P&gt;Give me a sample will be better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2005 14:35:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936008#M61969</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-12T14:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: XML node</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936009#M61970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok here follows my simplified code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Report code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  z_simple_test.

TYPES:  BEGIN OF ty_test,
	   volgnr TYPE i,	
          artnr TYPE i,
	 END OF ty_test.

DATA:  xml_string TYPE string.

DATA  ls_test TYPE ty_test.

ls_test-volgnr = 1.
ls_test-artnr = 13.

CALL TRANSFORMATION ztest
  SOURCE     para = ls_test
  RESULT XML xml_string.

IF sy-subrc &amp;lt;&amp;gt; 0.
  WRITE sy-subrc.
ELSE.
  WRITE xml_string.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The ztest transformation code:&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" template="MainTempl" version="0.1"&amp;gt;

  &amp;lt;tt:root name="PARA"/&amp;gt;

  &amp;lt;tt:template name="MainTempl"&amp;gt;
    &amp;lt;X tt:ref="PARA"&amp;gt;
      &amp;lt;VolgnrNode&amp;gt;        
        &amp;lt;tt:value ref="volgnr"/&amp;gt;
      &amp;lt;/VolgnrNode&amp;gt;
      &amp;lt;ArtNode&amp;gt;
        &amp;lt;tt:value ref="artnr1"/&amp;gt;
      &amp;lt;/ArtNode&amp;gt;
    &amp;lt;/X&amp;gt;

  &amp;lt;/tt:template&amp;gt;

&amp;lt;/tt:transform&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This results in the following string:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0" encoding="utf-16"?&amp;gt;#&amp;lt;X&amp;gt;&amp;lt;VolgnrNode&amp;gt;1&amp;lt;/VolgnrNode&amp;gt;&amp;lt;ArtNode&amp;gt;13&amp;lt;/ArtNode&amp;gt;&amp;lt;/X&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I would like to see on the spot &amp;lt;VolgnrNode&amp;gt; something like &amp;lt;VolgnrNode_1&amp;gt; so a concatenation of the VolgNrNode and the value of the Volgnr.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2005 15:19:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936009#M61970</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-12T15:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: XML node</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936010#M61971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, I'm not familiar with ST, but write a equivalent XSLT, like following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[code]&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0"&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &amp;lt;xsl:strip-space elements="*"/&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &amp;lt;xsl:template match="PARA"&amp;gt;&lt;/P&gt;&lt;P&gt;  &amp;lt;PARA&amp;gt;&lt;/P&gt;&lt;P&gt;      &amp;lt;xsl:variable name="segment" select="VOLGNR/name()"/&amp;gt;&lt;/P&gt;&lt;P&gt;      &amp;lt;xsl:variable name="tail"&amp;gt;&lt;/P&gt;&lt;P&gt;        &amp;lt;xsl:value-of select="VOLGNR"/&amp;gt;&lt;/P&gt;&lt;P&gt;      &amp;lt;/xsl:variable&amp;gt;&lt;/P&gt;&lt;P&gt;      &amp;lt;xsl:element name="{concat($segment, '_', $tail)}"&amp;gt;&lt;/P&gt;&lt;P&gt;        &amp;lt;xsl:value-of select="VOLGNR"/&amp;gt;&lt;/P&gt;&lt;P&gt;      &amp;lt;/xsl:element&amp;gt;  &lt;/P&gt;&lt;P&gt;      &lt;/P&gt;&lt;P&gt;      &amp;lt;xsl:variable name="segment2" select="ARTNR/name()"/&amp;gt;    &lt;/P&gt;&lt;P&gt;      &amp;lt;xsl:variable name="tail2"&amp;gt;&lt;/P&gt;&lt;P&gt;        &amp;lt;xsl:value-of select="ARTNR"/&amp;gt;&lt;/P&gt;&lt;P&gt;      &amp;lt;/xsl:variable&amp;gt;      &lt;/P&gt;&lt;P&gt;      &amp;lt;xsl:element name="{concat($segment2, '_', $tail2)}"&amp;gt;&lt;/P&gt;&lt;P&gt;        &amp;lt;xsl:value-of select="ARTNR"/&amp;gt;&lt;/P&gt;&lt;P&gt;      &amp;lt;/xsl:element&amp;gt;        &lt;/P&gt;&lt;P&gt;  &amp;lt;/PARA&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;    &amp;lt;xsl:template match="test1"&amp;gt;&lt;/P&gt;&lt;P&gt;    &amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:transform&amp;gt;&lt;/P&gt;&lt;P&gt;[/code]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABAP CODE :&lt;/P&gt;&lt;P&gt;[code]&lt;/P&gt;&lt;P&gt;TYPES:  BEGIN OF ty_test,	&lt;/P&gt;&lt;P&gt;volgnr TYPE I,	&lt;/P&gt;&lt;P&gt;artnr TYPE I,&lt;/P&gt;&lt;P&gt;	 END OF ty_test.&lt;/P&gt;&lt;P&gt;DATA:  xml_string TYPE string.&lt;/P&gt;&lt;P&gt;DATA  ls_test TYPE ty_test.&lt;/P&gt;&lt;P&gt;ls_test-volgnr = 1.ls_test-artnr = 13.&lt;/P&gt;&lt;P&gt;CALL TRANSFORMATION ztest&lt;/P&gt;&lt;P&gt;SOURCE     para = ls_test&lt;/P&gt;&lt;P&gt;RESULT XML xml_string.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;  WRITE sy-subrc.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;  WRITE xml_string.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;[/code]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can have a try, I think the result is what you need.&lt;/P&gt;&lt;P&gt;hope it will be helpful&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2005 16:56:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936010#M61971</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-12T16:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: XML node</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936011#M61972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Zhenglin Gu thank you very much for your answer, this is exactly what I wanted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2005 07:34:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-node/m-p/936011#M61972</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-13T07:34:31Z</dc:date>
    </item>
  </channel>
</rss>

