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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:17:17+00:00 2026-06-10T05:17:17+00:00

I want to remove spaces from all attributes in my xmls using xslt. I

  • 0

I want to remove spaces from all attributes in my xmls using xslt. I used strip-space, but that removes the spaces from nodes.
My input xml is:

<OrderList>
<Order OrderDate="26-July" OrderNo="ORDER 12345"
 CustomertName="JOHN DOE" OrderKey="ORDKEY12345">
<ShipAddress AddressLine="ABC Colony" FirstName="John" LastName="Doe "/>
</Order>
</OrderList>

and the xsl I used to get rid of the spaces in the attributes like CustomertName="JOHN DOE" is:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/> 
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:apply-templates/>
<OrderList>
    <xsl:for-each select="OrderList/Order">
        <xsl:element name="Order">
            <xsl:copy-of select="@OrderDate"/>
            <xsl:copy-of select="@OrderNo"/>
            <xsl:copy-of select="@CustomertName"/>

            <!-- ShipAddress begins -->
            <xsl:element name="ShipAddress">                                           
                <xsl:copy-of select="ShipAddress/@AddressLine"/>
                <xsl:copy-of select="ShipAddress/@FirstName"/>
                <xsl:copy-of select="ShipAddress/@LastName"/>                       
            </xsl:element>
        </xsl:element>
    </xsl:for-each>             
</OrderList>
</xsl:template>
</xsl:stylesheet> 

But this leaves the input xml as it was. I want to remove the spaces from the attribute values at all levels.

  • 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-06-10T05:17:19+00:00Added an answer on June 10, 2026 at 5:17 am

    You can use the translate function, like so, although it would make sense to refactor this with a call template:

    <xsl:attribute name="OrderDate">
        <xsl:value-of select="translate(@OrderDate, ' ','')"/>
    </xsl:attribute>
    <xsl:attribute name="OrderNo">
        <xsl:value-of select="translate(@CustomertName, ' ','')"/>
    </xsl:attribute>
    <xsl:attribute name="CustomertName">
        <xsl:value-of select="translate(@CustomertName, ' ','')"/>
    </xsl:attribute>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to remove all special characters except space from a string using JavaScript.
I want to remove all the white spaces from a given text file. Is
I want to remove all non-alphanumeric and space characters from a string. So I
i want to remove the link from my header using CSS so that only
I want to remove spaces from strings where the space is preceeded by a
I want to remove all spaces from a string in Lua. This is what
I want to modify (Remove all white spaces) all the values of Column Name
Hi I have this code, I want it to remove all the double spaces
How can I remove all white-spaces from ASP.NET MVC 3 output? UPDATE: I know
I want to remove trailing white spaces and tabs from my code without removing

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.