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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:58:55+00:00 2026-05-23T06:58:55+00:00

In JAVA I copy nodes from one XML document to another new document using

  • 0

In JAVA I copy nodes from one XML document to another new document using importNode. In original document there is an xmlns defined, but in output document I would like to not have xmlns defined per each element that I copied. How to do it?

  • 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-23T06:58:56+00:00Added an answer on May 23, 2026 at 6:58 am

    Using javax.xml.transform.Transformer with XSL defined as below seems to be a good solution:

        String stylesheet = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" +
                "<xsl:output method=\"xml\" version=\"1.0\" indent=\"no\"/>" +
                "<xsl:template match=\"*\">" +
                "<xsl:element name=\"{local-name()}\">" +
                "<xsl:for-each select=\"@*\">" +
                "<xsl:attribute name=\"{local-name()}\">" +
                "<xsl:value-of select=\".\"/>" +
                "</xsl:attribute>" +
                "</xsl:for-each>" +
                "<xsl:apply-templates/>" +
                "</xsl:element>" +
                "</xsl:template>" +
                "</xsl:stylesheet>";
    
        StreamSource xslSource = new StreamSource(new StringReader(stylesheet));
        Transformer transformer = tf.newTransformer(xslSource);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In My App, I want to copy a node from one document to another
I have a java code for copy file from one folder to another folder.
I'm trying to read/copy a certain part of a xml document in JAVA and
clone method vs copy constructor in java. which one is correct solution. where to
I need to start a copy of a Rails app from within Java. I
I'm trying to execute a copy of the Perl interpreter using Java's Runtime.exec(). However,
java.util.Calendar.clone() returns ...a new Calendar with the same properties and returns a shallow copy
I want to create a small java application to copy some wiki content from
We're using a vendor licensed copy of the Tanuki Java Service Wrapper to start
Is there a way to deep copy 2 java objects by calling its getter

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.