Reputation: 633
I have Java project with different modules on it. The project have one core module where all the common configuration files kept. Each module has separate configuration files like .properties
files, hibernate.cfg
, web.xml
etc. It is not necessary that every time all modules will be there on the final build.
My problem is that, suppose 3 modules such as A, B & C are present. Each has its on web.xml
and it contains only the servlets and mapping necessary for that. I want to know how concatenate these web.xml
while building. I know that from ant
I can call a Java application. The position of tags is important in web.xml
.
How it possible to concatenate these web.xml
effectively? I tried xstream for this but it was a failure.
Upvotes: 3
Views: 532
Reputation: 10377
The xmltask is great for xmlprocessing with ant.
See details and examples here :
xmltask :
xml task manual
xml manipulation using xml task
useful xpath links :
http://zvon.org/xxl/XPathTutorial/
http://www.w3schools.com/xpath/
Upvotes: 0
Reputation: 2425
If you are using an Servlet 3.0 container, then only your core module would have a web.xml
and your other modules would each provide their own web-fragment.xml
.
Upvotes: 3
Reputation: 3151
There are following ways you can achieve this:
Map
for how to marshal an object. or use the official tutorialJSON.org
and merge each of the XMLs and rebuild the XML from the JSON. NOTE: the don't use the xstream
for this purpose, it reverses the whole XML, causing validation errors to the resulting XMLs.Upvotes: 1
Reputation: 38
Your quesion itself has answer , Write a small java program to parse all XML you want to combine , get required nodeList , write in new XML in the order you want. Call this java program during Ant build.
Upvotes: 0