Thursday, 20 February 2014

Create list of files using XSLT

Issue - need a directory listing of xml files using purely XSLT

Resolution - create an XSLT with the following code, name this as lister.xsl and use the Saxon initial template option -it to call the template

java -jar saxon.jar -it:lister -xsl:lister.xsl -o:filelist.xml

<xsl:stylesheet version="2.0" xmlns:xsl=""

  <xsl:template name="lister">
        select="collection('./?select=*.xml;recurse=yes;on-error=warning')" >
 <xsl:element name='file'>
   <xsl:attribute name="full" select="document-uri(.)"/>
   <xsl:value-of select="tokenize(document-uri(.), '/')[last()]"/>

No comments:

Post a Comment