darma teja

darma teja

  • NA
  • 496
  • 328.4k

xslt filename problem in href

Oct 8 2015 4:12 AM
by using xslt, I am going to split my xml files. The follow code works fine. But it creats problem with filenames.
my sample xml file is here:
<roottag>
<child1>
<file name='test1'>
<content>content file 1</content>
</file>
<file name='test / test2'>
<content>content file 2</content>
</file>
<file name='test3'>
<content>content file 3</content>
</file>
</child1>
</roottag>
 
it created 2 output xml files in out folder as test1.xml, test3.xml.
test2.xml file created on out/test/ folder. It means it preserve spaces.
I would like to have test_test2.xml in out folder. 
How can I achieve this:
my xslt code is here:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="roottag">
<xsl:for-each select="child1">
<xsl:result-document method="xml" href="out/{@name}.xml">
<translations>
<xsl:copy-of select="/roottag/@*" />
<xsl:copy-of select="../@* | ." />
</translations>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
 
Advance thanks,
Darma