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

  • Home
  • SEARCH
  • 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 152347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:36:25+00:00 2026-05-11T09:36:25+00:00

Is there a function in XSLT that can takes in a directory path and

  • 0

Is there a function in XSLT that can takes in a directory path and gives back all the files in it??

I have a xml file now reads like this

<filelist>     <file>fileA.xml</file>     <file>fileB.xml</file> </filelist> 

Now, there’s directory called dir, has files fileX.xml, fileY.xml and a bunch of other xml files in it. I want to add these files on to the orginal xml file, so that I can get:

<filelist>     <file>fileA.xml</file>     <file>fileB.xml</file>     <file>fileX.xml</file>     <file>fileY.xml</file>     .... <!-- other files --> </filelist> 

Is there an XSLT way to do this?? something that takes in a dir root, and is able to iterator through all of the files in it?? And then I could just call something like:

<xsl:element name = file >      <xsl:copy> <!--whatever file name--> <xsl:copy> </xsl:element>0 

[Edit-solution]

all of the answers were very helpful. I ended up finding an external solution (using saxon). I thought it may be helpful for other people to post my solution here, although it is very specific to my own situation.

I use Ant to build a java web app and need to translate some xml files before deployment. Hence, I was using the xslt task to do the job by adding the ‘saxon9.jar’ in the classpath. And in my xsl file, I just did something like this:

<xsl:for-each select='collection('../dir/?select=*.xml')' >      <xsl:element name='file'>         <xsl:value-of select='tokenize(document-uri(.), '/')[last()]'/>      </xsl:element> </xsl:for-each> 
  • 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. 2026-05-11T09:36:26+00:00Added an answer on May 11, 2026 at 9:36 am

    XSLT has nothing built-in for this task. XSLT is a transformation language – for dynamic output you generally need a transformation source that contains everything already (just in a different form) – you cannot create XML from nothing.

    The three ways you can tackle the problem are:

    1. Build the XML in a programming language, leaving out XSLT altogether. This is the simplest way to get the result you want.
    2. Build an XSL stylesheet that accepts a parameter, put a (pre-built) delimited list of files into that parameter, let the XSLT handle the string and make XML from it. This involves external handling as well, basically this is option 1., plus you’d have to write an XSL stylesheet that does string handling (something that XSL has not been geared to)
    3. Use extension functions and do the directory processing from within the XSL. An example how to get started can be found in my answer to this question. This is not very portable as extension functions are platform specific.

    It boils down to this:

    • You will need help from an external programming language
    • You do not absolutely need XSLT do accomplish the task, since XML output is all you need and no transformation is required.

    Ergo: Don’t use XSL for this.

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

Sidebar

Ask A Question

Stats

  • Questions 112k
  • Answers 112k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No need to install anything, just include the Subsonic dll… May 11, 2026 at 9:54 pm
  • Editorial Team
    Editorial Team added an answer Move your <asp:ScriptManager /> to a custom control e.g. MyScriptManager.ascx… May 11, 2026 at 9:54 pm
  • Editorial Team
    Editorial Team added an answer I've done it several times with Zend_Translate and poedit. Check… May 11, 2026 at 9:54 pm

Related Questions

I need to process XML documents of varying formats into records in a MySQL
I have a question for the clever people of the SO community. Below is
Is there a function in python to split a word into a list of
Is there a function in Python to split a string without ignoring the spaces

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.