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

How to gracefully check if a document exists relative

Subject: How to gracefully check if a document exists relative to the document being transformed?
From: Calvados Boulard <calvados.boulard@xxxxxxxxx>
Date: Thu, 4 Feb 2010 15:55:20 -0800
 How to gracefully check if a document exists relative
Hi there,

I'm transforming a XML document, and attempting to determine if a file
at a relative location exists.

The file as you would guess from the relative path exists one
directory up, and in another directory

Currently I'm using:

<xsl:choose>
            <xsl:when test="unparsed-text-available('../06_Regulations
Point in Time/125_2008_pit.xml')">
                <h1>Document found</h1>
            </xsl:when>
            <xsl:otherwise>
                <h1>Document NOT found</h1>
            </xsl:otherwise>
</xsl:choose>

However the unparsed-text-available only seems to check for the target
document relative to the location of the XSL file, not the XML.

I've also tried:
<xsl:choose>
        <xsl:variable name="common-uri"
select="resolve-uri('../06_Regulations Point in
Time/125_2008_pit.xml')" />
        <xsl:choose>
            <xsl:when test="unparsed-text-available($common-uri)">
           <h1>Document found</h1>
            </xsl:when>
            <xsl:otherwise>
                <h1>Document NOT found</h1>
            </xsl:otherwise>
</xsl:choose>

as well as:
<xsl:choose>
             <xsl:when
test="unparsed-text-available(document(''../06_Regulations Point in
Time/125_2008_pit.xml',/))">
             <h1>Document found</h1>
            </xsl:when>
            <xsl:otherwise>
                <h1>Document NOT found</h1>
            </xsl:otherwise>
</xsl:choose>


How would I go about gracefully checking to see if the document exists
relative to the document being transformed?  I see that the document
function has a way to enforce checking relative locations, but am
unsure how to put this all together.

Thanks for all your help.

Cal.

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.