Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 759879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:38:59+00:00 2026-05-14T15:38:59+00:00

I would like to be able to pass an XML file to an ANT

  • 0

I would like to be able to pass an XML file to an ANT build script and have it create a folder structure mimicking the nodal structure of the XML, using the build files parent directory as the root.

For Example using:

<root>
    <folder1>
         <folder1-1/>
    </folder1>
    <folder2/>
    <folder3>
         <folder3-1/>
    </folder3>
</root>

ant would create:

folder1
   -folder1-1
folder2
folder3
   -folder3-1 

I know how to create a directory, but i’m not sure how to have ANT parse the XML.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:39:00+00:00Added an answer on May 14, 2026 at 3:39 pm

    One option would be to use the xslt task to do the heavy lifting. For example, generate a second ant script and invoke it.

    build.xml:

    <project default="mkdirs">
      <target name="mkdirs">
        <xslt style="mkdir.xslt" in="dirs.xml" out="mkdir.build.xml"/>
        <ant antfile="mkdir.build.xml"/>
      </target>
    </project>
    

    Place mkdir.xslt in the same directory as build.xml:

    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:template match="text()"/>
    
      <xsl:template match="root">
        <project><xsl:text>&#10;</xsl:text>
          <xsl:apply-templates/>
        </project>
      </xsl:template>
    
      <xsl:template match="*">
        <mkdir>
          <xsl:attribute name="dir">
            <xsl:for-each select="ancestor::*">
              <xsl:if test="position() != 1">
                <xsl:value-of select="name()"/>
                <xsl:text>/</xsl:text>
              </xsl:if>
            </xsl:for-each>
            <xsl:value-of select="name()"/>
          </xsl:attribute>
        </mkdir><xsl:text>&#10;</xsl:text>
    
        <xsl:apply-templates/>
      </xsl:template>
    </xsl:transform>
    

    Example mkdir.build.xml output from the xslt task:

    <?xml version="1.0" encoding="UTF-8"?><project>
    <mkdir dir="folder1"/>
    <mkdir dir="folder1/folder1-1"/>
    <mkdir dir="folder2"/>
    <mkdir dir="folder3"/>
    <mkdir dir="folder3/folder3-1"/>
    </project>
    

    I’m not fluent in XSLT, so it might be possible to improve on the for-each loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to be able to pass an optional parameter to an ant
I have a * -parameter method. I would like to be able to pass
I have a class, and I would like to be able to create multiple
I would like to be able to pass a parameter in a callback, but
I would like to be able to pass in rider or something else and
I would like to be able to pass extra arguments to a function and
I would like to be able to pass some context info between NLog loggers
i would like to be able to pass in a format string at runtime
I would like to be able to pass params to the is_following method as
Would like to be able to set colors of headings and such, different font

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.