Page 1 of 1

Copy output XML files to multiple folders

Posted: Tue Jun 25, 2013 6:20 pm
by eloralon

I am struggling with the following issue, which is that I need to be able to output XML files to multiple folders based on the XML filename using XSLT.

All files with names starting with B should go to one folder, files starting go to another folder and so on..

I have the following XSLT and it works fine to generate the needed files, but I am not able to output to multiple folders, which is what I need.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="" version="2.0"
<xsl:output method="xml" doctype-public="-//OASIS//DTD DITA Glossary//EN"
doctype-system="glossary.dtd" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="title"/>
<xsl:param name="files"
<xsl:template match="node()">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="node()"/>
<xsl:template match="/">
<xsl:for-each select="$files//topic">
<xsl:value-of select="text()" disable-output-escaping="yes"/>
<xsl:result-document href="DITA/glossentries_all/{title/text()|title/b/text()}.dita">
<glossentry id="{concat('dita', generate-id())}">
<glossterm id="{concat('my_title', generate-id())}">
<xsl:value-of select="title"/>
<xsl:for-each select="body">

Re: Copy output XML files to multiple folders

Posted: Tue Jun 25, 2013 8:04 pm
by eloralon
I got the files to be copied to multiple folders just as I wanted by using the following line of code, suggested by Michael Kay:

Code: Select all

<xsl:result-document href="DITA/glossentries_all/{substring(title,1,1)}/{title/text()|title/b/text()}.dita"> 
as shown ... st292220">