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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:02:55+00:00 2026-05-21T18:02:55+00:00

I have a 150 MB (it can go even more sometimes) XML file. I

  • 0

I have a 150 MB (it can go even more sometimes) XML file. I need to remove all the namespaces.
It’s on Visual Basic 6.0, so I’m using DOM to load the XML. Loading is okay, I was skeptical at first, but somehow that part works fine.

I am trying the following XSLT, but it removes all the other attributes also. I want to keep all the attributes and elements, I just need to remove the namespaces. Apparently it’s because I have xsl:element but not attribute. How can I include the attributes there?

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="UTF-8" />
    <xsl:template match="*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="@* | node()"/>
        </xsl:element>
    </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-05-21T18:02:56+00:00Added an answer on May 21, 2026 at 6:02 pm

    Your XSLT removes attributes also, because you don’t have a template that would copy them. <xsl:template match="*"> matches only elements, not attributes (or text, comments or processing instructions).

    Below is a stylesheet that removes all namespace definitions from the processed document but copies all other nodes and values: elements, attributes, comments, text and processing instructions. Please pay attention to 2 things

    1. Copying the attributes as such is not enough to remove all namespaces. Also an attribute can belong to a namespace, even when the containing element doesn’t belong to a namespace. Therefore also attributes need to be created, like elements. Creating attributes is done with <xsl:attribute> element.
    2. A valid XML document cannot contain an element that has two or more attributes with same expanded name but elements can contain multiple attributes with same local name if the attributes have different namespaces. This means that removing the namespace prefix from an attribute name will cause dataloss if there is an element that has at leas two attributes with same local name. Other one of these attributes will be removed (or overwritten).

    …and the code:

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
        <xsl:output indent="yes" method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
    
        <!-- Stylesheet to remove all namespaces from a document -->
        <!-- NOTE: this will lead to attribute name clash, if an element contains
            two attributes with same local name but different namespace prefix -->
        <!-- Nodes that cannot have a namespace are copied as such -->
    
        <!-- template to copy elements -->
        <xsl:template match="*">
            <xsl:element name="{local-name()}">
                <xsl:apply-templates select="@* | node()"/>
            </xsl:element>
        </xsl:template>
    
        <!-- template to copy attributes -->
        <xsl:template match="@*">
            <xsl:attribute name="{local-name()}">
                <xsl:value-of select="."/>
            </xsl:attribute>
        </xsl:template>
    
        <!-- template to copy the rest of the nodes -->
        <xsl:template match="comment() | text() | processing-instruction()">
            <xsl:copy/>
        </xsl:template>
    
    </xsl:stylesheet>
    

    You could also use <xsl:template match="node()"> instead of that last template but then you should use priority attribute to prevent elements matching to this template.

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

Sidebar

Related Questions

I have a rather large file (150 million lines of 10 chars). I need
I have got a class which contains more then 150 fields. i need the
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have about 150 000 rows of data written to a database everyday. These
I have a program where I generate bitstreams, of about 80 to 150 bits
I have multiple setTimeout functions like this: function bigtomedium(visiblespan) { visiblespan.removeClass('big').addClass('medium'); setTimeout(function(){ mediumtosmall(visiblespan);},150); };
Let's say I have two arrays: int ArrayA[] = {5, 17, 150, 230, 285};
Have just started using Google Chrome , and noticed in parts of our site,
We have an application where users enter prices all day. These prices are recorded
I have a file format (fastq format) that encodes a string of integers as

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.