[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Strange Problem with document($variablename)

Subject: Re: Strange Problem with document($variablename)
From: Torsten Schlabach <TSchlabach@xxxxxxx>
Date: Fri, 11 Jul 2003 14:00:20 +0200 (MEST)
xsl xml document name filename
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.