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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:29:33+00:00 2026-05-23T12:29:33+00:00

If I use <xsl:param> without specifying a value, the transformer assumes that the value

  • 0

If I use <xsl:param> without specifying a value, the transformer assumes that the value is an empty string.

In other words, if I forgot to specify a value (e.g. <xsl:param name="N"/>), the compiler doesn’t signal an error. This may cause my program to fail silently, which is a bad thing.

How can I specify that my <xsl:param> must have an explicit value? For example, this code should give me an error because there is no explicit value specified:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:call-template name="F1"></xsl:call-template>
        <html>
            <head>
                <title></title>
            </head>
            <body>stuff</body>
        </html>
    </xsl:template>
    <xsl:template name="F1">
        <xsl:param name="N"/> <!-- I Should Get An Error Here! -->
    </xsl:template>
</xsl:stylesheet>

Am looking for a solution in both XSLT 1.0 and XSLT 2.0.

  • 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-23T12:29:33+00:00Added an answer on May 23, 2026 at 12:29 pm

    You could actually do this with a bit of meta-XSLT:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text" />
    
      <xsl:template match="xsl:call-template">
        <xsl:variable name="template" select="/xsl:stylesheet/xsl:template[@name=current()/@name]"/>
        <xsl:variable name="call" select="." />
        <xsl:variable name="desc">
          <xsl:value-of select="concat('call to named template &quot;',$template/@name,'&quot; in ')"/>
          <xsl:choose>
            <xsl:when test="ancestor::xsl:template/@name">
              <xsl:value-of select="concat('named template &quot;',ancestor::xsl:template/@name,'&quot;')" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="concat('template matching &quot;',ancestor::xsl:template/@match,'&quot;')" />
            </xsl:otherwise>
          </xsl:choose>
          <xsl:text>&#10;</xsl:text>
        </xsl:variable>
    
        <xsl:for-each select="$template/xsl:param[not(@select)]">
          <xsl:if test="not($call/xsl:with-param[@name=current()/@name])">
            <xsl:value-of select="concat('Missing parameter &quot;',@name,'&quot; in ',$desc)" />
          </xsl:if>
        </xsl:for-each>
    
        <xsl:for-each select="xsl:with-param">
          <xsl:if test="not($template/xsl:with-param[@name=current()/@name])">
            <xsl:value-of select="concat('Unrecognised parameter &quot;',@name,'&quot; in ',$desc)" />
          </xsl:if>
        </xsl:for-each>
      </xsl:template>
    
      <xsl:template match="text()" />
    </xsl:stylesheet>
    

    This stylesheet takes any stylesheet as an input, and checks that all call-template’s have the right parameters, outputting a message if there’s any errors.

    This obviously isn’t going to put the error checking in the transformer itself, but it will list ALL errors in one go, and can potentially be extended to check for other issues as well.

    EDIT: I’ve adapted it to handle optional parameters, and added in a means of describing where the error is; it’s actually a bit of a redesign, with optional parameters simply counting them was going to be tricky, so I removed that bit. Every error is itemized anyway, so the count wasn’t really necessary.

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

Sidebar

Related Questions

I could use some help creating an XSL template that will take a string
Having declared <xsl:param name='suffix'>some_string</xsl:param> I tried to use its value in a function call
I have an xsl:param that I'm trying to use to do a template match
How to use xsl:for-each in xslt to get value iteratively from an xml file
I'm trying to use a user-defined function in XSLT that repeatedly calls the value
I'm trying to use XSL-stylesheets in order to transform some generated XML-data to HTML-output.
As a huge XSL fan, I am very happy to use xsl as the
I use a xsl tranform to convert a xml file to html in dotNet.
I wish to use xml and xsl to generate controls on an asp.net page.
What conventions (if any) do you use for indenting XSL code? how do you

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.