[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: check if document exists
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
|
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
|