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

Re: check with XSL if a file is available

Subject: Re: check with XSL if a file is available
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 7 Jul 2003 15:26:24 +0100
cocoon file exists
Hi Joel,

> i want to implement a choose statment that defines what to do if a
> document is available and what to do if this document is not
> available.

Processors are allowed to do one of two things when you tell them to
access a document that doesn't exist: they can generate an error, or
they can return an empty node set. You're obviously using a processor
that does the former rather than the latter. One solution would be to
switch to using a processor that does the latter, if you can find one.

A better solution (since you will then be able to use any processor)
would be to use another method to work out whether the file is
available or not. Since you're using Cocoon, one way you can do this
is to make available a directory listing, as XML, using the Directory
Generator (see
http://cocoon.apache.org/2.1/userdocs/generators/directory-generator.html).

For example, if you set it up in the sitemap so that the URL
"path/_dir" gave you a directory listing for the directory found at
"path" then you could do something like:

  <xsl:choose>
    <xsl:when test="document('path/_dir')/dir:directory/dir:file/@name =
                    'path/filename.xml'">
      do this with the file
    </xsl:when>
    <xsl:otherwise>
      do something else without the file
    </xsl:otherwise>
  </xsl:choose>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.