Solved

Folder contains multiple xml files

Posted on 2009-04-06
1
221 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
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RSS feed not showing item time 3 22
iOS retina Display, HTML Email Signature 5 511
cookies analysis tools 2 92
Windows Tool to Build Android and iOS App 3 76
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 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