Re: [xsl] Value-Of a Parameter

Subject: Re: [xsl] Value-Of a Parameter
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 4 Sep 2001 10:41:14 +0100
Hi Tanzila,

> Attempt 1:
> <xsl:param name="xmlFile" select="document('spanish.xml')"></xsl:param>
> <!--where xmlFile is passed in as - document('spanish.xml')-->

$xmlFile is being passed in as *the string* "document('spanish.xml')".
The processor doesn't evaluate that string, so the parameter is just
set to the literal string. When you use a parameter at the start of
the path, it has to be a node set rather than a string, which is why
you get the error message.

>               <xsl:value-of select="document('$xmlFile')//organisation"/>
[snip]
>
> The value of the xmlFile is not returned i.e. the following message
> is displayed "can't find the file $xmlFile".

The quotes around '$xmlFile' in the above call to document() mean that
you're passing in the literal string '$xmlFile' as the argument to
document(), not the value of the $xmlFile parameter. You haven't got a
file called '$xmlFile' on your system, so it doesn't find one.

You need to set the parameter as you do in the second attempt, to
"spanish.xml", and then pass the value of the parameter in as the
argument by removing the quotes. Use:

  <xsl:value-of select="document($xmlFile)//organisation" />

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread