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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:19:37+00:00 2026-05-23T19:19:37+00:00

I have some trouble trying to setup a template to solve address this situation:

  • 0

I have some trouble trying to setup a template to solve address this situation:

My xml looks like:

<root>
     <recordset name="companies">
               <record>
                    <id>1</id>
                    <description>Company 1</description>
               </record>
               <record><id>2</id><description>Company 2</description></record>
               ...
               <record><id>n</id><description>Company n</description></record>
     </recordset>
     <gruppi>
          <supplier>
               <agreement>1</agreement>
               <company>
                    <id>3</id>
                    <description>Compoany 3</description>
               </company>
               <company>
                    <id>7</id>
                    <description>Company 7</description>
               </company>
          </supplier>
          ... <!-- a lot of supplier --> ...
          <supplier>
               <agreement>3</agreement>
               <company>
                    <id>1</id>
                    <description>Company 1</description>
               </company>
               <company>
                    <id>18</id>
                    <description>Company 18</description>
               </company>
          </supplier>
     </gruppi>        
</root>

My aim is to have a template able to perform the following processing: for each supplier within gruppi I wish to output a list of all record within recordset name=”companies” EXCEPT for the record whose id is already contained in the id element descendent of the current supplier element.

In other words: for each supplier I should create a set of html options listing all the companies (id as values) not including the companies already included in the supplier

I am tried to use xsl:key and some recursion but I found this task quite involved and I am running out of ideas. Someone has a hint to solve this problem?

Thanks for any help!

@polishchuk: the xml input is quite a big file, so I extracted the structure I am interested in filling with few generic data. About the output I am looking for something like this:

<h1>Agreement: 1</h1>
<select>
     <option value="1"></option>
          ....                                                  <!-- WITHOUT values 3 and 7 -->
     <option value="N"></option>
</select>

<h1>Agreement: 3</h1>
<select>
     <option value="1"></option>
          ....                                                  <!-- WITHOUT values 1 and 18 -->
     <option value="N"></option>
</select>
  • 1 1 Answer
  • 1 View
  • 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-23T19:19:38+00:00Added an answer on May 23, 2026 at 7:19 pm

    XSLT:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >
        <xsl:output method="xml" indent="yes"/>
    
        <xsl:template match="/">
            <xsl:apply-templates select="//supplier"/>
        </xsl:template>
    
        <xsl:template match="supplier">
            <h1>
                <xsl:text>Agreement:&#xA0;</xsl:text>
                <xsl:value-of select="agreement"/>
            </h1>
            <select>
                <xsl:for-each select="//recordset[@name = 'companies']/record[not(id = current()/company/id)]">
                    <option value="{id}">
                        <xsl:value-of select="id"/>
                    </option>
                </xsl:for-each>
            </select>
        </xsl:template>
    </xsl:stylesheet>
    

    Supposed XML:

    <root>
        <recordset name="companies">
            <record>
                <id>1</id>
                <description>Company1</description>
            </record>
            <record>
                <id>2</id>
                <description>Company2</description>
            </record>
            <record>
                <id>3</id>
                <description>Company3</description>
            </record>
            <record>
                <id>4</id>
                <description>Company4</description>
            </record>
            <record>
                <id>5</id>
                <description>Company5</description>
            </record>
        </recordset>
        <gruppi>
            <supplier>
                <agreement>1</agreement>
                <company>
                    <id>1</id>
                </company>
                <company>
                    <id>2</id>
                </company>
            </supplier>
            <supplier>
                <agreement>2</agreement>
                <company>
                    <id>1</id>
                </company>
                <company>
                    <id>3</id>
                </company>
            </supplier>
            <supplier>
                <agreement>3</agreement>
                <company>
                    <id>4</id>
                </company>
                <company>
                    <id>5</id>
                </company>
            </supplier>
        </gruppi>
    </root>
    

    Output:

    <h1>Agreement: 1</h1>
    <select>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    <h1>Agreement: 2</h1>
    <select>
      <option value="2">2</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    <h1>Agreement: 3</h1>
    <select>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble trying to figure this out. What i have is
I have some trouble trying to join a couple of tables for a time-booking
I have some trouble when trying to update a table by looping cursor which
I am having some trouble trying to access variables in twig. I have a
Im currently having trouble trying to understand linked lists. I have some code that
I'm trying to start my java game but I have some troubles with the
I have some trouble when I try to map object to int . My
I have some trouble with my trac installation (version 11.4). What should I do
I have some trouble with jquery ui-events: In my application, there are some sliders.
I have some trouble achieving adequate real-time performance from my application and wondering if

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.