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

  • Home
  • SEARCH
  • 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 7652693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:50:15+00:00 2026-05-31T11:50:15+00:00

need to convert an xml file having a tag(dynamicVariable) that has an attribute(name).This xml

  • 0

need to convert an xml file having a tag(dynamicVariable) that has an attribute(name).This xml file has to be converted using xsl into the same xml file such that the tag (dynamicVariable) should have the same structure along with it and its the tag-content also should be the value of the attribute.

need to convert the below xml file

   <Content>
     <alertHeader>
         <text xmlns="http://abc.com" xmlns:w="http://def.com"> Claim  
           <dynamicVariable name="Claim_Reference" />: More Information Needed
         </text>
         <contactUs>false</contactUs>
     </alertHeader>


     <body>
         <text> ATM/Debit Card Claim: 
         <strong><dynamicVariable name="Claim_Reference" /></strong>
         </text>
     </body>

         </Content>

into the same format but the tag having ‘name’ attribute should appear in the output xml file as this format

      <dynamicVariable name="Claim_Reference" />Claim_Reference</dynamicVariable>

Can anyone provide the necessary xsl file in converting the same. Hope that its done using

    <xsl:copy></xsl:copy>  or <xsl:copy-of /> tags .
  • 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-31T11:50:16+00:00Added an answer on May 31, 2026 at 11:50 am

    As simple as this:

    <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="*[name() = 'dynamicVariable']">
          <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:value-of select="@name"/>
          </xsl:copy>
         </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document:

    <Content>
        <alertHeader>
            <text xmlns="http://abc.com" xmlns:w="http://def.com"> Claim              
                <dynamicVariable name="Claim_Reference" />: More Information Needed          
            </text>
            <contactUs>false</contactUs>
        </alertHeader>
        <body>
            <text> ATM/Debit Card Claim:           
                <strong>
                    <dynamicVariable name="Claim_Reference" />
                </strong>
            </text>
        </body>
    </Content>
    

    the wanted, correct result is produced:

    <Content>
       <alertHeader>
          <text xmlns="http://abc.com" xmlns:w="http://def.com"> Claim
                <dynamicVariable name="Claim_Reference">Claim_Reference</dynamicVariable>: More Information Needed
            </text>
          <contactUs>false</contactUs>
       </alertHeader>
       <body>
          <text> ATM/Debit Card Claim:
                <strong>
                <dynamicVariable name="Claim_Reference">Claim_Reference</dynamicVariable>
             </strong>
          </text>
       </body>
    </Content>
    

    Explanation:

    1. The identity rule copies every node “as-is”.

    2. A single template overrides the identity template. It matches any that has athe name “dynamicVariable” regardless of namespace, and that is a child of strong (thus specifying more context helps us process only this occurence of dynamicVariable but leave the preceding one “as-is”).

    3. The overriding tempalte shallo-copies the current node, then copies its attributes, then finally creates a text-node child whose contents is the string value of the name attribute of the current (matched) element.

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

Sidebar

Related Questions

I have an xml file that is like this: <xml>I need this text<notthistext>blahblah<notthistext></xml> I
I have xml file and I need to convert the text that I get
We are using XSL to convert a XML file into a pipe-delimited format. <?xml
I am in a need of programatically convert an Word-XML file into a RTF
I have an xml document object that I need to convert into a string.
I need to convert text file to XML file through C# application. Can any
I have a project where I need to convert a XML file to CSV
I need to write and update XML file based on nodes. For that I
I am parsing through a XML file that's about 12mb big. I need to
I need a stylesheet to convert my docbook xml files so that they now

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.