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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:50:41+00:00 2026-06-11T01:50:41+00:00

I want to apply a template with a mode that depends on a variable

  • 0

I want to apply a template with a mode that depends on a variable value.

<xsl:variable name="mode" select="@attribute"/>
<xsl:apply-templates mode="{$mode}"/>

I get the error that the stylesheet cannot be compiled. The value of mode should be a QName, but it is “{$mode}”.

Is there a possibilty to use modes dependent on variables?

  • 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-11T01:50:43+00:00Added an answer on June 11, 2026 at 1:50 am

    The only option you have to use a certain mode based on an expression is to use

    <xsl:choose>
       <xsl:when test="@attribute = 'foo'">
          <xsl:apply-templates mode="bar"/>
       </xsl:when>
       <xsl:otherwise>
          <xsl:apply-templates/>
       </xsl:otherwise>
    </xsl:choose>
    

    or the same with an xsl:if. The mode attribute value itself needs to be a QName in XSLT 1.0 respectively in XSLT 2.0 allows a QName or special tokens like #current or #default‘. But you can’t compute a mode value at run-time.

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

Sidebar

Related Questions

Below I'm trying to match certain nodes. <xsl:template match=nodes> <element> <xsl:apply-templates select=nodes mode=different />
I have the template <xsl:template match=node mode=some_mode> <xsl:value-of select=child1 /> <xsl:value-of select=child2 /> <xsl:value-of
So I'm using the identity design pattern for XSLT: <xsl:template match=@*|node()> <xsl:copy> <xsl:apply-templates select=@*|node()[not(@visible='false')]/>
<xsl:template match=extnode> <xsl:if test=/topnode/value> </xsl:if> </xsl:template> <xsl:template match=/> <xsl:apply-template select=document('external.xml')/exttopnode/extnode/> </xsl:template> In the example
i want to apply masking over the textinput that need to get SSN from
I have an XSLT like below, and want to use apply-templates inside the xsl:for-each
I want to apply a Storyboard to my Rectangle Fill like this: <Rectangle Name=MyRectangle
Is there any way to apply a template to the selected value of a
I have the following xslt template: <xsl:template name=with-newlines> <xsl:param name=text /> <fo:block linefeed-treatment=preserve white-space-collapse=false
I am trying to re-use a XSL template, and place other templates within this

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.