473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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 21444


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matthew Barnes | last post by:
I'm considering submitting a patch for Python 2.4 to allow environment variable expansion in ConfigParser files. The use cases for this should be obvious. I'd like to be able to specify something...
1
by: Shahzad Atta | last post by:
Hi there, I am using a batch file to do some zipping task. This batch file get executed on postbuild event which I set through project properties. Now when I execute the batch file from command...
2
by: shaun | last post by:
Is there anyway to access a system environment variable from within an xml document? Two applications: 1) I'd like to make an XBase declared path equal to an environment variable declared path....
28
by: Christian | last post by:
Another question from a not even newbie: In Unix you can set an environment variable with the command export PYTHONPATH but I would like to set the variable from at .py script. So my question...
2
by: Vinay | last post by:
Hi We can use Environment class to read %Temp% variable o local machine. But I want to read this variable for currently logged on used for remote machine. Is there anyway to do this using .NET? I...
6
by: yaron | last post by:
Hi, my application use environment variable, let call it FOO. how can i add the FOO environment variable to my project or my solution, so the line string foo =...
6
by: dylan.boudreau | last post by:
My configuration is Apache/2.0.59 (Unix) mod_ssl/2.0.59 OpenSSL/0.9.7d PHP/5.0.4 on Solaris 10. phpinfo() lists the location of php.ini as /usr/local/apache/conf and my php.ini file is there but...
23
by: ShaneO | last post by:
Hello, I wish to extract embedded string data from a file using a Binary Read method. The following code sample is used in VB.NET and similar code is used in VB6 - (Assume variable...
3
by: smitty1e | last post by:
Just a fun exercise to unify some of the major input methods for a script into a single dictionary. Here is the output, given a gr.conf file in the same directory with the contents stated below: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.