xsl-list
[Top] [All Lists]

RE: [xsl] check if document exists

2006-05-19 09:59:11
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(_at_)LakeValleySeed(_dot_)com] 
Sent: 19 May 2006 17:54
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>