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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:23:53+00:00 2026-06-13T09:23:53+00:00

I am new to XSLT and am having a problem with removing duplicates from

  • 0

I am new to XSLT and am having a problem with removing duplicates from a simple XML file. Spent a lot of time trying to get it but it’s never quite right. Here is the source file:

<?xml version="1.0" encoding="UTF-16"?>
<language>
    <lang name="welcome">welcom</lang>
    <lang name="open">Open</lang>
    <lang name="close">Close</lang>
    <lang name="welcome">Welcome</lang>
    <lang name="copy">Copy</lang>
</language>

Desired output is this:

<?xml version="1.0" encoding="UTF-16"?>
<language>
    <lang name="open">Open</lang>
    <lang name="close">Close</lang>
    <lang name="welcome">Welcome</lang>
    <lang name="copy">Copy</lang>
</language>

The actual files are much larger than this and “lang” and “name” may change later in the file, and I only want to keep the last duplicate. Basically, if the tag and attributes are duplicated, only keep the last entry. I hope this is possible with XSLT 1.0. If not, I can always use multiple scripts in case lang does change to something else. Thank you in advance!

  • 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-13T09:23:54+00:00Added an answer on June 13, 2026 at 9:23 am

    The following XSLT should answer your question :

        <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
        <xsl:template match="node()|@*">
            <xsl:copy>
                <xsl:apply-templates select="node()|@*"/>
            </xsl:copy>
        </xsl:template>
        <xsl:template match="lang[@name=following-sibling::lang/@name]"/>
    </xsl:stylesheet>
    

    This way, you filter every lang element that have a following sibling lang element with the same value for the name attribute.

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

Sidebar

Related Questions

I'm new to XML/XSLT and am having an issue trying to change an image
I am having a problem trying to sort with an XSL file using the
I'm having a problem. How can I instruct my XSLT to insert a new
I am very new to XSLT and I am having a hard time understanding
I want to change from one XML (XHTML) file to another using XSLT. In
Hey I'm pretty new to XSLT's and trying to get my head around using
I am having a problem where one XSLT file imports another, causing my application
I am new to XSLT and have spent hours trying to figure out a
I am new to xslt and trying to create one XSLT , I am
i am pretty new to XSLT / XML and HTML. I have a XML

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.