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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:37:10+00:00 2026-05-11T09:37:10+00:00

I am finding it impossible to get with-param to work with apply-templates. As an

  • 0

I am finding it impossible to get with-param to work with apply-templates. As an example, I’ve hacked the examples given in w3schools.

xsl

<xsl:template match='/'>   <xsl:apply-templates>     <xsl:with-param name='test' select=''has this parameter been passed?''/>   </xsl:apply-templates> </xsl:template>  <xsl:template match='cd'>   <xsl:param name='test'></xsl:param>   parameter:   <xsl:value-of select='$test'></xsl:value-of> </xsl:template> 

xml

<catalog>   <cd>     <title>Empire Burlesque</title>     <artist>Bob Dylan</artist>     <country>USA</country>     <company>Columbia</company>     <price>10.90</price>     <year>1985</year>   </cd>   <cd>     <title>Hide your heart</title>     <artist>Bonnie Tyler</artist>     <country>UK</country>     <company>CBS Records</company>     <price>9.90</price>     <year>1988</year>   </cd> </catalog> 

(Hopefully) you’ll see that the test parameter is not being passed to the cd template. I can get it to work when using call-template, but not apply-templates. What’s going on? I am using XSL 1.0. Please ignore the fact that I’m passing a hard-coded parameter – this is just an example.

  • 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. 2026-05-11T09:37:11+00:00Added an answer on May 11, 2026 at 9:37 am

    Hmmm… interesting… fails for me using XslTransform and XslCompiledTransform in .NET – but it looks like it should work… curious…

    update the problem seesm to be the root match; try

    <xsl:template match='/catalog'> <!-- CHANGE HERE -->    <xsl:apply-templates>     <xsl:with-param name='test' select=''has this parameter been passed?''/>   </xsl:apply-templates> </xsl:template> 

    This then works for me without any other changes. The difference is that you were matching the root node. When you did your ‘apply templates’, it cascaded first to catalog (with the param), then to cd (without the param). To get what you want, you need to start at catalog. You can see this by adding an <xsl:vaue-of select='name()'/> to the match, and then try it as ‘/’ and ‘/catalog’.

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

Sidebar

Related Questions

Finding Duplicate Row with Count Numbers Suppose a table is given ID Name Age
Just finding my way around templates so was trying out a few stuff. Let
I finding a php template engine allow user defined function only or it allow
Finding a good way to do this has stumped me for a while now:
I'm failing at finding the commands I need to send to authenticate to a
I'm finding that I can't access the admin shares on an XP64 box when
I'm interested in finding out why this is used on some Web sites for
I'm finding myself doing a lot of things with associative arrays in PHP. I
I keep finding that if I have nested divs inside each other, and one
I'm having trouble finding an open-source IDE with support for Git. Are there any

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.