<?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>Question Re: xslt code help needed in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226728#M2604428</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep, you're correct with the structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SellerPartNumber / BuyerPartNumber / ManufacturingPartNumber are all on the same level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BuyerPartNumber/PartNum/PartID --&amp;gt; target &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ManufacturingPartNumber/PartID --&amp;gt; The value on this value will be copied to BuyerPartNumber/PartNum/PartID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With regards to your code on the 'value-of select', what does ".../.../PartID" means?&lt;/P&gt;&lt;P&gt;Do I need to indicate there the full path from Order root document?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Aug 2010 13:59:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-08-25T13:59:47Z</dc:date>
    <item>
      <title>xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaq-p/7226720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SAP experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you be able to help me in configuring the right xslt code to accomodate the looping logic?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source Document:&lt;/P&gt;&lt;P&gt;School  (occur only once)&lt;/P&gt;&lt;P&gt; - Name (can occur multiple times)&lt;/P&gt;&lt;P&gt;      - Nickname (occur only once)&lt;/P&gt;&lt;P&gt;      - Desired name (occur only once)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Target Document:&lt;/P&gt;&lt;P&gt;School&lt;/P&gt;&lt;P&gt; - Name &lt;/P&gt;&lt;P&gt;     - Nickname (the value for this should be obtained from 'Desired name field')&lt;/P&gt;&lt;P&gt;     - Desired name &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this code, but seems not working in looping logic. (to accomodate the multiple Names):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:template match="@*|node()"&amp;gt;&lt;/P&gt;&lt;P&gt; &amp;lt;xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;    &amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;&lt;/P&gt;&lt;P&gt; &amp;lt;/xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:template match="Order/OrderDetail/ListOfItemDetail/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/BuyerPartNumber"&amp;gt;&lt;/P&gt;&lt;P&gt;  &amp;lt;BuyerPartNumber&amp;gt;&lt;/P&gt;&lt;P&gt;     &amp;lt;PartNum&amp;gt;&lt;/P&gt;&lt;P&gt;        &amp;lt;PartID&amp;gt;&lt;/P&gt;&lt;P&gt;            &amp;lt;xsl:value-of select ="/Order/OrderDetail/ListOfItemDetail/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/ManufacturerPartNumber/PartID"/&amp;gt;&lt;/P&gt;&lt;P&gt;        &amp;lt;/PartID&amp;gt;&lt;/P&gt;&lt;P&gt;    &amp;lt;/PartNum&amp;gt;&lt;/P&gt;&lt;P&gt; &amp;lt;/BuyerPartNumber&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What happened is that the value was taken ONLY on the 1st line item. (1st Name occurence)&lt;/P&gt;&lt;P&gt;The succeeding Name field just copied the value of Nicknames from the 1st Name field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly advise how to handle the context (loop logic) in the xslt code.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 18:05:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaq-p/7226720</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-24T18:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226721#M2604421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;instead of copy you have to use copy-of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This XSLT seems not to have anything to do with your source XML.&lt;/P&gt;&lt;P&gt;Maybe you check this page, that helped me a lot:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://w3schools.com/xsl/el_copy-of.asp" target="test_blank"&gt;http://w3schools.com/xsl/el_copy-of.asp&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 19:09:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226721#M2604421</guid>
      <dc:creator>stefan_grube</dc:creator>
      <dc:date>2010-08-24T19:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226722#M2604422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Apologies, here's the logic for the source document I've mentioned above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:template match="@*|node()"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:template match="Name/Nickname"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;BuyerPartNumber&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;PartNum&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;PartID&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:value-of select ="Name/Desired name"/&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/PartID&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/PartNum&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/BuyerPartNumber&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will consider your inputs and retest again. I will inform for any updates,&lt;/P&gt;&lt;P&gt;Thanks for your inputs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 19:27:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226722#M2604422</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-24T19:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226723#M2604423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gerberto,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your template matches Name/Nickname you cannot access Name/DesiredName the way you have shown.  If you give the full path /School/Name/DesiredName you will only get the first occurrence.  Try getting the value using a context aware xpath like in the example below.  This will copy source to target as-is except for the Name/Nickname field.  The Nickname value will be replaced with the value from DesiredName within the same "Name" context.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;

  &amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;

  &amp;lt;xsl:template match="@*|node()"&amp;gt;
    &amp;lt;xsl:copy&amp;gt;
      &amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;
    &amp;lt;/xsl:copy&amp;gt;
  &amp;lt;/xsl:template&amp;gt;
  
  &amp;lt;xsl:template match="Name/Nickname"&amp;gt;
    &amp;lt;Nickname&amp;gt;&amp;lt;xsl:value-of select="../DesiredName"/&amp;gt;&amp;lt;/Nickname&amp;gt;
  &amp;lt;/xsl:template&amp;gt;
  
