Subject: Re: [xsl] Testing file existence From: Steve Ball <Steve.Ball@xxxxxxxxx> Date: Tue, 03 Sep 2002 09:15:53 +1000 |
I wanna include some images in the html file generated from a xml file using a stylesheet but I want to do that only if these images exists.
How can I test if a file (no xml) exists on my misk.
I'm using the XT processor.
For the benefit of those not using XT, there are at least two ways so solve this:
1. Use an extension function. Most XSLT processors provide a means of defining extensions. Personally, I use libxslt and have a wrapper for it for the Tcl scripting language. To test file existence (or get a file mod time, etc) I call out to a Tcl script via an extension function.
2. There may be other ways depending on the framework you have set up. For example, if you are running a web server then you could set up a CGI(-like) URL that returns the file existence information as a small XML document. Then use the document() function to retrieve that info. This is essentially a Web Service. It would be nice to be able to use SOAP for this purpose, but SOAP doesn't play nicely with XSLT :-(
It goes without saying that security issues must be considered...
2.5 Pass filesystem information to the stylesheet as a parameter. You could have some code create a listing of the filesystem (most probably the sub-hierarchy you're interested in, rather than the entire tree), pop that in a file, pass the filename to the stylesheet as a parameter and then use document() to pull in that file.
Just some ideas... Steve Ball
-- Steve Ball | XSLT Standard Library | Training & Seminars Zveno Pty Ltd | Web Tcl Complete | XML XSL Schemas http://www.zveno.com/ | TclXML TclDOM | Tcl, Web Development Steve.Ball@xxxxxxxxx +---------------------------+--------------------- Ph. +61 2 6242 4099 | Mobile (0413) 594 462 | Fax +61 2 6242 4099
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Testing file existence, G. Ken Holman | Thread | [xsl] book on xsl-fo?, Jo Bourne |
RE: [xsl] Re: Getting the value of , Michael Kay | Date | Re: [xsl] Getting the value of an e, G. Ken Holman |
Month |