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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:26:39+00:00 2026-05-15T20:26:39+00:00

I have a problem. I have an XML file that contains information about 100

  • 0

I have a problem.

I have an XML file that contains information about 100 courses.

I have an XSL file that nicely displays the list of 100 courses.

But what if I want to only display 1 course. Can I pass a parameter to the XSLT file to tell it to only display “ENGL 100” ?

The XML looks something like this:

<document>
<menu>
   <item>
      <name>MTH 300</name>
      <brief>Mathematics Skill Development</brief>
      <description>A course in the fundamentals of ...</description>
   </item>
   <item>
      <name>MTH 301</name>
      <brief>Basic Algebra</brief>
      <description>An introduction to algebra, ...</description>
   </item>
 ...

I know I could write an XSLT file called “eng100.xsl” to loop through the XML and display only ENG 100 but I don’t want to have to write dozens of these files.

The XML is dynamic and I am able to control it. I want the XSLT file to be static and never change.

Is there any way to pass parameters into the XSLT?

  • 1 1 Answer
  • 3 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-15T20:26:40+00:00Added an answer on May 15, 2026 at 8:26 pm

    You can pass parameters to XSLT, how this is done depends on your XSLT processor, but usually as additional command arguments, if it’s a command-line processor.

    You declare parameters using

      <xsl:param name="courseName" select"initialValue"/>
    

    You can then test this parameter in your XSLT, and invoke a different template depending on it’s value. For example, if the parameter is empty, then invoke the current template that processes all elements, otherwise invoke a template that only processes elements when the item name equals the parameter value. You can do this with a test

       <xsl:template match="item">
          <xsl:if test="$courseName=name(./name)">
             <xsl:call-template name="yourOriginalTemplate"/>
          </xsl:if>
       </xsl:template>
    

    But by filtering and formatting, you are mixing two concerns in one file. I would separate out the selection of the XML elements from formatting – have two xslt files for that and run them as a pipeline.

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

Sidebar

Related Questions

I have an interesting problem with XSL. We have an XML Input file that
I have a web application, that contains a configuration xml file for one of
I'm trying to parse an xml file that contains accents, but I get this
I have an XML file in res/values. The file contains a list of people.
I have a problem with using the SAX parser to parse a XML file.
I have one problem , I want to get some data from XML file
Trying to use JSTL but have the following problem: Index.xhtml page: <?xml version=1.0 encoding=UTF-8?>
XML is cool in flex, but I have an annoying problem to solve, caused
I have a product that contains a Jar file in its distribution and I
Again a simple thing. I have a stylesheet that parses XML and XSL files.

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.