[xsl] Stuck on meta-stylesheet problem

Subject: [xsl] Stuck on meta-stylesheet problem
From: "Charles Knell" <cknell@xxxxxxxxxx>
Date: Thu, 23 May 2002 11:03:03 -0700
I am writing a stylesheet to create a second stylesheet.

The product stylesheet must have four parameters. I have included them
	<xslt:param name="canEdit" />
	<xslt:param name="script" />
	<xslt:param name="css" />
	<xslt:param name="updateProc" />

There are no parameters passed to the first stylesheet, the task is to
create placeholders for the parameters which will be passed to the product
stylesheet during the final transformation.

Note that the namespace is "xslt" rather than "xsl" so that I can pass
the tags through the first tranformation as unmolested, and I use a "namespace-alias"
to define "xslt" as pointing to the standard "xsl" URL thus:

<xsl:namespace-alias stylesheet-prefix="xslt" result-prefix="xsl" />
so the product stylesheet will have the "xslt" prefix associated with
the correct namespace.

In order to get through the first transformation with my product stylesheet
parameter declarations intact, I pull this little kludge in the first

	<xsl:variable name="v_updateProc">$updateProc</xsl:variable>
	<xsl:variable name="v_canEdit"><xsl:copy-of select="concat('{$','canEdit}')"
	<xsl:variable name="v_script"><xsl:copy-of select="concat('{$','script}')"
	<xsl:variable name="v_css"><xsl:copy-of select="concat('{$','css}')"
	<xsl:variable name="v_class"><xsl:copy-of select="concat('{$','class}')"

This leads to these tags further on in the body of the sheet:

<script language="JavaScript" src="{$v_script}"></script>
<link rel="stylesheet" href="{$v_css}" type="text/css" media="screen"

These two work just as I expect, and when the product stylesheet is created,
the variable references in the "src" and "href" attributes are replaced
with the correct values.

My problem comes with the "canEdit" parameter. I wish to use its value
to determine whether or not to call a particular template. The construct
which I have tried (and which fails) is this:

	<xslt:if test="{$v_canEdit}='true'">
		<xslt:call-template name="saveButton" />

My processor (Oracle's) returns this error:
ORA-20100: Error occurred while processing: XSL-1013: (Error) Error in
expression: '{$canEdit}='true''.

If I omit the curly braces like this:
	<xslt:if test="$v_canEdit='true'">
		<xslt:call-template name="saveButton" />
I get this error:
ORA-20100: Error occurred while processing: XSL-1031: (Error) Variable
not defined: 'v_canEdit'

If I leave these curly braces in and remove them from the variable declaration
like this:
<xsl:variable name="v_canEdit"><xsl:copy-of select="concat('$','canEdit')"

I get the ame error as the other curly brace option.

At this point I am fresh out of ideas on how to procede, but still convinced
there must be a way to do this, perhaps much more cleanly than I have
so far devised.

Has anyone got any experience with this sort of two-stage transformation
involving parameters?

Charles Knell
cknell@xxxxxxxxxx - email

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread