Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

populate XML with value from another XML

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A google search for XML include found this article.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not just use a properties file with unique keys of course for different DB storing such info rather than creating another XML?

 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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?
 
Trust God, but always tether your camel... to this tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic