Solved my own question after few trials and errors. Thanks to all for their help.
I have a question about how to transform a set of XML files located in a folder on the local system. I need to transform the files to XML while keeping the original names, which are based on the topic text().
I am currently able to transform the a file using the xslt and I get the desired result, but because I have a good number of files it is not practical to transform the files one at a time.
My input XML look like the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic>
<title class="- topic/title ">
Term
</title>
<body class="- topic/body ">
<p class="- topic/p ">Paragraph new</p>
<p class="- topic/p ">(See New parag.)</p>
<p class="- topic/p ">(See Next parag.)</p>
<p class="- topic/p ">(See Test.)</p>
<p class="- topic/p ">(See The other parag)</p>
<p class="- topic/p ">(Refer to the conclusion)</p>
</body>
</topic>
and my XSLT is the following
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" >
<!-- This adds DOCTYPE declaration -->
<xsl:output method="xml" encoding="UTF-8"
doctype-public="-//OASIS//DTD DITA Glossary//EN"
name="mygloss" doctype-system="glossary.dtd" omit-xml-declaration="no" indent="yes" />
<xsl:output omit-xml-declaration="no" indent="yes"/>
<xsl:param name="files" select="collection('../A/?select=*.dita;recurse=yes')"/>
<xsl:template match="node()|@*">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:for-each select="$files//topic">
<!--had issues with this portion, but fixed it by changing from topic/>text() to title/text(). -->
<xsl:result-document href="outputDITANEW/{title/text()}.dita" format="mygloss">
<glossentry id="{concat('test', generate-id())}">
<glossterm id="{concat('test_title', generate-id())}">
<xsl:value-of select="title"/>
</glossterm>
<glossdef>
<xsl:for-each select="body">
<xsl:apply-templates/>
</xsl:for-each>
</glossdef>
</glossentry>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Output XML looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glossentry
PUBLIC "-//OASIS//DTD DITA Glossary//EN" "glossary.dtd">
<glossentry id="test_d2e11">
<glossterm id="new_term_d2e3">
Term
</glossterm>
<glossdef>
<p>Paragraph new</p>
<p>(See New parag.)</p>
<p>(See Next parag.)</p>
<p>(See Test.)</p>
<p>(See The other parag)</p>
<p>(Refer to the conclusion)</p>
</glossdef>
</glossentry>
I have tried to use xslt collection() and result-document(), but I am unable to make it work.
The above xslt gives me this error: A sequence of more than one item is not allowed as the first argument of concat().
Hopefully this will give more clarity to my question.
Thanks in advance for your help.