xsl-list
[Top] [All Lists]

Re: Strange Problem with document($variablename)

2003-07-11 05:00:20
Jeni,

<xsl:variable name="filename"
              select="concat('../content/news/', @name)" />

Thank you. That at least make the code more efficient. I had overlooked
that.

I doubt that it will give you a different result.

Right. It doesn't.

the reason that the file isn't found might be because the
URL is being resolved relative to the directory that the stylesheet
lives in rather than the directory that the XML document lives in. Try
using:

It is. This is why I need to prefix this with ../ to get out of the
stylesheets directory. Again, thank you for the hint, 

 document($filename, .)

is again much more elegant.

BUT this does not touch the original problem. It is the *path* at which the
file is being sought. The actual filename piece is lost somewhere, but
*only*
if the concatenated pathname starts with anything else than either the /
character or an alphanumeric character. If it is trying to open the file
"../content/news" instead of "../content/news/foo.html" it is not going to
find it.

I look as if something in between the stylesheet and the actual file system
call is trying to interpret the path against anyhting and gets this wrong. I
need to admin I am running this in Cocoon. Might cocoon be fooling me here?
How would I be able to debug this?

Torsten

Hi Torsten,

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!!!).

That's very peculiar. If you want an equivalent variable, try using
the concat() function:

<xsl:variable name="filename"
              select="concat('../content/news/', @name)" />

I doubt that it will give you a different result.

By the way, the reason that the file isn't found might be because the
URL is being resolved relative to the directory that the stylesheet
lives in rather than the directory that the XML document lives in. Try
using:

  document($filename, .)

to get the $filename URL to be resolved relative to the current
<directory> element.

Cheers,

Jeni

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





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