Search

When working with GET parameters, xsl starts protesting when they are left empty.

Is there a way to test if the param has been left empty, and provide a default value?

The order of the parameters is not fixed, so thats why I like to use the $url-param way, instead of building them from the url.

Have you tried adding <xsl:param name="url-param" /> to the top of your XSL template?

Have you tried adding to the top of your XSL template?

Hmm, that seems to always return an empty result. Also, a dollar sign is not allowed in the param name..

Am I missing anything?

Ah, sorry about the dollar sign - that was a typo that I corrected above. I had to handle your issue a while back and I though defining an empty parameter solved the issue. If it does not, I’m at my wits’ end.

Where exactly did you define that param? At the top level template, or at the specific template?

It’s a fallback parameter that gets set within the <xsl:stylesheet> element of the file that would expect the parameter. I’ve used this method for any xslt that expects parameters before…

At the top level template, or at the specific template?

I thought that both should work.

My understanding is that you need to place at the top level.

I thought that you placed it either at the top level or within a template depending on the scope you require for the parameter (global scope or template scope).

It needs to be global (to an individual XSL document) if you’re dealing with a parameter being passed to the transformer, which url parameters are. Of course, this is only necessary if you actually use the parameter somewhere within your XSL document.

My understanding is that you cannot nest them inside anything but the xsl:stylesheet element in this scenario.

Thanks all, including it in my main template did the trick.

Maybe this should be integrated into the docs?

Thanks for asking the question, creativedutchmen:

Is there a way to test if the param has been left empty, and provide a default value?

Was searching for an answer and I stumbled on this thread.

Cheers!

@vladG - You might want to look at the Data Source Filtering concepts page. You’ll want to look at parameter enumerators, sets a default value if one is not set.

{$color:red}

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details