[xslt] Undeclared params

Is an <xsl:param> statement required for all global variables?
xsltproc will happily allow a reference to an undeclared param _if_
the param has a value passed in.   I noticed today that a customer's
script was depending on this behavior, which I thought would be an

In this example the variable "test" is not declared.  Running
xsltproc without a "--param test" gives an error but with a "--param
test" it runs fine.

% cat test.xsl
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
  <xsl:template match="/">
        <xsl:value-of select="concat(&quot;test: &quot;, $test)"/>
% xsltproc test.xsl test.xml
runtime error: file test.xsl line 6 element value-of
Variable 'test' has not been declared.
xmlXPathCompOpEval: parameter error
runtime error: file test.xsl line 6 element value-of
XPath evaluation returned no result.
<?xml version="1.0"?>
% xsltproc --param test '"test"' test.xsl test.xml
<?xml version="1.0"?>
<out><value>test: test</value></out>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]