Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Folder contains multiple xml files

Posted on 2009-04-06
1
Medium Priority
?
226 Views
Last Modified: 2013-11-18
Hello Experts,

I would like to create an filelist by passing input folder which contains xml files and using xslt generate filelist like...

<filelist>
<file href="1.xml"/>
<file href="2.xml"/>
.....
</filelist>

Can you please suggest is this can be done using xslt?

Thanks,
Shailesh
0
Comment
Question by:ShaileshShinde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 24076961
This can only be done if you use XSLT2.
Do you?

If you do, here is how to use Saxon for that
<?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
         exclude-result-prefixes="xsi">
        <xsl:param name="joinDir">file:/F:/10_Development/2008/Q3/</xsl:param>
        <xsl:output method="xml" indent="yes" />
        <xsl:strip-space elements="*"/>
        
        <xsl:template match="/">
            <xsl:element name="filelist">
                <xsl:for-each select="collection(concat($joinDir, '?select=*.xml'))">
                    <file href="{tokenize(base-uri(), '/')[last()]}"/>
                </xsl:for-each>
            </xsl:element>
        </xsl:template>
        
   </xsl:stylesheet>
   

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question