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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:13:32+00:00 2026-05-13T13:13:32+00:00

Am I correct in thinking that an apply-templates declaration should match all templates which

  • 0

Am I correct in thinking that an apply-templates declaration should match all templates which could possibly be applied for a selection?

For example, given the following xml fragment:

<doc>
  <foo bar="1" baz="2">boz</foo>
</doc>

and the following stylesheet:

<xsl:template match="/">
  <xsl:apply-templates select="foo" mode="xyz" />
</xsl:template>

<xsl:template mode="xyz" match="foo[bar='1']">
  abc
</xsl:template>

<xsl:template mode="xyz" match="foo[baz='2']">
  def
</xsl:template>

I would expect the output to be:

abc
def

Is this correct?

  • 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-13T13:13:32+00:00Added an answer on May 13, 2026 at 1:13 pm

    No, you don’t get both outputs, as only one template will be selected.
    See this page for the rules on conflict resolution if there are multiple possible templates.

    After fixing your stylesheet (similarly to how Rubens did it, but with same modes), this usually will result in the last template in your xslt file to be applied, so the output will be def. This is because the two templates have the same priority and if your xslt processor does not stop with an error the standard requires it to apply the last one:

    It is an error if this leaves more than one matching template rule. An XSLT processor may signal the error; if it does not signal the error, it must recover by choosing, from amongst the matching template rules that are left, the one that occurs last in the stylesheet.

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

Sidebar

Ask A Question

Stats

  • Questions 282k
  • Answers 282k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Pass it through multiple regexes if you can. It'll be… May 13, 2026 at 4:02 pm
  • Editorial Team
    Editorial Team added an answer I would have worker threads waiting in a thread pool.… May 13, 2026 at 4:02 pm
  • Editorial Team
    Editorial Team added an answer Okay, so you want to calculate a^b mod m. First… May 13, 2026 at 4:02 pm

Related Questions

Here is a sample code to retrieve data from a database using the yield
I'm very new to multi-threading and for some reason this class is giving me
Following on from Jeff and Joel's discussions of plugin architectures. Plugins in C++ (using
myFoo = myFoo ?? new Foo(); instead of if (myFoo == null) myFoo =
Taking the jQuery framework for example, if you run code like this: $(document).ready(function init()

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.