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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:24:11+00:00 2026-05-18T00:24:11+00:00

I have an XML document that have additonal nodes in it at different levels

  • 0

I have an XML document that have additonal nodes in it at different levels that I want to remove via XSLT.

My intuition is to generate an XSD (using Altova or the like), remove the elements I don’t want to appear in my output, then let the editor (Altova or the like) auto generate an XSLT to transform the old XSD into the new XSD.

Back in the day, I used to write XSL for this by hand…but with all these cool tools, is there really a reason to or can someone suggest an alternative way? I haven’t done this stuff in a couple of years, so I figured I would ask…

I ended up coming up with this, which is pretty simple, so thanks for the suggestion:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" >
<xsl:output method="xml" indent="yes"/>

  <xsl:template xpath-default-namespace="http://www.tempuri.org" match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template xpath-default-namespace="http://www.tempuri.org" match="SomeNode">
  </xsl:template>
  <xsl:template xpath-default-namespace="http://www.tempuri.org" match="TheNode[@type!='SomeType' and @type!='OtherType']">
  </xsl:template>

</xsl:stylesheet>

The one remaining thing I need to do is check for a missing element “SomeSubElement” of “TheNode” and insert an empty element if it’s missing.

Any suggestions on how to do this? Thanks.

  • 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-18T00:24:12+00:00Added an answer on May 18, 2026 at 12:24 am

    A simple identity transform with empty templates for what you want to discard:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      version="2.0">
    
      <xsl:template match="@*|node()">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="tagToBeRemoved"/>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML document that I want to generate unique IDs for. Some
I have an XML document that I'm trying to style via CSS. A relevant
I have an XML document that I generate from an Entity Framework object. The
I have an XML document that contains a series of item nodes that look
I have an XML document snippet that matches this XSD: <xs:complexType name=QuestionType> <xs:sequence> <xs:element
I have an XML document that I load in and try to search with
I have an xml document that looks like this. <foo> <bar type=artist/> Bob Marley
Say I have a xml document that looks like this <foo> <bar id=9 />
In my Python app, I have an XML document that I'd like to transform
Have a source xml document that uses namespace containing prefixes and a default namespace.

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.