[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Strange Problem with document($variablename)


Subject: [xsl] Strange Problem with document($variablename)
From: Torsten Schlabach <TSchlabach@xxxxxxx>
Date: Fri, 11 Jul 2003 13:05:11 +0200 (MEST)

Dear list,

my apologies if this is too obvious, but I cannot figure out this problem
for two days now. This is what I try to do:

In a <xsl:foreach> I iterate some directory elements. I want to open the
corresponding XML file for each of the directly entries. So I need to
concatenate the @name attribute of the current node the <xsl:foreach> iterator is
visiting with a directory name prefix. I try to do this like that:

<xsl:variable name="filename">
<xsl:value-of select="'../content/news/'" />
<xsl:value-of select="@name" />
</xsl:variable>

Using <p><xsl:value-of select="$filename"/></p> the correct filename is
being printed. 

(For example ../content/news/foo" if @name == foo.)

Using document($filename) I get a java.io.FileNotFound exception for
"../content/news/" (where is the foo gone; it the identical variable!!!).

Even more strange: Just putting an X in front of ../content/news" makes the
whole thing work:

<xsl:variable name="filename">
<xsl:value-of select="'X../content/news/'" />
<xsl:value-of select="@name" />
</xsl:variable>

I will get java.io.FileNotFound exception for "X../content/news/foo" (note
the foo is *not* omitted just because I put the X in front of the other part
of the variable). Of couse with the leasing X the filename is invalid.

Do I get the syntax wrong? Is there a different way of achieving this?

I tried <xsl:variable name="filename" select="'../content/news/'@name"/> but
this causes Xalan to refused to compile that stylesheet at all. I also
tried:

<xsl:variable name="filename1" select="'../content/news/'"/>
<xsl:variable name="filename2" select="@name" />
	
<xsl:variable name="filename" select="$filename1$filename2" />

as well as

<xsl:variable name="filename1" select="'../content/news/'"/>
<xsl:variable name="filename2" select="@name" />
	
<xsl:variable name="filename" select="{$filename1}{$filename2}" />

All this variations result in the stylesheet not beeing compiled.

Any comments are welcome.

Regards,
Torsten



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



Current Thread
Keywords
xml