I am trying to generate an XML file that list XML files that are in a specified folder using xsl:
XML file :
<xml>
<folder>FolderPath-to-List</folder>
</xml>
Expected result:
<mergeData newRoot="newRoot">
<fileList>
<fileItem>path-to-file/file1.xml</fileItem>
<fileItem>path-to-file/file2.xml</fileItem>
<fileItem>path-to-file/file3.xml</fileItem>
<fileItem>path-to-file/file4.xml</fileItem>
</fileList>
</mergeData>
So far I am able to collect Files list using XSL and embedded script/ JScipt function as follow in the current folder:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://tempuri.org/msxsl"
>
<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[
var fso = new ActiveXObject("Scripting.FileSystemObject");
function ShowFolderFileList(folderspec)
{
var f, f1, fc, s;
f = fso.GetFolder(folderspec);
fc = new Enumerator(f.files);
s = '<fileItem>';
for (; !fc.atEnd(); fc.moveNext())
{
s += fc.item();
s += '<fileItem>\n<fileItem>';
}
return(s);
}
]]>
</msxsl:script>
<xsl:template match="/">
<mergeData newRoot="Activity">
<fileList>
<xsl:value-of select="user:ShowFolderFileList('.')"/>
</fileList>
</mergeData>
</xsl:template>
</xsl:stylesheet>
But the result is that in place of getting <fileItem>
and </fileItem>
, I have :
<fileItem>path-to-xml\file.xml<fileItem>
How can I get <fileItem>path-to-xml\file.xml</fileItem>
?
How can I get the "FolderPath-to-List" from my XML to be used when calling user:ShowFolderFileList() in place of '.' so far to get it running.