Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML Beans..Can xml file read system variable

 
dimpsonu arora
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using XMLBeans which is reading an xml file.
For example: Following are contents of xml file.

<Log4JPropertiesFilePath>C:/MyProj/config/log4j.properties</Log4JPropertiesFilePath>
<LogFilePath>C:/MyProj/logs/ICA_log.txt</LogFilePath>

The above kind of c:/MyProj locations are defind at many places in xml file.

Now, problem is that if the above location gets changed, I will have to make changes in the complete xml file which I don't want.

Is there any way where I can define my location "c:/MyProj" at a common place in XML Or outside XML from where XML can read it.

It is very urgent. Please help.

Thanks in advance.
 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How are you forming your XML? Can't you force the code making your XML to read it,say, from a property file and insert it at the proper tag in the XML?

Jhakda
 
dimpsonu arora
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Done! Thanks.
 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
What did you do,do let us know. Share the knowledge.

Jhakda
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dimpsonu arora:

Is there any way where I can define my location "c:/MyProj" at a common place in XML Or outside XML from where XML can read it.


What is the meaning of "Xml can read it"?
XML is not an application, it is a simple file. It is like saying i will write a place holder in a Text file and the text file should read the value for the place holder from another file!
It is the application that reads an XML file and thus the application must have the intelligence as to how to understand a place holder like the path you are talking about. I can write in my Xml something like:

The application reading this will know that the actual value in between these tags will come from a system variable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic