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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:56:34+00:00 2026-05-28T03:56:34+00:00

I am writing a template that extends templates, but it has some issues. <xsl:template

  • 0

I am writing a template that “extends” templates, but it has some issues.

<xsl:template match="*[@condition]" mode="#all">
<xsl:element name="condition">
  <xsl:attribute name="name">
    <xsl:value-of select="@condition"></xsl:value-of>
  </xsl:attribute>
  <xsl:apply-imports>
  </xsl:apply-imports>
</xsl:element>

The problem with this is templates called using <xsl:apply-imports> are missing params.
The list of params are not known since there are many different templates that this template is trying to extend (hence the mode="#all").

Is there a good way around this?


Additional example:

Consider two final templates (read-only):

<xsl:template match="*" mode="mode1">
    <param name="p1"/>
</xsl:template>

<xsl:template match="*" mode="mode2">
    <param name="p2"/>
</xsl:template>

they are called somewhere (read-only):

<xsl:apply-templates mode="mode1">
    <xsl:with-param name="mode1" select="$mode1"/>
</xsl:apply-templates>

<xsl:apply-templates mode="mode2">
    <xsl:with-param name="mode2" select="$mode2"/>
</xsl:apply-templates>

There might be 100s of mode1, mode2, mode3, mode4 … and the names do not have a pattern.

I would like to have a global template that wraps additional info around the final templates. Something like:

<xsl:template match="*" mode="#all">
    <xsl:next-match/>
</xsl:element>

The problem is the above global template does not pass the params to the templates.

  • 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-05-28T03:56:34+00:00Added an answer on May 28, 2026 at 3:56 am

    If your problem is that when you call <xsl:apply-imports> it doesn’t include the parameters passed to the current template, you can use tunnel parameters. In the template you are extending mark your parameters like this:

    <xsl:param name="foo" tunnel="yes"/>
    

    Also, when you pass the parameters:

    <xsl:with-param name="foo" tunnel="yes"/>
    

    I also suggest using <xsl:next-match> instead of <xsl:apply-imports>.

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

Sidebar

Related Questions

I've been writing a system that at runtime generates some templates, and then generates
I've been writing some templates that expect to be passed a boost::function. They determine
I am busy writing a CodeSmith template that has one of its properties as
I am writing an XSL template that pulls data from many secondary sources. An
I'm writing an XSLT template that need to output a valid xml file for
I'm writing a website in ASP.NET MVC, using the ASP.NET MVC 1.0 template that
I'm writing a template that will be used like this: {{templatename |var1=foo |var4=bar |var14=toot
I have this control template that I am writing: <Style TargetType={x:Type controls:InfoBar}> <Setter Property=Template>
I have a base Twig template that has a search bar form in it
I'm writing some template classes for parseing some text data files, and as such

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.