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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:51:52+00:00 2026-05-19T10:51:52+00:00

I have some original file with a header I want to change for another

  • 0

I have some original file with a header I want to change for another one (stored i other file):

original file:

<doc1>
    <header>
        <a>aaaa</a>
        <b>bbbb</b>
    </header>
    <content>
      <z>zzzzzzzzzzzzz</z>
    </content>
</doc1>

new header (in a file):

<header>
    <c>cccc</c>
</header>

expected result:

    <doc1>
    <header>
        <c>cccc</c>
    </header>
    <content>
      <z>zzzzzzzzzzzzz</z>
    </content>
</doc1>

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-05-19T10:51:52+00:00Added an answer on May 19, 2026 at 10:51 am

    This transformation (for demo-only purposes the new header is imbedded in the XSLT stylesheet):

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:my="my:my">
     <xsl:output omit-xml-declaration="yes"/>
    
     <my:header>
       <header>
        <c>cccc</c>
       </header>
     </my:header>
    
     <xsl:variable name="vHeaderDoc" select="document('')/*/my:header"/>
        <xsl:template match="node()|@*">
          <xsl:copy>
             <xsl:apply-templates select="node()|@*"/>
          </xsl:copy>
        </xsl:template>
    
        <xsl:template match="header">
         <xsl:copy-of select="$vHeaderDoc/*"/>
        </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <doc1>
        <header>
            <a>aaaa</a>
            <b>bbbb</b>
        </header>
        <content>
            <z>zzzzzzzzzzzzz</z>
        </content>
    </doc1>
    

    produces the wanted, correct result:

    <doc1>
        <header xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="my:my">
        <c>cccc</c>
       </header>
        <content>
            <z>zzzzzzzzzzzzz</z>
        </content>
    </doc1>
    

    In the real case you will have:

     <xsl:variable name="vHeaderDoc" select="document('Header.xml')"/>
    

    and the header document will be in the file named 'Header.xml' that resides in the same directory as the XSLT stylesheet (if in another directory, then change the document URL accordingly).

    In the real case, no xsl: namespace node will be copied on the header element.

    Do note: The use of the standard XSLT function document().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the problem: I have to change header of WAVE file, to be
I have a huge xml file (1 Gig). I want to move some of
Let's say I have some original text: here is some text that has a
Edit: original question below, but I revise it now that I have some code
I have some arbitrary pixel data that I want to save as a PNG.
I have some code that will change the background color of a specific label
I have some C code that should print the entire contents of a file.
I have some problems decrypting a file encrypted with openssl in a bash. Below
I have the following like data in a tab-delimted text file named original Name
Assume that I have some HTML page, and a corresponding CSS file. I'd like

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.