I´ve a Xml file with the struct below. I want to read the nod by node and call a specific task with the values without commom separator.In Ant this is possible ?
<projects>
<!-- first node -->
<project>
<name> </name>
<url> </url>
<package> </package>
</project>
<!-- Second node -->
<project>
<name> </name>
<url> </url>
<package> </package>
</project>
<projects>
thanks!
Ant projects cannot be nested within the same Ant build file. However, build logic can be modularized using MacroDefs. In addition, subprojects can have their own build files, which may be called from a master build file using the Ant Ant task. Ant targets may be called within the same build file using the AntCall task.
thiagolsilva,
Using a combination of xmlproperty and javascript I was able to split a multi-element (same node) of a projects.xml file and use project node data fields in ant. All actions are performed in a single ant file, in a single execution.
The sample data projects.xml file from the example above:
Has to be transformed into following format of projects.xml file:
Here, the previous node elements were transformed into a single string with fields separated by ‘;’ character.
I have renamed the element “project” to “myProject” to avoid confusion, as I will be using ant “project” object in javascript.
Once we have flattened the repeatable xml node into a string, we can use the following ant script to iterate through the elements, read the flattened properties and use them as we wish.
The files in: - C:\temp\lib\ProcessProjects.xml - the build - C:\temp\lib\projects.xml - the data - C:\temp\lib\ant-contrib-1.0b3.jar - the lib jar
The output:
Regards, Jurek
Use the XSLT task to process the input XML file into an ANT script that is subsequently executed.
Example
Running will process the information in the
projects.xml
projects-process.xsl
This XSLT stylesheet is used to generate an ANT script
build.xml
Runs the XSLT transform to process the projects.xml file and generate an ANT build file