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 8878909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:49:38+00:00 2026-06-14T19:49:38+00:00

I need to append child node into the parent node. Order_no under order_h is

  • 0

I need to append child node into the parent node. Order_no under order_h is equal to next sibiling the order_d should merge into parent node order_h

Here is the xml

 <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <order>
        <order_h owner="GD" order_no="421424" profoma_po="421425">
          <order_d owner="GD" item_no="100000014" line_no="1" order_no="421424" color_code="730" manufacturer="100783">
            <size assoc_id="69398" match_id="14" pack_code="BULK" size_range="2" model_name="SIZE SCALE 2" size_id="SIZE SCALE 2">
              <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602001" size_code="S" alloc_qty="26" plan_pct_ratio="34" row_no="0" sort_value="6"/>
              </Size_b>
              <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602182" size_code="L" alloc_qty="11" plan_pct_ratio="15" row_no="0" sort_value="8"/>
              </Size_b>
              <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602078" size_code="M" alloc_qty="21" plan_pct_ratio="27.5" row_no="0" sort_value="7"/>
              </Size_b>
              <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602060" size_code="XS" alloc_qty="18" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
              </Size_b>
            </size>
          </order_d>
    </order_h>
        <order_h owner="GD" order_no="421424" profoma_po="421425">
          <order_d owner="GD" item_no="100000014" line_no="3" order_no="421424" color_code="002" manufacturer="100783">
            <size assoc_id="69400" match_id="14" pack_code="BULK" size_range="2" model_name="SIZE SCALE 2" size_id="SIZE SCALE 2">
              <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602019" size_code="S" alloc_qty="17" plan_pct_ratio="34" row_no="0" sort_value="6"/>
              </Size_b>
              <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602238" size_code="M" alloc_qty="14" plan_pct_ratio="27.5" row_no="0" sort_value="7"/>
              </Size_b>
              <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602131" size_code="XS" alloc_qty="12" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
              </Size_b>
              <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602027" size_code="L" alloc_qty="8" plan_pct_ratio="15" row_no="0" sort_value="8"/>
              </Size_b>
            </size>
          </order_d>
        </order_h>
    </order>
    </document>

and expected xml output is below

<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<order>
<order_h owner="GD" order_no="421424" profoma_po="421425">
  <order_d owner="GD" item_no="100000014" line_no="1" order_no="421424" color_code="730" manufacturer="100783">
    <size assoc_id="69398" match_id="14" pack_code="BULK" size_range="2" model_name="SIZE SCALE 2" size_id="SIZE SCALE 2">
      <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
        <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602001" size_code="S" alloc_qty="26" plan_pct_ratio="34" row_no="0" sort_value="6"/>
      </Size_b>
      <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
        <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602182" size_code="L" alloc_qty="11" plan_pct_ratio="15" row_no="0" sort_value="8"/>
      </Size_b>
      <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
        <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602078" size_code="M" alloc_qty="21" plan_pct_ratio="27.5" row_no="0" sort_value="7"/>
      </Size_b>
      <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
        <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602060" size_code="XS" alloc_qty="18" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
      </Size_b>
    </size>
  </order_d>
  <order_d owner="GD" item_no="100000014" line_no="3" order_no="421424" color_code="002" manufacturer="100783">
    <size assoc_id="69400" match_id="14" pack_code="BULK" size_range="2" model_name="SIZE SCALE 2" size_id="SIZE SCALE 2">
      <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
        <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602019" size_code="S" alloc_qty="17" plan_pct_ratio="34" row_no="0" sort_value="6"/>
      </Size_b>
      <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
        <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602238" size_code="M" alloc_qty="14" plan_pct_ratio="27.5" row_no="0" sort_value="7"/>
      </Size_b>
      <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
        <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602131" size_code="XS" alloc_qty="12" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
      </Size_b>
      <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
        <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602027" size_code="L" alloc_qty="8" plan_pct_ratio="15" row_no="0" sort_value="8"/>
      </Size_b>
    </size>
  </order_d>
</order_h>
</document>

