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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:38:13+00:00 2026-06-14T20:38:13+00:00

I am trying to filter the XML by what I get in a parameter.

  • 0

I am trying to filter the XML by what I get in a parameter.
What is the correct sintax to match on only those courses that have dep_code equal to ‘something’ or in this case $department???

XML STRUCTURE IS

     <course>
         <dep_code></dep_code>
         <catalog_number></catalog_number>
         <course_group></course_group>
         <term></term>
         <offered></offered>
         <course_type></course_type>
         <course_level></course_level>
         <title></title>
         <course_number></course_number>
         <meeting_text></meeting_text>
         <faculty_text></faculty_text>
         <description></description>
         <prerequisites></prerequisites>

      </course>

Parameter defined

<xsl:param name="department" select="'All'" />

Code I have tried
I have tried this:

<xsl:template match="course/dep_code/{$department}">

Also this:

<xsl:template match="course/dep_code/$department">


<xsl:template match="course/dep_code eq $department">

I I keep on getting syntactical errors like the following:

  1. F [Saxon-PE 9.4.0.3] Unexpected token “{” in path expression
  2. F [Saxon-PE 9.4.0.3] A variable reference is not allowed in an XSLT
    pattern (except in a predicate)

Thanks in advance

  • 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-14T20:38:14+00:00Added an answer on June 14, 2026 at 8:38 pm

    Sample XML

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <courses>
          <course>
             <dep_code>not_it</dep_code>
             <catalog_number></catalog_number>
             <prerequisites></prerequisites>
          </course>
          <course>
             <dep_code>something</dep_code>
             <catalog_number></catalog_number>
             <prerequisites></prerequisites>
          </course>
    </courses>
    

    Sample XSLT

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="/">
      <html>
      <body>
        <table border="1">
          <tr>
            <th>dep_code</th>
          </tr>
          <xsl:for-each select="courses/course">
            <xsl:if test="dep_code[text()='something']">
          <tr>
            <td><xsl:value-of select="dep_code"/></td>
          </tr>
            </xsl:if>
          </xsl:for-each>
        </table>
      </body>
      </html>
    </xsl:template>
    </xsl:stylesheet>
    

    Result

    <html>
    <body>
    <table border="1">
    <tr><th>dep_code</th></tr>
    <tr><td>something</td></tr>
    </table>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to filter an XML based on multiple parameters that I have
I'm a newbie with LINQ2XML. I'm trying to filter an xml file and get
I'm trying to filter some XML in JavaScript using E4X and have some specific
I am trying to get my TagsController#index action to display only the Questions that
I am trying to get data from xml file and then filter using datatable.Select()
I'm trying to parse an XML, but I want to filter and extract only
I have some xml and I am trying to filter it using e4x. My
Im trying to filter rows based on a column say c1 that contains boolean
I am trying to filter for an object that has a Title field, and
I'm trying to use DOMParser, or XPath to get a XML fragment out of

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.