tags:

views:

103

answers:

2

I have xsl file while processing xml file some time i do need several xml file to be include, for that i use document() method, my problem is that all time all xml file which i include are not available online hence my transformation is stop due to file not found!!! does any body help me the best practice for this scenario.

Thanks in advanced

A: 

Create a local Hosts File entry for the website(s) that point to your local machine(or dev server).

An example that points www.foo.com and www.bar.com to the local machine:

127.0.0.1       localhost
127.0.0.1   www.foo.com
127.0.0.1   www.bar.com

Place sample XML file(s) on your local webserver(in necessary folder structure), so that when testing locally any requests for the files on the remote servers(e.g. http://www.foo.com/file1.html, http://www.bar.com/file2.html) will go to your locally hosted files.

Mads Hansen
+1  A: 

The problem is that the XSLT spec leaves it up to the implementation to define how to handle the case when a file referenced by the document() function is unavailable. There is a good discussion of this here: http://www.biglist.com/lists/xsl-list/archives/200801/msg00036.html

If you have the option to use XSLT 2.0 you can use the doc-available() function to test whether a file is available before calling the document() function.

Peter Jacoby