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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:01:52+00:00 2026-05-25T22:01:52+00:00

Below is my XML. I wanted to parse this using XSL. What I want

  • 0

Below is my XML. I wanted to parse this using XSL. What I want to achieve is to remove the namespace (xmlns) then just retain some of the elements and their attributes. I found a way to remove the namespace but when I put it together with the code to retain some of the elements, it doesn’t work. I already tried the identity but still didn’t work.

I hope someone out there could share something. Thank you very much in advance.

XML Input:

<Transaction xmlns="http://www.test.com/rdc.xsd">
    <Transaction>
       <StoreName id="aa">STORE A</StoreName>
       <TransNo>TXN0001</TransNo>
       <RegisterNo>REG001</RegisterNo>
       <Items>
          <Item id="1">
             <ItemID>A001</ItemID>
             <ItemDesc>Keychain</ItemDesc>
          </Item>
          <Item id="2">
             <ItemID>A002</ItemID>
             <ItemDesc>Wallet</ItemDesc>
          </Item>
       </Items>
       <IDONTLIKETHIS_1>
          <STOREXXX>XXX-</STOREXXX>
          <TRANSXXX>YYY</TRANSXXX>
       </IDONTLIKETHIS_1>
       <IDONTLIKETHIS_2>
          <STOREXXX>XXX-</STOREXXX>
          <TRANSXXX>YYY</TRANSXXX>
       </IDONTLIKETHIS_2>
    </Transaction>
<Transaction>

Expected XML Output:

<Transaction>
    <Transaction>
       <StoreName id="aa">STORE A</StoreName>
       <TransNo>TXN0001</TransNo>
       <RegisterNo>REG001</RegisterNo>
       <Items>
          <Item id="1">
             <ItemID>A001</ItemID>
             <ItemDesc>Keychain</ItemDesc>
          </Item>
          <Item id="2">
             <ItemID>A002</ItemID>
             <ItemDesc>Wallet</ItemDesc>
          </Item>
       </Items>
    </Transaction>
<Transaction>

Code used to remove the namespace (xmlns):

<xsl:template match="*">
   <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
   </xsl:element>
</xsl:template>

<xsl:template match="@*">
   <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
   </xsl:attribute>
</xsl:template>
  • 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-25T22:01:52+00:00Added an answer on May 25, 2026 at 10:01 pm
    <xsl:stylesheet version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:x="http://invia.fujitsu.com/RetailDATACenter/rdc.xsd">
         <xsl:output omit-xml-declaration="yes" indent="yes"/>
         <xsl:strip-space elements="*"/>
    
         <xsl:template match="*">
          <xsl:element name="{name()}">
           <xsl:copy-of select="@*"/>
           <xsl:apply-templates select="node()"/>
          </xsl:element>
         </xsl:template>
    
         <xsl:template match="node()[not(self::*)]">
          <xsl:copy-of select="."/>
         </xsl:template>
    
         <xsl:template match="x:IDONTLIKETHIS_1 | x:IDONTLIKETHIS_2"/>
    </xsl:stylesheet>
    

    Explanation:

    1. The template matching “*” matches any element and recreates it (<xsl:element>) with the same name, but doesn’t copy any namespace nodes. It also copies all attributes of this element. Then it applies templates (including itself — recursively) on all of this element’s children nodes — not only elements but all types of children nodes: elements, text nodes, processing-instructions and comments.

    2. The last template matches any node we don’t like to copy to the output and does exactly this (no copying ) with an empty template body.

    3. The second template matches and copies to the output all nodes that aren’t elements, excluding the document node /

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

Sidebar

Related Questions

I've got the following below XML and would like to parse this with JQuery
How do I add CDATA to the ViolationInfo in this below XML <Violations ViolationNo=1
I need to generate an xsl table for the xml below, for attributes fname
I have an xml document that I am creating using the loop below and
want to query below xml <courseList filedUnder=Courses> <category code=4wd title=4wd Operation> <product code=lr title=4wd
I'm trying to select the content of MINRANGE of the below XML. This is
I have a XML like the below. Here I wanted to slect the attribute
I am using the below code to iterate through multiple nodes of XML but
I'm using xml.dom.mindom in Python and have retrieved the book node in the below
I am using php xpath to get the values from the below xml feed

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.