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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:50:30+00:00 2026-05-25T20:50:30+00:00

Please explain me how best XSLT param can be used. in terms of <xsl:param>

  • 0

Please explain me how best XSLT param can be used.
in terms of <xsl:param> & <xsl:with-param>

Sample LOC:

<xsl:call-template name="ABC">
    <xsl:with-param name="title" />
</xsl:call-template>
  • 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-25T20:50:31+00:00Added an answer on May 25, 2026 at 8:50 pm

    Please explain me how best XSLT param can be used. in terms of
    <xsl:param> & <xsl:with-param>

    <xsl:param> can be specified at the global level anywhere (as a child of xsl:stylesheet) or if it is within a template, it must be its child and it must precede any non-xsl:param child of xsl:template.

    This is the facility that allows a template or the whole transformation (in case of a global xsl:param) to receive varying data from the caller/initiator of the template or of the whole transformation, respectively.

    On the side of the caller/initiator of the template/transformation, parameters are passed by using an xsl:with-param instruction. it can be a child of xsl:apply-templates or xsl:call-template.

    The name attribute of either xsl:param or xsl:with-param is mandatory. It identifies the parameter.

    The select attribute of xsl:with-param may be used to specify any XPath expression, the result of whose evaluation is passed to the called/applied template.

    Alternatively, the value can be specified in the content (body) of xsl:with-param.

    xsl:with-param must have either a select attribute or a body. but not both of them.

    An xsl:param can also have a select attribute or body. In this case, these specify the default value of the parameter and it is used if no parameter with this name has been specified by the caller.

    Finally, here is a complete example illustrating most of these concepts:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:param name="pTarget" select="'love'"/>
     <xsl:param name="pReplacement" select="'like'"/>
    
     <xsl:template match="/*">
      <xsl:call-template name="replace">
       <xsl:with-param name="pPattern" select="$pTarget"/>
       <xsl:with-param name="pRep" select="$pReplacement"/>
      </xsl:call-template>
    
      <xsl:text>&#xA;</xsl:text>
    
      <xsl:call-template name="replace"/>
    
      <xsl:text>&#xA;</xsl:text>
    
      <xsl:apply-templates select="text()">
       <xsl:with-param name="pPattern" select="$pTarget"/>
       <xsl:with-param name="pRep" select="'adore'"/>
      </xsl:apply-templates>
     </xsl:template>
    
     <xsl:template match="text()" name="replace">
       <xsl:param name="pText" select="."/>
       <xsl:param name="pPattern" select="'hate'"/>
       <xsl:param name="pRep" select="'disapprove'"/>
    
       <xsl:if test="string-length($pText) >0">
           <xsl:choose>
            <xsl:when test="not(contains($pText, $pPattern))">
              <xsl:value-of select="$pText"/>
            </xsl:when>
            <xsl:otherwise>
             <xsl:value-of select="substring-before($pText, $pPattern)"/>
             <xsl:value-of select="$pRep"/>
    
             <xsl:call-template name="replace">
               <xsl:with-param name="pPattern" select="$pPattern"/>
               <xsl:with-param name="pRep" select="$pRep"/>
               <xsl:with-param name="pText" select=
                "substring-after($pText, $pPattern)"/>
             </xsl:call-template>
            </xsl:otherwise>
           </xsl:choose>
       </xsl:if>
     </xsl:template>
    </xsl:stylesheet>
    

    When applied on this XML document…

    <t>Sports stars we really love, love to hate, hate</t>
    

    …the result is…

    Sports stars we really like, like to hate, hate
    Sports stars we really love, love to disapprove, disapprove
    Sports stars we really adore, adore to hate, hate
    

    Explanation:

    1. The replace template is called twice. In both calls the pText parameter is omitted. Its default value is used by the called template.

    2. The first call provides the pattern and replacement parameters, so "love" is replaced by "like".

    3. Do note that the values of the global parameters $pTarget and $pReplacement are passed through. If the initiator of the transformation decides to pass other values (not the defaults that are used in this code) for these global parameters, these values will be passed to the replace template and not the defaults "love" and "like".

    4. The second call doesn’t provide any parameter values at all, so all defaults in the replace template are used — the string "hate" is replaced by the string "disapprove".

    5. Note that the replace template calls itself recursively, so that all occurrences of the pattern are replaced by the replacement.

    6. Also, the values of the pText parameter of the recursive calls aren’t static, but are dynamically calculated.

    7. The third time the replace template is initiated from outside is via xsl:apply-templates. Here we also show that a template can have both a match and a name attribute at the same time and it is possible that such a template can be initiated both using xsl:apply-templates and xsl:call-template.

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

Sidebar

Related Questions

If this is the best (or a good) solution, can someone please explain exactly
Please explain what is name mangling, how it works, what problem it solves, and
Can someone please explain why ?___SID=U is appearing in some Magento URLs on my
Can someone please explain how Read/Show works.. I cannot find any tutorials on it.
Can some one please explain why this loop never 'breaks' and goes on forever
Can someone please explain to me how this responsive approach works? This was done
Can someone please explain the difference between ViewState and Session? More specifically, I'd like
can any one explain this? Overload resolution and partial ordering are used to select
Can someone please explain in a way as simple as possible what the Model
Can someone please explain what GZIP Output Compression Level is and how it affects

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.