Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 26th, 2009, 01:42 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default When the file passed to doc() is not available..

Hi,

I am using Saxon-B 9.0.0.6J

I have a situation where there may or may not be a file I need to bring into a transformation.

I am using:
Code:
<xsl:variable name="featGrpMap" select="doc($FeatGrpMap)"/>
Where $FeatGrpMap is a relative path to the file that might be present.

If the file is there, of course, all is well.
If the file is missing, I get a java.io.FileNotFoundException (The system cannot find the file specified).

What I hoped for is that the doc() would simply set my variable, $featGrpMap, to an empty structure that I could detect later when I went to use the information and simply skip that processing.

Is there something I can do to detect early on the file is not present and skip the doc() function? Or is there some better way to handle this behaviour?

Thanks,
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare
 
Old August 26th, 2009, 01:48 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I think you want to use doc-available http://www.w3.org/TR/xpath-functions...-doc-available to check whether the document is available:
Code:
<xsl:variable name="featGrpMap" select="if (doc-available($FeatGrpMap)) then doc($FeatGrpMap) else ()"/>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
mphare (August 26th, 2009)
 
Old August 26th, 2009, 03:23 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Thanks, exactly what I needed.
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare





Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a doc file using a jsp karthik_talasu Javascript 3 June 27th, 2006 08:02 AM
Problem in opening .doc file kumar_raj13 C# 1 March 13th, 2006 12:57 PM
Write in A DOC File With Same Text Formatting Arshi VB How-To 0 February 5th, 2006 05:08 AM
How to open a .DOC file with MS-Word ? sherbir Servlets 0 July 26th, 2004 02:39 AM
Opening a .doc file for view Shoedat Beginning VB 6 2 June 14th, 2003 02:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.