0

I have an xslt that I need to run on multiple xml files that are present in a folder 'source' he hierarchy of the files is as follows:

file 1: source/a/1.xml file 2: source/b/2.xml file 3: source/b/3.xml file 4: source/c/4.xml

and so on. How do I run the following xslt on these xml files

<xsl:template match="/">
    <xsl:for-each select="collection( 'source//*.xib')">
        <xsl:variable name="filename" select="document-uri(.)"/>
        <xsl:variable name="filename1">
            <xsl:value-of select="substring-after($filename,'source/')"/>
        </xsl:variable>         
            <xsl:result-document href="res/{$filename1}">
                <xsl:apply-templates/>
            </xsl:result-document>              
    </xsl:for-each>
</xsl:template>

1 Answer 1

1

You need to tell us which XSLT processor you are using. The URIs recognized by the XSLT 2.0 collection() function are processor-dependent. In addition, you haven't said whether there are other files in this directory structure that you DON'T want to process.

In Saxon, if you want to process all the XML files in a directory you can use

collection('source?recurse=yes;select=*.xml')
Sign up to request clarification or add additional context in comments.

4 Comments

The XSLT processor I'm using is XMLSpy and there are other files in this folder structure that i don't want to process
Then you'll have to consult the RaptorXML documentation. I don't expect Altova are listening to this forum (but you never know...)
Thanks, but decided to go another way and use powershell to accomplish this. Very simple 5 line code to achieve it.
Yes, when the transformations to be applied to each file are completely independent of each other, then controlling it externally to the XSLT code is often the best way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.