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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:07:33+00:00 2026-05-23T13:07:33+00:00

Is it possible to remove xml attributes from XSLT AND work with the resulting

  • 0

Is it possible to remove xml attributes from XSLT AND work with the resulting transform?

In other words, I have the following XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="XML_TEST.xslt"?>
<report xmlns="abc123">
<book>
<page id="22">

</page>
<page id="23">

</page>
</book>
</report>

I know that I can use the following XSLT to strip the attributes:

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

But if I wanted to read the values, using the following template

<xsl:template match="report">
    <xsl:for-each select="book/page">
        <xsl:value-of select="@id"/>
    </xsl:for-each>
</xsl:template>

Could I chain that template to the output of the first two?

Thanks in advance,

-R.

  • 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-23T13:07:34+00:00Added an answer on May 23, 2026 at 1:07 pm

    Is it possible to remove xml
    attributes from XSLT AND work with the
    resulting transform?

    Yes, just search for “multi-pass transformation” and you’ll find many answers with good code examples.

    However, for what you want to do such transformation chaining is overly complex and completely unnecessary.

    Just use:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:x="abc123" >
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="x:page">
      <xsl:value-of select="@id"/>
     </xsl:template>
    </xsl:stylesheet>
    

    And in case the default namespace of the XML document isn’t known in advance, you can still produce the wanted results in a single pass:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="*[name()='page']">
      <xsl:value-of select="@id"/>
     </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I looked at How to remove duplicate XML nodes using XSLT and other related
Is it possible to get an XML file (not HTML) from a server, add/remove/edit
Possible Duplicate: Regex Remove Images with style tag from Html PHP XML remove element
Is it possible to remove the opacity inheritance from a parent to it's child
Is it possible to completely remove a revision from a bazaar repository? I'm asking
Possible Duplicate: php multi-dimensional array remove duplicate I have an array like this: $a
It is possible to add and remove elements from an enum in Java at
Possible Duplicate: XmlSerializer: remove unnecessary xsi and xsd namespaces I'm generating some XML using
I'm filtering all user input to remove the following characters: http://www.w3.org/TR/unicode-xml/#Charlist (not suitable characters
XmlElement.Attributes.Remove* methods are working fine for arbitrary attributes resulting in the removed attributes being

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.