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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:28:27+00:00 2026-06-18T14:28:27+00:00

I’m trying to produce a search filter that will work with an existing XML

  • 0

I’m trying to produce a search filter that will work with an existing XML data file and I’m starting with trying to display just unique values from one of the nodes in a drop down list box.

An example of the XML file can be seen at…
http://kirk.rapweb.co.uk/testing/filter/tidy/plain/products.xml

I’ve managed to use XSLT to display the XML in a more readable format…
http://kirk.rapweb.co.uk/testing/filter/tidy/products.xml

The same data with filter applied…
http://kirk.rapweb.co.uk/testing/filter/tidy/filter/products.xml

The values I would like to list in the 1st drop down list box filtered out…
http://kirk.rapweb.co.uk/testing/filter/tidy/distinct/products.xml

All the data pulled into a HTML page…
http://kirk.rapweb.co.uk/testing/filter/tidy/html/

I’m struggling to work out how to get the data from…
http://kirk.rapweb.co.uk/testing/filter/tidy/distinct/products.xml
into a HTML page drop down list box.

Can anyone offer advice, point me in the right direction or confirm that I’m on the right track?

The end result that I’m trying to achieve is to have 2 drop down boxes.

Drop Down List 1 would contain… Brakes, Exhaust, Lighting

Drop Down List 2 would contain…

  • If Brakes were selected previously… Discs and Drums, Pads and Shoes.
  • If Exhaust were selected previously… Centre, Rear.
  • If Lighting were selected previously… Headlamps, Rear Lights.

Right now I’d just like to focus on populating Drop Down Box 1 with the data discussed above.

  • 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-18T14:28:28+00:00Added an answer on June 18, 2026 at 2:28 pm

    With your updated decription it looks like you want to create a dropdown with the distinct group values. This is an example of a grouping problem and in XSLT 1.0, the way to do this is with a technique called Muenchian grouping. It goes like this:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" omit-xml-declaration="yes"/>
      <xsl:key name="kGroup" match="product" use="group"/>
    
      <xsl:template match="/">
        <select name="productGroup" id="productGroup">
          <xsl:apply-templates 
            select="dataroot/product[generate-id() = 
                                     generate-id(key('kGroup', group)[1])]" />
        </select>
      </xsl:template>
    
      <xsl:template match="product">
        <option value="{group}">
          <xsl:value-of select="group"/>
        </option>
      </xsl:template>
    </xsl:stylesheet>
    

    When run on your input XML, it produces this:

    <select name="productGroup" id="productGroup">
      <option value="Brakes">Brakes</option>
      <option value="Exhaust">Exhaust</option>
      <option value="Lighting">Lighting</option>
    </select>
    

    Then you would use the same JavaScript as you’re using now to put the result inside a particular element in the HTML DOM that can be easily found by its ID.

    Now as for the next step, once the above is working, you would put a JavaScript event on this dropdown so that it runs another transform when an item is selected. You would get this selected value and then you can pass this into yet another XSLT as a parameter value. This page has good information on passing parameters into an XSLT in JavaScript. The XSLT would look like this (yet again with Muenchian grouping):

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" omit-xml-declaration="yes"/>
      <xsl:key name="kType" match="product" use="type"/>
    
      <xsl:param name="group" />
    
      <xsl:template match="/">
        <select name="productType" id="productType">
          <xsl:apply-templates 
            select="dataroot/product[generate-id() = 
                         generate-id(key('kType', type)[1])][group = $group]" />
        </select>
      </xsl:template>
    
      <xsl:template match="product">
        <option value="{type}">
          <xsl:value-of select="type"/>
        </option>
      </xsl:template>
    </xsl:stylesheet>
    

    When the parameter value “Lighting” is passed in as the group parameter and this is run on your input XML, this produces:

    <select name="productType" id="productType">
      <option value="Headlamps">Headlamps</option>
      <option value="Rear Lights">Rear Lights</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post

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.