Re: [xsl] using a parameter to modify part of the file path in document(...) function

Subject: Re: [xsl] using a parameter to modify part of the file path in document(...) function
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Sun, 17 Sep 2006 22:54:40 +0200
Tracey Zellmann wrote:
I was able to resolve this.

I needed to include in my stylesheet
<xsl:param name="buidlingDataFile"/>

Not exactly sure why I need this in this case, but not in others.

It should be that way in all cases (well: you can use either xsl:variable or xsl:param), you did the right thing.

When you want to use an external parameter (one given to the xslt stylesheet by the processor, from the commandline or a program), the parameter must have been declared inside the xslt, at root level, with <xsl:param>, before you can use it. Afaik, this is also true for ATV (attribute value templates, the format you where referring to earlier, with the curly braces). Using a variable or a parameter which was not declared, is an error.

In XPath 1.0 it is defined so: "A VariableReference evaluates to the value to which the variable name is bound in the set of variable bindings in the context. It is an error if the variable name is not bound to any value in the set of variable bindings in the expression context." (see: http://www.w3.org/TR/xpath#section-Basics),

In understandable English I think this means: if the variable reference (the thing after the dollar sign) is not there in your document, in an imported document, or not in the scope of the current statement, an error will rise.

If your processor does not treat it as an error when you reference a parameter or variable that is not declared, I think your processor has a bug.

Cheers,

Abel Braaksma
http://abelleba.metacarpus.com

Current Thread