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

RE: check if document exists

Subject: RE: check if document exists
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 19 May 2006 17:58:56 +0100
if document
In 1.0, when document() uses a URI that doesn't exist, the processor can
either return nothing or throw an error. In 2.0, it's obliged to throw an
error; but a new doc-available() function is provided so you can test for
the existence of the document in advance.

However, your URI ends in .png, which suggests that it might not be an XML
file. In that case doc-available() should return false, because document()
would fail to parse the contents of the file. You can use
unparsed-text-available() to test for existence of a text file - but even
that is not designed to test for binary files. Use an extension function
that invokes File.exists() in the Java library.

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: Rick Roen [mailto:Rick@xxxxxxxxxxxxxxxxxx] 
> Sent: 19 May 2006 17:54
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  check if document exists
> 
> I'm trying to check if a document exists before I do 
> something in a XSL 2.0 stylesheet, however it fails using XML Spy:
> 
> 
> 			<xsl:variable
> name="postnetfile">.\postnet<xsl:value-of
> select="../@zip"/>.png</xsl:variable>
> 			<xsl:choose>
> 			
> 			<xsl:when 
> test="boolean(document($postnetfile))">
> 			<fo:block padding-left="3mm" 
> padding-top="5mm"> found postnet file
> 				<!--<fo:external-graphic><xsl:attribute
> name="src"></xsl:attribute></fo:external-graphic>-->
> 			</fo:block>
> 			</xsl:when>
> 			</xsl:choose>
> 
> Result: "XSL transformation failed ue to the following error: 
> Error in XPath 2.0 expression Error retrieving resource - 
> 'C:\temp\postnet94030.png'
> 
> Can someone tell my what is wrong?
> 
> Rick

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.