&amp;lt;/xsl:stylesheet&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to rebuild the entire "Name" node then set your template to match on Name and access fields within Name as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;

  &amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;

  &amp;lt;xsl:template match="@*|node()"&amp;gt;
    &amp;lt;xsl:copy&amp;gt;
      &amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;
    &amp;lt;/xsl:copy&amp;gt;
  &amp;lt;/xsl:template&amp;gt;

  &amp;lt;xsl:template match="Name"&amp;gt;
    &amp;lt;Name&amp;gt;
      &amp;lt;DesiredName&amp;gt;&amp;lt;xsl:value-of select="DesiredName"/&amp;gt;&amp;lt;/DesiredName&amp;gt;
      &amp;lt;Nickname&amp;gt;&amp;lt;xsl:value-of select="DesiredName"/&amp;gt;&amp;lt;/Nickname&amp;gt;
    &amp;lt;/Name&amp;gt;
  &amp;lt;/xsl:template&amp;gt;

&amp;lt;/xsl:stylesheet&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-Russ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 20:36:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226723#M2604423</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-24T20:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226724#M2604424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for this helpful information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is in consideration that,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;School --&amp;gt; Main Header segment (occur only once)&lt;/P&gt;&lt;P&gt;Name --&amp;gt; sub-segment under School field (occur multiple times)&lt;/P&gt;&lt;P&gt;Nickname --&amp;gt;  sub-segments under Name (occur only once)&lt;/P&gt;&lt;P&gt;Desired Name --&amp;gt; sub-segments under Name (occur only once)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will the code you've provided applies?&lt;/P&gt;&lt;P&gt;Meanwhile, I will debug the code on my side also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 20:51:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226724#M2604424</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-24T20:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226725#M2604425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It should, the key is to know your current context and use relative or full xpaths depending on what you need.  If your template matches on Name you can access all sub-nodes within Name using a relative xpath. Here's what I assumed your sample structure looks like followed by what the xsl will convert it to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;DocRoot&amp;gt;
  &amp;lt;OtherStuff&amp;gt;
    &amp;lt;a&amp;gt;1&amp;lt;/a&amp;gt;
  &amp;lt;/OtherStuff&amp;gt;
  &amp;lt;School&amp;gt;
    &amp;lt;Name&amp;gt;
      &amp;lt;Nickname&amp;gt;Nickname1&amp;lt;/Nickname&amp;gt;
      &amp;lt;DesiredName&amp;gt;DesiredName1&amp;lt;/DesiredName&amp;gt;
    &amp;lt;/Name&amp;gt;
    &amp;lt;Name&amp;gt;
      &amp;lt;Nickname&amp;gt;Nickname2&amp;lt;/Nickname&amp;gt;
      &amp;lt;DesiredName&amp;gt;DesiredName2&amp;lt;/DesiredName&amp;gt;
    &amp;lt;/Name&amp;gt;
  &amp;lt;/School&amp;gt;
