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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:13:11+00:00 2026-05-30T21:13:11+00:00

I have xml like <programs> <program name=breaking laws id=97;#ttt;#98;#tpl;#41;#fel /> <program name=advanced technology id=89;#hjk;#95;#uio;#81;#lpk

  • 0

I have xml like

<programs>
 <program name="breaking laws" id="97;#ttt;#98;#tpl;#41;#fel" />
   <program name="advanced technology" id="89;#hjk;#95;#uio;#81;#lpk" />
 <program name="Emerging companies " id="88;#ple;#98;#tpl;#41;#fel" />
 <program name="breakinglaws" id="97;#ttt" />
 <program name="breakinglaws" id="97;#ttt;#98;#tpl;#81;#lpk" />
 <program name="breakinglaws" id="99;#hklo;#95;#uio" />
</programs>

I would like to find all the unique ids text using xslt 1.0 i.e

ttt
tpl
fel
hjk
uio
lpk
ple
hklo

I was trying to do something using key and output tokens

<xsl:template name="output-tokens">
        <xsl:param name="list" />
        <xsl:variable name="newlist" select="concat(normalize-space($list), ' ')" />
        <xsl:variable name="first" select="substring-before($newlist, ';#')" />
        <xsl:variable name="remaining" select="substring-after($newlist, ';#')" />
        <id>
            <xsl:value-of select="$first" />
        </id>
        <xsl:if test="$remaining">
            <xsl:call-template name="output-tokens">
                <xsl:with-param name="list" select="$remaining" />
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
  • 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-30T21:13:12+00:00Added an answer on May 30, 2026 at 9:13 pm

    Here is one solution

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
    
       <xsl:template match="/programs">
          <!-- Variable containing concateneated list of all program elements**
          <xsl:variable name="allprograms">
             <xsl:apply-templates select="program"/>
          </xsl:variable>
    
          <!-- Call recursive template to split the list -->
          <xsl:call-template name="output-tokens">
             <xsl:with-param name="list" select="$allprograms" />
          </xsl:call-template>
       </xsl:template>
    
       <!-- Template used to concatenate all program elements -->
       <xsl:template match="program">
          <xsl:value-of select="concat(@id, ';#') "/>
       </xsl:template>
    
       <!-- Recursive template to split out list into unique elements -->
       <xsl:template name="output-tokens">
          <!-- List to split -->
          <xsl:param name="list"/>
          <!-- List of all currently processed elements -->
          <xsl:param name="newlist" select="';#'" />
    
          <!-- Get first variable in list, and also the remaining part of the list -->
          <xsl:variable name="first" select="substring-before($list, ';#')"/>
          <xsl:variable name="remaining" select="substring-after($list, ';#')"/>
    
          <!-- Check if first variable is not a number, and is not contained in currently processed list -->
          <xsl:if test="number($first) != number($first) and not(contains($newlist, concat(';#', $first, ';#')))">
             <id>
                <xsl:value-of select="$first"/>
             </id>
          </xsl:if>
    
          <!-- If there are still elements left in the list, call the template recursively -->
          <xsl:if test="$remaining">
             <xsl:call-template name="output-tokens">
                <xsl:with-param name="list" select="$remaining"/>
                <xsl:with-param name="newlist" select="concat($newlist, $first, ';#')"/>
             </xsl:call-template>
          </xsl:if>
       </xsl:template>
    </xsl:stylesheet>
    

    The idea is you first build up a single string containing all the program elements concatenated together. You then call a recursive template which gets the first element from the list, and then checks it has not already been processed (this is achieved by the template also containing a variable of already processed elements)

    When the XSLT is applied to your sample XML, the following is output:

    <id>ttt</id>
    <id>tpl</id>
    <id>fel</id>
    <id>hjk</id>
    <id>uio</id>
    <id>lpk</id>
    <id>ple</id>
    <id>hklo</id>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have xml like this: <configurationData> <path name='b'> <path name='a'> <setting name='s1'> ![CDATA[XXXX]] </setting>
I have xml structure like this: <Group id=2 name=Third parentid=0 /> <Group id=6 name=Five
I have an xml like the following <DataCollection> <Data> <Name>John</Name> <Age>30</Age> </Data> ... more
I have some xml like this: <Data> <Rows> <Row> <Field Name=title>Mr</Field> <Field Name=surname>Doe</Field> <Row>
I ran into the following problem. I have an xml-file like this: <Source Name
I have a program that I would like to display the name and house
I have XML like, <items> <item> <products> <product>laptop</product> <product>charger</product> <product>Cam</product> </products> </item> <item> <products>
If I have XML like: <foo> <bar id=1 score=192 /> <bar id=2 score=227 />
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
I have an XML like this: <EXP> <TITLES> <SUBTITLE CL=AXT4 FL=1 NB=Text 1/> </TITLES>

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.