|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Test if an (image) file exists
> I'd like to test if image files exist in a target directory on my file > system before adding links to them in html output (I need to check on > $filename.jpg or $filename.gif and other variations.) Should > I use a Java > extension function in my XSLT or are there now better ways to > do this with > in-built XSLT functions, using unparsed-text() for example? You need to use extension functions. Assuming that the reference to the image is in an attribute called @src, and that it takes the form of a relative URI (relative to the document that contains the reference), you will need something like this: <xsl:variable name="absoluteURI" select="resolve-uri(@src, base-uri(.))" as="xs:anyURI"/> <xsl:if test="file:exists(file:new($absoluteURI))" xmlns:file="java@xxxxxxxxxxxx">... > But if I pass this template a filename (xs:string) I get the following > error: > > "There is more than one method matching the function call > file:new, and > there is insufficient type information to determine which one > should be used." > Java provides File.new(string) and File.new(URI), so Saxon needs to know at compile time whether the argument is a string or a URI. In this case the function was called as file:new($param) where $param was declared as <xsl:param name="param"/> with no type information. You can probably fix the problem by changing the declaration to <xsl:param name="param" as="xs:string"/> or by writing the function call as file:new($param as xs:string) (or use xs:anyURI if that's what it is) Michael Kay http://www.saxonica.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