&amp;lt;/DocRoot&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Target:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;DocRoot&amp;gt;
  &amp;lt;OtherStuff&amp;gt;
    &amp;lt;a&amp;gt;1&amp;lt;/a&amp;gt;
  &amp;lt;/OtherStuff&amp;gt;
  &amp;lt;School&amp;gt;
    &amp;lt;Name&amp;gt;
      &amp;lt;Nickname&amp;gt;DesiredName1&amp;lt;/Nickname&amp;gt;
      &amp;lt;DesiredName&amp;gt;DesiredName1&amp;lt;/DesiredName&amp;gt;
    &amp;lt;/Name&amp;gt;
    &amp;lt;Name&amp;gt;
      &amp;lt;Nickname&amp;gt;DesiredName2&amp;lt;/Nickname&amp;gt;
      &amp;lt;DesiredName&amp;gt;DesiredName2&amp;lt;/DesiredName&amp;gt;
    &amp;lt;/Name&amp;gt;
  &amp;lt;/School&amp;gt;
&amp;lt;/DocRoot&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you needed something different please post back what you want the results to look like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-Russ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 21:20:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226725#M2604425</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-24T21:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226726#M2604426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is my real source code,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Order (Root) &lt;/P&gt;&lt;P&gt;- OrderHeader (1parent field)- occur only once&lt;/P&gt;&lt;P&gt;- OrderDetail  (1parent field)- occur only once&lt;/P&gt;&lt;P&gt; &amp;gt; ListOfItemDetail- occur only once&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; ItemDetail - occur multiple times&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; BaseItemDetail&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ItemIdentifiers&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; PartNumbers&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; SellerPartNumber&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; BuyerPartNumber&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; PartNum&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; PartID&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ManufacturingPartNumber&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; PartID&lt;/P&gt;&lt;P&gt;- OrderSummary(1parent field)- occur only once&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;&amp;gt; --&amp;gt; this indicates the sub-fields under each segment.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;- SellerPartNumber / BuyerPartNumber / ManufacturingPartNumber is on the same level&lt;/P&gt;&lt;P&gt;- ItemDetail can occur multiple times, the rest occur only once&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The goal is to transfer the value of PartID under ManufacturingPartNumber field into the field PartID of BuyerPartNumber/PartNum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you can help. Thanks!&lt;/P&gt;&lt;P&gt;Im still debugging the code also.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 21:36:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226726#M2604426</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-24T21:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226727#M2604427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From your post I think your XML structure looks like this (ItemDetail can repeat) :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Order&amp;gt;
  &amp;lt;OrderHeader&amp;gt;header&amp;lt;/OrderHeader&amp;gt;
  &amp;lt;OrderDetail&amp;gt;
    &amp;lt;ListOfItemDetail&amp;gt;
      &amp;lt;ItemDetail&amp;gt;
        &amp;lt;BaseItemDetail&amp;gt;
          &amp;lt;ItemIdentifiers&amp;gt;
            &amp;lt;PartNumbers&amp;gt;
              &amp;lt;SellerPartNumber&amp;gt;spn1&amp;lt;/SellerPartNumber&amp;gt;
              &amp;lt;BuyerPartNumber&amp;gt;
                &amp;lt;PartNum&amp;gt;
                  &amp;lt;PartID&amp;gt;bpn1&amp;lt;/PartID&amp;gt;
                &amp;lt;/PartNum&amp;gt;
              &amp;lt;/BuyerPartNumber&amp;gt;
              &amp;lt;ManufacturingPartNumber&amp;gt;mpn1&amp;lt;/ManufacturingPartNumber&amp;gt;
              &amp;lt;PartID&amp;gt;pn1&amp;lt;/PartID&amp;gt;
            &amp;lt;/PartNumbers&amp;gt;
          &amp;lt;/ItemIdentifiers&amp;gt;
        &amp;lt;/BaseItemDetail&amp;gt;
      &amp;lt;/ItemDetail&amp;gt;
    &amp;lt;/ListOfItemDetail&amp;gt;
  &amp;lt;/OrderDetail&amp;gt;
  &amp;lt;OrderSummary&amp;gt;ordsum&amp;lt;/OrderSummary&amp;gt;