Thanks in advance

  • 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-14T19:49:39+00:00Added an answer on June 14, 2026 at 7:49 pm

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="order_h"/>
    
     <xsl:template match="order_h[1]">
      <xsl:copy>
       <xsl:apply-templates select=
        "@*|node()|following-sibling::*/node()"/>
      </xsl:copy>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied to the provided XML document:

    <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <order>
            <order_h owner="GD" order_no="421424" profoma_po="421425">
                <order_d owner="GD" item_no="100000014" line_no="1" order_no="421424" color_code="730" manufacturer="100783">
                    <size assoc_id="69398" match_id="14" pack_code="BULK" size_range="2" model_name="SIZE SCALE 2" size_id="SIZE SCALE 2">
                        <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                            <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602001" size_code="S" alloc_qty="26" plan_pct_ratio="34" row_no="0" sort_value="6"/>
                        </Size_b>
                        <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                            <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602182" size_code="L" alloc_qty="11" plan_pct_ratio="15" row_no="0" sort_value="8"/>
                        </Size_b>
                        <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                            <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602078" size_code="M" alloc_qty="21" plan_pct_ratio="27.5" row_no="0" sort_value="7"/>
                        </Size_b>
                        <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                            <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602060" size_code="XS" alloc_qty="18" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
                        </Size_b>
                    </size>
                </order_d>
            </order_h>
            <order_h owner="GD" order_no="421424" profoma_po="421425">
                <order_d owner="GD" item_no="100000014" line_no="3" order_no="421424" color_code="002" manufacturer="100783">
                    <size assoc_id="69400" match_id="14" pack_code="BULK" size_range="2" model_name="SIZE SCALE 2" size_id="SIZE SCALE 2">
                        <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                            <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602019" size_code="S" alloc_qty="17" plan_pct_ratio="34" row_no="0" sort_value="6"/>
                        </Size_b>
                        <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                            <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602238" size_code="M" alloc_qty="14" plan_pct_ratio="27.5" row_no="0" sort_value="7"/>
                        </Size_b>
                        <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                            <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602131" size_code="XS" alloc_qty="12" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
                        </Size_b>
                        <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                            <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602027" size_code="L" alloc_qty="8" plan_pct_ratio="15" row_no="0" sort_value="8"/>
                        </Size_b>
                    </size>
                </order_d>
            </order_h>
        </order>
    </document>
    

    produces the wanted, correct result:

    <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <order>
          <order_h owner="GD" order_no="421424" profoma_po="421425">
             <order_d owner="GD" item_no="100000014" line_no="1" order_no="421424" color_code="730" manufacturer="100783">
                <size assoc_id="69398" match_id="14" pack_code="BULK" size_range="2" model_name="SIZE SCALE 2" size_id="SIZE SCALE 2">
                   <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                      <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602001" size_code="S" alloc_qty="26" plan_pct_ratio="34" row_no="0" sort_value="6"/>
                   </Size_b>
                   <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                      <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602182" size_code="L" alloc_qty="11" plan_pct_ratio="15" row_no="0" sort_value="8"/>
                   </Size_b>
                   <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                      <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602078" size_code="M" alloc_qty="21" plan_pct_ratio="27.5" row_no="0" sort_value="7"/>
                   </Size_b>
                   <Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                      <size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602060" size_code="XS" alloc_qty="18" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
                   </Size_b>
                </size>
             </order_d>
             <order_d owner="GD" item_no="100000014" line_no="3" order_no="421424" color_code="002" manufacturer="100783">
                <size assoc_id="69400" match_id="14" pack_code="BULK" size_range="2" model_name="SIZE SCALE 2" size_id="SIZE SCALE 2">
                   <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                      <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602019" size_code="S" alloc_qty="17" plan_pct_ratio="34" row_no="0" sort_value="6"/>
                   </Size_b>
                   <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                      <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602238" size_code="M" alloc_qty="14" plan_pct_ratio="27.5" row_no="0" sort_value="7"/>
                   </Size_b>
                   <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                      <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602131" size_code="XS" alloc_qty="12" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
                   </Size_b>
                   <Size_b assoc_id="69400" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
                      <size_d assoc_id="69400" ship_pack="BULK" ctn_sku="5602027" size_code="L" alloc_qty="8" plan_pct_ratio="15" row_no="0" sort_value="8"/>
                   </Size_b>
                </size>
             </order_d>
          </order_h>
       </order>
    </document>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xml file, and i need to append a child to it
I need to make a car a child node of a track. I have
My xml :- <users> </users> i need to just append a child element :-
I need to create multiple Child Nodes in one element node in XML, do
I need to append multiple nodes to a container. Rather than doing a slow
I need to append some text to an input field...
I need to append log4j content to a Swing component (JTextArea or similar). Is
I need to append text repeatedly to an existing file in Java. How do
I am returning query results from MySQL and I need to append them to
All my div blocks use the same class name and I need to append

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.