<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.0.9">
</HEAD>
<BODY>
Patrick,<BR>
<BR>
My comment was intended to answer the question you asked:<BR>
<FONT COLOR="#737373"><I><BR>
&quot;So there is no way to pass in a system property to set this up?&quot;</I></FONT><BR>
<BR>
<BR>
Since there is no system property for that (According to Per) then you could build in your own functionality by using the system property as I described it, and then do your internal references from there using that as a base.&nbsp; In other words you could wrap the transformer with a package that gives the illusion of a base directory.<BR>
<BR>
This is a hack, not an elegant solution to the problem.&nbsp; However, in an environment where the people maintaining the environment rely on environment variables to define such things, it is entirely appropriate.<BR>
<BR>
The reason I used JBoss as an example in my original response is because it turned out exactly that way for us.&nbsp; Our clients seemed to be comfortable with the idea of environment variables, so we referenced our external directories for attachments and such by using a variable of our choosing, the same way you should define ${JAVA_HOME} and such.&nbsp; In order for our applications to get that property, it had to be passed into the JVM from the command line.&nbsp; Here's the basic steps:
<OL TYPE=1>
    <LI TYPE=1 VALUE=1>Set the system environment variable MY_HOME to whatever you like.
    <LI TYPE=1 VALUE=2>In the application server, if it's Java based, alter the script that runs the java command by adding -DMY_HOME=%MY_HOME% (for a MS operating system) or -DMY_HOME=$MY_HOME (for unix shell).
    <LI TYPE=1 VALUE=3>In the server-side application, use System.getProperty(&quot;MY_HOME&quot;) to get the value of the variable.
    <LI TYPE=1 VALUE=4>If it's a directory, perform whatever tests to assure that it exists and is writable.
    <LI TYPE=1 VALUE=5>If you need to pass it to an applet, you can add it to a session or encode it as a parameter in the html.
</OL>
<BR>
<BR>
<BR>
On Thu, 2004-12-30 at 03:50, patrick@openbase.com wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#737373"><I>Ken, Per

To be fair with the 2 of you :) I would be interested to know what  
system property needs to be added to specify the base dir to use for  
the Transformer to resolve the external file. What reasons should I  
pursue to know whether I should create a custom URIResolver vs setting  
up a system property?

Thanks



On 30 d&#233;c. 04, at 01:28, Ken Roberts wrote:

&gt;  On Wed, 2004-12-29 at 18:08, Per Norrman wrote:
&gt; Ken Roberts wrote:
&gt; &gt; On Wed, 2004-12-29 at 17:27, Per Norrman wrote:
&gt; &gt;
&gt; &gt;&gt;/Ken Roberts wrote:
&gt; &gt;&gt;&gt; Passing in a system property to a JVM is done by specifying
&gt; &gt;&gt;&gt; -Dvariable=value, no spaces on the command line.
&gt; &gt;&gt;&gt;
&gt; &gt;&gt;&gt; Doing this inside JBoss means editing your run.bat file or your  
&gt; run.sh
&gt; &gt;&gt;&gt; file, or (if redhat) the jboss_init_redhat.sh file.
&gt; &gt;&gt;&gt;
&gt; &gt;&gt;&lt;irony&gt;
&gt; &gt;&gt;   Thank you very much for that timely and accurate piece of  
&gt; information.
&gt; &gt;&gt;&lt;/irony&gt;
&gt; &gt;&gt;
&gt; &gt;&gt;Serioulsy, next time, please read the entire thread before jumping  
&gt; in ...
&gt; &gt;&gt;
&gt; &gt;&gt;/pmn/
&gt; &gt;&gt;
&gt; &gt;
&gt; &gt; Per,
&gt; &gt;
&gt; &gt; Sorry if my solution seems old-school, but I had read the entire  
&gt; thread.
&gt; &gt;
&gt; &gt; You answered the direct question of telling that the underlying
&gt; &gt; transformer has no such setting.  I tried to answer the next  
&gt; question by
&gt; &gt; indirection.
&gt;
&gt; Aha, so you *anticipated* that the next question would be &quot;Now that I  
&gt; have the
&gt; URIResolver, and knowing that this specific URIResolver uses a system  
&gt; property
&gt; to resolve relative urls, what can I possibly to do get that darn  
&gt; system
&gt; property set?&quot;, and answered that question before it was posed.
&gt;
&gt; If that's the case, your'e too quick for the rest of us.
&gt;
&gt;  No, I went down the other path from the one you suggested, which is  
&gt; to set a system property based on an environment variable.&nbsp; I did it  
&gt; to offer a different solution to the same problem, since a URIResolver  
&gt; didn't exactly fit the needs I had when I implemented my solution.
&gt;
&gt;
&gt; There are all sorts of ways to define a base directory,
&gt; &gt; and the one I have used in the past is what I described because it  
&gt; fit
&gt; &gt; more easily with our needs.  Your solution would take 10 minutes
&gt;
&gt; Actually, I said 10 *lines* of code.
&gt;
&gt;  As opposed to:
&gt;
&gt;  File myBaseDir = new File(System.getProperty(&quot;mybasedir&quot;));
&gt;
&gt;
&gt; Let's not continue this off-topic thread ...
&gt;
&gt;  Sure.&nbsp; We can stop as soon as you stop flaming me.&nbsp; I have in no way  
&gt; earned this treatment, and as a matter of fact I have a few months to  
&gt; spend on this if you like.&nbsp; Sarcasm and bitterness has no place on a  
&gt; forum such as this.&nbsp; We're not in a contest to see who's the brightest  
&gt; programmer, we're offering solutions to problems that people might  
&gt; have.
&gt;
&gt;  Whether my solution was in style or not, it did satisfy a certain  
&gt; category of business needs.&nbsp; Generally it's considered a good idea to  
&gt; look at multiple solutions before making a design decision, and you  
&gt; offered one solution.&nbsp; I offered another.
&gt;
&gt;
&gt; &gt; code, you said, and mine took maybe 5.  Which is correct depends a  
&gt; lot
&gt; &gt; on your application needs.
&gt; &gt;
&gt; &gt; The interesting bit is that your solution and mine would both be  
&gt; placed
&gt; &gt; in just about the same place in whatever code one would write.   
&gt; Since it
&gt; &gt; can't be done (by your statement) internally to the XSL parser, it  
&gt; would
&gt; &gt; have to be done in the wrapping code, no matter what the solution.
&gt; &gt;
&gt; &gt; Passing an environment variable is quaint and maybe not very elegant,
&gt; &gt; but it does work.  I shared it because the original poster asked
&gt; &gt; specifically about passing system properties.  Since the JVM used to
&gt; &gt; pass the environment of the operating system in but no longer does, I
&gt; &gt; thought my contribution was pertinent.
&gt; &gt;
&gt; &gt;&gt;/&gt; On Wed, 2004-12-29 at 16:38, Per Norrman wrote:
&gt; &gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;/Patrick JUSSEAU wrote:
&gt; &gt;&gt;&gt;&gt;&gt; Hi,
&gt; &gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt; So there is no way to pass in a system property to set this up?
&gt; &gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;Not that I'm aware of, no.
&gt; &gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt; I guess the other solution would be to put all the files I need  
&gt; in the
&gt; &gt;&gt;&gt;&gt;&gt; same directory but I would rather have the option to set the  
&gt; base dir
&gt; &gt;&gt;&gt;&gt;&gt; of the external file that is referenced from the document()  
&gt; method.
&gt; &gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;But that is exactly what you would/could do with an URIResolver.  
&gt; It is less
&gt; &gt;&gt;&gt;&gt;that 10 lines of code to have a URIResolver resolve a relative url  
&gt; using a
&gt; &gt;&gt;&gt;&gt;system property as the base uri.
&gt; &gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;/pmn
&gt; &gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt; Patrick
&gt; &gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt; On 29 Dec 2004, at 19:51, Per Norrman wrote:
&gt; &gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt; Hi,
&gt; &gt;&gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt; I believe you can use the Transformer#setURIResolver method.
&gt; &gt;&gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt; /pmn
&gt; &gt;&gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt; patrick@openbase.com wrote:
&gt; &gt;&gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Hi,
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; I am using JDOM to perform an XSL transformation. The problem  
&gt; I have
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; is that my XSL Document refers to an external file using the
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; document(URL) method. I don't want to use an absolute URL.  
&gt; What I
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; would like to do is tell JDOM  (the Transformer) what the  
&gt; basedir is
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; (/Users/aUser) so that in my XSL file I could use:
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; ...
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;xsl:variable name=&quot;lookupParam&quot;  
&gt; select=&quot;document('aFile.xml')&quot;/&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; ...
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; and aFile.xml would abvioulsy be in /Users/aUser
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Here is the code I am using
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Document p_sourceDocument = ....
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Document p_xslDocument = ....
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; // Create a JDOMSource from the source JDOM Document
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         JDOMSource source = new JDOMSource(p_sourceDocument);
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         // Create a JDOMSource from the source XSL Document
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         JDOMSource xslSource = new JDOMSource(p_xslDocument);
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         // Get a XSLT Transformer
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         Transformer transformer =
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; getTransformerFactory().newTransformer(xslSource);
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         // Create a JDOMResult
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         JDOMResult result = new JDOMResult();
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         // Populate the Result
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;         transformer.transform(source, result);
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; I guess there must be some way to tell the underlying  
&gt; Transformer
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; what the basedir is?
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Thanks,
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Patrick
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; _______________________________________________
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; To control your jdom-interest membership:
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; //_//_</FONT><A HREF="http://www.jdom.org/mailman/options/jdom-interest/__"><U>http://www.jdom.org/mailman/options/jdom-interest/__</U></A><FONT COLOR="#737373">  
&gt; youraddr@yourhost.com
&gt; &gt;&gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;&gt; _______________________________________________
&gt; &gt;&gt;&gt;&gt;&gt;&gt; To control your jdom-interest membership:
&gt; &gt;&gt;&gt;&gt;&gt;&gt;  
&gt; __</FONT><A HREF="http://www.jdom.org/mailman/options/jdom-interest/"><U>http://www.jdom.org/mailman/options/jdom-interest/</U></A>
<FONT COLOR="#737373">&gt; youraddr@yourhost.com__
&gt; &gt;&gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;
&gt; &gt;&gt;&gt;&gt;_______________________________________________
&gt; &gt;&gt;&gt;&gt;To control your jdom-interest membership:
&gt; &gt;&gt;&gt;&gt;__</FONT><A HREF="http://www.jdom.org/mailman/options/jdom-interest/"><U>http://www.jdom.org/mailman/options/jdom-interest/</U></A>
<FONT COLOR="#737373">&gt; youraddr@yourhost.com__
&gt; &gt;&gt;&gt;&gt;/
&gt; &gt;&gt;&gt;&gt;
&gt; &gt;&gt;/
&gt; &gt;&gt;
&gt;
&gt; _______________________________________________
&gt; To control your jdom-interest membership:
&gt; </FONT><A HREF="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com"><U>http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</U></A>
<FONT COLOR="#737373"></I></FONT></PRE>
</BLOCKQUOTE>
</BODY>
</HTML>