Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8193061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:21:00+00:00 2026-06-07T04:21:00+00:00

I have this requirement to concatenate data from DNR2 (Parent) Message Data into the

  • 0

I have this requirement to concatenate data from DNR2 (Parent) Message Data into the DNRL (Child) Message Data

Here is my source XML:

 <?xml version="1.0" encoding="UTF-8"?>
<ns1:Delivery2 xmlns:ns1="http://www.norskeskog.com/MES">
  <ns1:FGOD>
    <ns1:DNH2>
      <ns1:OIT_ID>1025</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNH2</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>0000000000000019158100000000106448              00422  DE22ZCC2110600000027032500000227032502CC20DC          SUDU 198007-0                           .054349             2002432011081008150520110810                                                                                                                              delivery note                                                         0010002                                        FR. MEYERS SOHN GMBH&amp;CO                 20110820</ns1:MESSAGE_DATA>
    </ns1:DNH2>
    <ns1:DNR2>
      <ns1:OIT_ID>1026</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNR2</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000022000000270325000002201108084325164108562025I2                              0006               10000444158000000000000856702000600</ns1:MESSAGE_DATA>
    </ns1:DNR2>
    <ns1:DNRL>
      <ns1:OIT_ID>1027</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNRL</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000043251641085620254325164104282025</ns1:MESSAGE_DATA>
    </ns1:DNRL>
    <ns1:DNRL>
      <ns1:OIT_ID>1028</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNRL</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000043251641085620254325174104282025</ns1:MESSAGE_DATA>
    </ns1:DNRL>
    <ns1:DNR2>
      <ns1:OIT_ID>1029</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNR2</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000022000000270325000002201108084325164208602025I2                              0006               10000444158000000000000860702000600</ns1:MESSAGE_DATA>
    </ns1:DNR2>
    <ns1:DNRL>
      <ns1:OIT_ID>1030</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNRL</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
<ns1:MESSAGE_DATA>000000000000001915810000000043251642086020254325164204302025</ns1:MESSAGE_DATA>
    </ns1:DNRL>
  </ns1:FGOD>
</ns1:Delivery2>

I need to concatenate only the message data of the DNR2 into the DNRL, keeping in mind that DNR2 is parent of DNRL based on some string in the message data.

I tried doing it but, the resulting XML contains duplicates of Message Data as it iterated for each DNR2

Required Target:

<?xml version="1.0" encoding="UTF-8"?>
<ns1:Delivery2 xmlns:ns1="http://www.norskeskog.com/MES">
  <ns1:FGOD>
    <ns1:DNH2>
      <ns1:OIT_ID>1025</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNH2</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>0000000000000019158100000000106448              00422  DE22ZCC2110600000027032500000227032502CC20DC          SUDU 198007-0                           .054349             2002432011081008150520110810                                                                                                                              delivery note                                                         0010002                                        FR. MEYERS SOHN GMBH&amp;CO                 20110820</ns1:MESSAGE_DATA>
    </ns1:DNH2>
    <ns1:DNR2>
      <ns1:OIT_ID>1026</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNR2</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000022000000270325000002201108084325164108562025I2                              0006               10000444158000000000000856702000600</ns1:MESSAGE_DATA>
    </ns1:DNR2>
    <ns1:DNRL>
      <ns1:OIT_ID>1027</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNRL</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000043251641085620254325164104282025 000000000000001915810000000022000000270325000002201108084325164108562025I2                              0006               10000444158000000000000856702000600</ns1:MESSAGE_DATA>
    </ns1:DNRL>
    <ns1:DNRL>
      <ns1:OIT_ID>1028</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNRL</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000043251641085620254325174104282025 000000000000001915810000000022000000270325000002201108084325164108562025I2                              0006               10000444158000000000000856702000600</ns1:MESSAGE_DATA>
    </ns1:DNRL>
    <ns1:DNR2>
      <ns1:OIT_ID>1029</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNR2</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000022000000270325000002201108084325164208602025I2                              0006               10000444158000000000000860702000600</ns1:MESSAGE_DATA>
    </ns1:DNR2>
    <ns1:DNRL>
      <ns1:OIT_ID>1030</ns1:OIT_ID>
      <ns1:CONTEXT>FGOD</ns1:CONTEXT>
      <ns1:MESSAGE_ID>DNRL</ns1:MESSAGE_ID>
      <ns1:VERSION>40B</ns1:VERSION>
      <ns1:SOURCE_SYS>MWWA</ns1:SOURCE_SYS>
      <ns1:DESTIN_SYS>SAPT</ns1:DESTIN_SYS>
      <ns1:TIME_STAMP>2012-06-18T12:55:00</ns1:TIME_STAMP>
      <ns1:FUNCTION>NEW</ns1:FUNCTION>
      <ns1:PRIORITY>
      </ns1:PRIORITY>
      <ns1:STATUS>1</ns1:STATUS>
      <ns1:SAP_IDOC_NUMBER/>
      <ns1:MESSAGE_DATA>000000000000001915810000000043251642086020254325164204302025 000000000000001915810000000022000000270325000002201108084325164208602025I2                              0006               10000444158000000000000860702000600</ns1:MESSAGE_DATA>
    </ns1:DNRL> 
  </ns1:FGOD>