&amp;lt;/Order&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If so, then try this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;
  &amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;

  &amp;lt;xsl:template match="@*|node()"&amp;gt;
    &amp;lt;xsl:copy&amp;gt;
      &amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;
    &amp;lt;/xsl:copy&amp;gt;
  &amp;lt;/xsl:template&amp;gt;
  
  &amp;lt;xsl:template match="BuyerPartNumber/PartNum/PartID"&amp;gt;
     &amp;lt;PartID&amp;gt;&amp;lt;xsl:value-of select="../../../PartID"/&amp;gt;&amp;lt;/PartID&amp;gt;
  &amp;lt;/xsl:template&amp;gt;
  
&amp;lt;/xsl:stylesheet&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 23:57:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226727#M2604427</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-24T23:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226728#M2604428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep, you're correct with the structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SellerPartNumber / BuyerPartNumber / ManufacturingPartNumber are all on the same level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BuyerPartNumber/PartNum/PartID --&amp;gt; target &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ManufacturingPartNumber/PartID --&amp;gt; The value on this value will be copied to BuyerPartNumber/PartNum/PartID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With regards to your code on the 'value-of select', what does ".../.../PartID" means?&lt;/P&gt;&lt;P&gt;Do I need to indicate there the full path from Order root document?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 13:59:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226728#M2604428</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-25T13:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226729#M2604429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried this code,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version='1.0' encoding='UTF-8' ?&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:variable name="SenderPhysicalDUNS" select="'253066740'"/&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:template match="@*|node()"&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;			&amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;/xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:template match="/Order/OrderHeader/OrderReferences/AccountCode/Reference/RefNum"&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;RefNum&amp;gt;&lt;/P&gt;&lt;P&gt;			&amp;lt;xsl:value-of select="$SenderPhysicalDUNS"/&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;/RefNum&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:template match="BuyerPartNumber/PartNum/PartID"&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;PartID&amp;gt;&lt;/P&gt;&lt;P&gt;			&amp;lt;xsl:value-of select="/Order/OrderDetail/ListOfItemDetail/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/ManufacturerPartNumber/PartID"/&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;/PartID&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the output is still the same.&lt;/P&gt;&lt;P&gt;Only the 1st Part ID under BuyerPartNumber were copied in the 2nd, 3rd, .. iteration of ItemDetail. :'(&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried removing the "/" in the Order/OrderDetail... , but there was no value appearing in the BuyerPartNumber/PartNum/PartID.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly provide your inputs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 14:09:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226729#M2604429</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-25T14:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226730#M2604430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ".." references the parent node of the current node.   &lt;A href="http://www.w3schools.com/XPath/xpath_syntax.asp" target="test_blank"&gt;http://www.w3schools.com/XPath/xpath_syntax.asp&lt;/A&gt;  The full xpath will always reference the first occurrence and is equivalent to this statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;/Order/OrderDetail/ListOfItemDetail/ItemDetail[1]/BaseItemDetail/ItemIdentifiers/PartNumbers/ManufacturerPartNumber/PartID&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You need an xpath statement relative to your current context (loop iteration):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  &amp;lt;xsl:template match="BuyerPartNumber/PartNum/PartID"&amp;gt;
    &amp;lt;PartID&amp;gt;
      &amp;lt;xsl:value-of select="../../../ManufacturerPartNumber/PartID"/&amp;gt;
    &amp;lt;/PartID&amp;gt;
  &amp;lt;/xsl:template&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 15:03:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226730#M2604430</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-25T15:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226731#M2604431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've added that in my current code, but seems the output still the same. The value in PartID under BuyerPartNumber was just copied to its succeeding ItemDetail fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version='1.0' encoding='UTF-8' ?&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:template match="@*|node()"&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;			&amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;/xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;	&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:template match="BuyerPartNumber/PartNum/PartID"&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;PartID&amp;gt;&lt;/P&gt;&lt;P&gt;			&amp;lt;xsl:value-of select="/Order/OrderDetail/ListOfItemDetail/ItemDetail[1]/BaseItemDetail/ItemIdentifiers/PartNumbers/ManufacturerPartNumber/PartID"/&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;/PartID&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would that be ok if I can attach the source document I am currently testing right now to this thread? Although, I don't know how to attach it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly advise.&lt;/P&gt;&lt;P&gt;I'm thinking, if I can use for-each code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 15:22:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226731#M2604431</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-25T15:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226732#M2604432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try the relative xpath statement that I suggested:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;
  &amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;
 
  &amp;lt;xsl:template match="@*|node()"&amp;gt;
    &amp;lt;xsl:copy&amp;gt;
      &amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;
    &amp;lt;/xsl:copy&amp;gt;
  &amp;lt;/xsl:template&amp;gt;
 
  &amp;lt;xsl:template match="BuyerPartNumber/PartNum/PartID"&amp;gt;
    &amp;lt;PartID&amp;gt;
      &amp;lt;xsl:value-of select="../../../ManufacturerPartNumber/PartID"/&amp;gt;
    &amp;lt;/PartID&amp;gt;
  &amp;lt;/xsl:template&amp;gt;
   
