Re: [xsl] Behavior of document() Function with Empty String

Subject: Re: [xsl] Behavior of document() Function with Empty String
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 18 Dec 2006 17:37:06 +0100
Roger L. Cauvin wrote:
My project involves a Java web application and a Java 5.0 application that
share the same directory structure.  Unfortunately, the parser in the web
application interprets the document() function differently than the parser
in the standalone application.  I suppose the base paths are different.
Unfortunately, in neither case does document('') refer to the stylesheet
that makes the call.

I can't figure out how to work around this problem without hardcoding
absolute paths or having two sets of stylesheets with different relative
paths.

It seems to me that I have struggled with closely the same problem. Developer env. and production env. having different execution paths. We found that using document('') caused more trouble than it solved. I have a few pointers for you:


1. If you want to use document('') (for whatever reason) and you don't know what path is sought, use resolve-uri('') and inspect its result.
2. Use either a configuration file (like Michael suggested as well) and put your path info in there, or use parameters for the same.
3. Use the use-when attribute to distinguish between Developer Env and Production Env. Simply set (or use) a global system property in your Production Env and get it through system-property(). Like this:


<xsl:param name="base-path" select=" ' productionpath/bla.xslt ' " use-when = "system-property( ' application.context ' ) = 'production' " />
<xsl:param name="base-path" select=" ' developerpath/bla.xslt ' " use-when = "system-property( ' application.context ' ) != 'production' " />


Now, set "application.context" (or whatever) to "production" from your Production Env (and *do not* set it, or set it differently, on the dev. env).

If you need some more help getting this to work more conveniently, just let me know, as we have created (I believe) quite a nice workaround for working with path problems between production and developer envs, without compromising stability.

Cheers,
Abel

Current Thread