</ns1:Delivery2>

My attempt:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://www.norskeskog.com/MES" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="ns0 xs">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <Delivery2 xmlns="http://www.norskeskog.com/MES">
            <xsl:attribute name="xsi:schemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance">http://www.norskeskog.com/MES C:/Users/scarlosb/Desktop/DEV/FGOD.xsd</xsl:attribute>
            <xsl:for-each select="ns0:Delivery2">
                <xsl:variable name="var2_cur" select="."/>
                <FGOD>
                    <DNH2>
                        <xsl:copy-of select="ns0:FGOD/ns0:DNH2/@node()"/>
                        <xsl:copy-of select="ns0:FGOD/ns0:DNH2/node()"/>
                    </DNH2>
                    <xsl:for-each select="ns0:FGOD/ns0:DNR2">
                        <DNR2>
                            <xsl:copy-of select="@node()"/>
                            <xsl:copy-of select="node()"/>
                        </DNR2>
                    </xsl:for-each>
                    <xsl:for-each select="ns0:FGOD/ns0:DNRL">
                        <xsl:variable name="var1_cur" select="."/>
                        <DNRL>
                            <OIT_ID>
                                <xsl:value-of select="string(floor(number(string(ns0:OIT_ID))))"/>
                            </OIT_ID>
                            <CONTEXT>
                                <xsl:value-of select="string(ns0:CONTEXT)"/>
                            </CONTEXT>
                            <MESSAGE_ID>
                                <xsl:value-of select="string(ns0:MESSAGE_ID)"/>
                            </MESSAGE_ID>
                            <VERSION>
                                <xsl:value-of select="string(ns0:VERSION)"/>
                            </VERSION>
                            <SOURCE_SYS>
                                <xsl:value-of select="string(ns0:SOURCE_SYS)"/>
                            </SOURCE_SYS>
                            <DESTIN_SYS>
                                <xsl:value-of select="string(ns0:DESTIN_SYS)"/>
                            </DESTIN_SYS>
                            <TIME_STAMP>
                                <xsl:value-of select="string(ns0:TIME_STAMP)"/>
                            </TIME_STAMP>
                            <FUNCTION>
                                <xsl:value-of select="string(ns0:FUNCTION)"/>
                            </FUNCTION>
                            <PRIORITY>
                                <xsl:value-of select="string(ns0:PRIORITY)"/>
                            </PRIORITY>
                            <STATUS>
                                <xsl:value-of select="string(floor(number(string(ns0:STATUS))))"/>
                            </STATUS>
                            <SAP_IDOC_NUMBER>
                                <xsl:value-of select="/.."/>
                            </SAP_IDOC_NUMBER>
                            <xsl:for-each select="$var2_cur/ns0:FGOD/ns0:DNR2">
                                <MESSAGE_DATA>
                                    <xsl:value-of select="concat(string($var1_cur/ns0:MESSAGE_DATA), string(ns0:MESSAGE_DATA))"/>
                                </MESSAGE_DATA>
                            </xsl:for-each>
                        </DNRL>
                    </xsl:for-each>
                </FGOD>
            </xsl:for-each>
        </Delivery2>
    </xsl:template>
</xsl:stylesheet>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:21:04+00:00Added an answer on June 7, 2026 at 4:21 am

    This XSLT 1.0 style-sheet should do the trick.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ns1="http://www.norskeskog.com/MES">
    <xsl:output method="xml" indent="yes"/>
    
    <xsl:template match="@*|node()">
     <xsl:copy> 
       <xsl:apply-templates select="@*|node()" /> 
     </xsl:copy> 
    </xsl:template>  
    
    <xsl:template match="ns1:DNRL/ns1:MESSAGE_DATA">
     <xsl:copy> 
       <xsl:apply-templates select="@*" /> 
       <xsl:value-of select="concat(., ' ', ../preceding-sibling::ns1:DNR2[1]/ns1:MESSAGE_DATA)" /> 
       <xsl:apply-templates select="*" /> 
     </xsl:copy> 
    </xsl:template>  
    
    </xsl:stylesheet>  
    

    Notes

    1. Use the power of the identity template to save you an enormous
      amount of script writing.
    2. Write templates to handle the desired variation from identity transformation.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this requirement from client where depending on the location of the iPhone
I have this requirement that i need to Update/Save all records from DatabaseA on
I have this kinda interesting requirement. Typically you use XSLT to transform an XML
I have this requirement of Uploading 1000s of Photos from a window application. Logic
I have this weird requirement to access scanner, barcode reader, camera etc. from an
I have this requirement: From my application I send a user an email link
I'm trying to fork 3 different child processes from a parent (and running this
I have this requirement to check for characters, numbers, and few special characters from
I have this unusual requirement from a client, and I am not quite sure
I have this java application and ran into a requirement to parse an STDF.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.