&amp;lt;/xsl:stylesheet&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Aug 2010 05:44:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226732#M2604432</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-26T05:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: xslt code help needed</title>
      <link>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226733#M2604433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Apologies, but, it seems i did not indicate the complete message structure for the document I am testing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Order (root)&lt;/P&gt;&lt;P&gt;OrderHeader (1st parent segment)&lt;/P&gt;&lt;P&gt;OrderNumber (child fields - 1st)&lt;/P&gt;&lt;P&gt;Order.. (child fields - 2nd)&lt;/P&gt;&lt;P&gt;Order...(child fields - 2nd)&lt;/P&gt;&lt;P&gt;OrderDetail (1st parent segment)&lt;/P&gt;&lt;P&gt;&amp;lt;fields under this segment were already mentioned from previous threads&amp;gt;&lt;/P&gt;&lt;P&gt;OrderSummary (1st parent segment)&lt;/P&gt;&lt;P&gt;NumOfLines (child fields - 1st)&lt;/P&gt;&lt;P&gt;TotalAmount (child fields - 1st)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Under Order, there are also OrderHeader and OrderSummary parent segment, other than OrderDetail, in which we focus our code.&lt;/P&gt;&lt;P&gt;I've tried your code, but, the segments OrderHeader and OrderSummary and child fields under it were not appearing on my output. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it seems, I've already generated the correct code.&lt;/P&gt;&lt;P&gt;Here it is,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:template match="@*|node()"&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;			&amp;lt;xsl:apply-templates select="@*|node()"/&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;/xsl:copy&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;xsl:template match="/Order/OrderDetail/ListOfItemDetail/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/BuyerPartNumber"&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;xsl:for-each select="."&amp;gt;&lt;/P&gt;&lt;P&gt;			&amp;lt;BuyerPartNumber&amp;gt;&lt;/P&gt;&lt;P&gt;				&amp;lt;PartNum&amp;gt;&lt;/P&gt;&lt;P&gt;					&amp;lt;PartID&amp;gt;&lt;/P&gt;&lt;P&gt;						&amp;lt;xsl:value-of select="../ManufacturerPartNumber/PartID"/&amp;gt;&lt;/P&gt;&lt;P&gt;					&amp;lt;/PartID&amp;gt;&lt;/P&gt;&lt;P&gt;				&amp;lt;/PartNum&amp;gt;&lt;/P&gt;&lt;P&gt;			&amp;lt;/BuyerPartNumber&amp;gt;&lt;/P&gt;&lt;P&gt;		&amp;lt;/xsl:for-each&amp;gt;&lt;/P&gt;&lt;P&gt;	&amp;lt;/xsl:template&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe, the code you've suggested last time will accomodate only OrderDetail parent segment. Is this correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Aug 2010 18:44:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/xslt-code-help-needed/qaa-p/7226733#M2604433</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-27T18:44:50Z</dc:date>
    </item>
  </channel>
</rss>

