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

The Archive Base Latest Questions

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

I know that XSLT does not work in procedural terms, but unfortunately I have

  • 0

I know that XSLT does not work in procedural terms, but unfortunately I have been doing procedural languages for too long. Can anyone help me out by explaining in simple terms how things like apply-templates works and help a thicko like me to understand it.

  • 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-11T00:10:33+00:00Added an answer on May 11, 2026 at 12:10 am

    What makes you think that procedural terms do not apply here? It’s just that the calling convention is somewhat more implicit than you would traditionally expect it, because there is an invisible context involved. Everything apply-templates does could be expressed in procedural terms.

    Basically, apply-templates is nothing more than a for-each loop. Starting from where where you currently are in the document (the context, think ‘this‘), it iterates over the child nodes.

    For each child, the processor selects the matching xsl:template with the highest priority (based on their respective match and priority attributes), sets the context to the child at hand and runs this template (think ‘function‘). After the template returns, the context snaps back and it’s the next child’s turn.

    Even when things become recursive (which is somewhat hard to avoid in XSLT), the whole process really does not become any more complicated. The context ‘pointer’ is moved around, and templates get called.

    You can restrict the node set that apply-templates iterates over, using the select attribute:

    <!-- all children of the context node regardless --> <xsl:apply-templates />    <!-- all children of the context node being 'data' with a @name of 'Foo' --> <xsl:apply-templates select='data[@name='Foo']' />   

    You can sort the node-set prior to the iteration, if you wish:

    <!-- all children of the context node being 'data' with a @name of 'Foo',      ordered by their respective 'detail' count --> <xsl:apply-templates select='data[@name='Foo']'>    <xsl:sort select='count(detail)' data-type='number' order='descending'/> </xsl:apply-templates> 

    And you can pass parameters to your template if you need, just like you would with a regular function call:

    <!-- pass in some parameter --> <xsl:apply-templates select='data[@name='Foo']'>    <xsl:with-param name='DateSetIcon' select='$img_src' /> </xsl:apply-templates> 

    That’s about all there is to it.

    EDIT:

    I know that the last comment is a bit provocative. This is very much intentional, for a basic understanding of how apply-templates works this is more or less it. The implications and possibilities that come from the fact that not you are defining what template to call, but rather let the processor choose the right one for you are of course bigger than what it sounds like to the untrained ear. The declarative/implicit approach of the whole thing surely needs some time to sink in.

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

Sidebar

Related Questions

I know that in xslt not have the break statement and don't know how
I know that this sort of question has been asked here before, but still
I know that Java have its own garbage collection, but sometimes I want to
Does anyone know of a solid non-encumbered suite of XSLT sheets that can generate
I know that XSLT itself has attribute-sets, but that forces me to use <xsl:element
I know that Phonegap has an event for back button, but it's only available
I know that immutable objects always have the same state, the state in which
I know that many threads has been created here & on the internet about
I've generated the following XSLT file, and have created a Form that will post
I'm looking for an xslt that does the following: With the input xml 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.