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

  • Home
  • SEARCH
  • 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 8326621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:49:15+00:00 2026-06-09T00:49:15+00:00

I am getting duplicate records with the following xml and xsl file. I only

  • 0

I am getting duplicate records with the following xml and xsl file. I only want to transform 1 set of the list items. Try not removing anything from the xsl part (just add to it), if possible.

<?xml version="1.0" encoding="utf-8" ?>
<data>
  <listitems name="Select..." CtrId="Id2"/>
  <listitems name="Item A" CtrId="Id2"/>
  <listitems name="Item B" CtrId="Id2"/>
  <listitems name="Select..." CtrId="Id4"/>
  <listitems name="Item A" CtrId="Id4"/>
  <listitems name="Item B" CtrId="Id4"/>  
  <listitems name="Select..." CtrId="Id6"/>
  <listitems name="Item C" CtrId="Id6"/>
  <listitems name="Item D" CtrId="Id6"/>  
</data>

 

  <xsl:template match="data/listitems">
    <html>
      <head>
        <title>Untitled</title>
      </head>
      <body>
        <xsl:value-of select="@name"/>
      </body>
    </html>
  </xsl:template>

 

Result (Incorrect behavior; Duplicate)
Select… Item A Item B Select… Item A Item B

Desired behavior (Only get 1 set)
Select… Item A Item B

  • 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-09T00:49:17+00:00Added an answer on June 9, 2026 at 12:49 am

    Here’s a relatively simple way of doing this:

    <xsl:param name="useId" select="/data/listitems[1]/@CtrId" />
    
    <xsl:template match="/">
      <html>
        <head>
          <title>Untitled</title>
        </head>
        <body>
          <xsl:apply-templates select="data/listitems[@CtrId = $useId]"/>
        </body>
      </html>
    </xsl:template>
    
    <xsl:template match="listitems">
      <xsl:value-of select="concat(@name, ' ')" />
    </xsl:template>
    

    Your existing template will actually put in an html element for every listitems element- it seems fairly likely that you probably only want the one.

    The <xsl:param> declaration at the top picks the first CtrId in the file, and uses that. You can change that to a literal value with select="'Id2'" (note the single quotes inside the double quotes), or you can pass a parameter into the stylesheet with the ID you want to pick out.

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

Sidebar

Related Questions

Possible Duplicate: Getting Filename from file descriptor in C Obtain filename from file pointer
Possible Duplicate: Getting Cross-thread operation not valid Cross-thread operation not valid I am trying
Possible Duplicate: Getting a FILE* from a std::fstream Is there a way to obtain
I have tried this query to get the duplicate records.but I am getting this
I'm having trouble getting the results to show up right, I want a list
I want to know the probability of getting duplicate values when calling the GetHashCode()
I am trying to print the duplicate records of the table but only the
This question is not a duplicate of Get data file from microphone in windows
I keep getting duplicate entries in my database because of impatient users clicking the
I am getting duplicate error in my xcode while build and run I have

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.