aspose file tools*
The moose likes XML and Related Technologies and the fly likes populate XML with value from another XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "populate XML with value from another XML" Watch "populate XML with value from another XML" New topic
Author

populate XML with value from another XML

Andrew Cane
Ranch Hand

Joined: Aug 07, 2013
Posts: 91
I have a config file (lets call this file main-config.xml) with a list of environments of databases for my app.
The question now, I have several frameworks that requires the information from inside main-config.xml, but different format (hibernate wants its own config format and mybatis wants its own format). so how can I populate the hibernate's and mybatis' config file based on the value in main-config.xml. thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
I suggest you start by working with simpler XML exercises until you get comfortable with the Java standard library for XML.

This free online book by Harold is loaded with good examples.

Bill
Andrew Cane
Ranch Hand

Joined: Aug 07, 2013
Posts: 91
umm, I've been working with XML for quite a while along with XSLT. I don't understand how the article can help me with thisissue, am I missing something? thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41823
    
  62
I can think of two ways to address this.

1) Keep all those properties in some file format of your own choosing, and create all the config files for the various subsystems as part of the build process from that.

2) Write code that reads the properties at startup time, and then initialize the other libraries programmatically.


Ping & DNS - my free Android networking tools app
Andrew Cane
Ranch Hand

Joined: Aug 07, 2013
Posts: 91
so, there's no way to do something like

general.properties


mybatis-cfg-xml


so, it won't involve any kind of code involvement, just pure XML reading another XML / properties file
thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
A google search for XML include found this article.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2409
    
    7

Why not just use a properties file with unique keys of course for different DB storing such info rather than creating another XML?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Andrew Cane
Ranch Hand

Joined: Aug 07, 2013
Posts: 91
@william brogden:
yep, this is what I've been looking for.

K. Tsang:
yes, properties file would also work, its just my team prefer XML because utility class that processes XML already exist. its just a matter of habit I guess. can you give me an example of how this works?

is xi:include the common way in reusing information stored in one main configuration file by different frameworks config file?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: populate XML with value from another XML