468,458 Members | 1,813 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

How do you read in an environment variable in an XML file? . . .

that was set up for and/or by this user in the OS.

Say, you set WEB_DIR as an environment variable pointing to certain
folder or root directory

Could you go like this

<?xml version='1.0' encoding='utf-8'?>
<XMLExample Att1="69" Att2=$WEB_DIR"rest_of_it">

.. . .

</XMLExample>

for attributes or values?

And when a program parses the XML doc it should pick the current env.
var. value.

I think of using it for tomcat's configuration files which are more
XMLish than true XML ones.

There are ways to pass in parameters to the JVM when you run a java
prog., but I don't know of a way to read in an external environment
variable from the OS into an updated conf doc and use this value

How do you do something like that?
Jul 20 '05 #1
3 18710


Albretch wrote:
that was set up for and/or by this user in the OS.

Say, you set WEB_DIR as an environment variable pointing to certain
folder or root directory

Could you go like this

<?xml version='1.0' encoding='utf-8'?>
<XMLExample Att1="69" Att2=$WEB_DIR"rest_of_it">

. . .

</XMLExample>

for attributes or values?

And when a program parses the XML doc it should pick the current env.
var. value.

I think of using it for tomcat's configuration files which are more
XMLish than true XML ones.

There are ways to pass in parameters to the JVM when you run a java
prog., but I don't know of a way to read in an external environment
variable from the OS into an updated conf doc and use this value

How do you do something like that?


There is no general XML mechanism for that. XSLT 1.0 knows global
parameters defined as
<xsl:param name="paramName" />
which you can then set before you run an XSLT transformation. JAXP has a
method serParameter to set such parameters before you do a transformation.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Albretch <lb*****@hotmail.com> wrote:
that was set up for and/or by this user in the OS.

Say, you set WEB_DIR as an environment variable pointing to certain
folder or root directory

Could you go like this

<?xml version='1.0' encoding='utf-8'?>
<XMLExample Att1="69" Att2=$WEB_DIR"rest_of_it">

. . .

</XMLExample>

for attributes or values? [...] How do you do something like that?


Yourself. AFAIK, XML parsers don't expand environemtn variables.

To get the value of an environment variable, see:
- System#getProperty(String)
- Integer#getInteger(String)
- Long#getLong(String)
- And similar methods in these classes.
--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website

PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
Jul 20 '05 #3
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41***********************@newsread4.arcor-online.net>...
There is no general XML mechanism for that. XSLT 1.0 knows global
parameters defined as
<xsl:param name="paramName" />
which you can then set before you run an XSLT transformation. JAXP has a
method serParameter to set such parameters before you do a transformation.


I think that would do it in a clean way:

1._ Set up purposed/altered/parameterised xml conf files

2._ Check out TC's sources to chnage the code segments where it reads
these conf files and

3._ pass them first through an XSLT transformation that would:
3.1_ read the values in from env. vars
3.2_ inject them in the files
on the fly

4._ before these files reach TC proper . . .
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Matthew Barnes | last post: by
2 posts views Thread by shaun | last post: by
28 posts views Thread by Christian | last post: by
6 posts views Thread by dylan.boudreau | last post: by
23 posts views Thread by ShaneO | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.