Last active
December 10, 2015 07:38
-
-
Save nine9ths/4402113 to your computer and use it in GitHub Desktop.
XSLT 3.0 stylesheet for Saxon to create a saxon catalog file for collections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet | |
version="3.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:file="java:java.io.File" | |
xmlns:jt="http://saxon.sf.net/java-type" | |
exclude-result-prefixes="xs file jt"> | |
<xsl:param name="directory"/> | |
<xsl:output indent="yes"/> | |
<xsl:mode name="recurse" on-no-match="deep-skip"/> | |
<xsl:mode name="output" on-no-match="deep-skip"/> | |
<xsl:template match="/"> | |
<collection> | |
<xsl:apply-templates mode="recurse" select="file:new(resolve-uri($directory))"/> | |
</collection> | |
</xsl:template> | |
<xsl:template mode="recurse" match="~jt:java.io.File[file:isDirectory(.)]"> | |
<xsl:apply-templates mode="#current" select="file:listFiles(.)"/> | |
</xsl:template> | |
<xsl:template mode="recurse" match="~jt:java.io.File"> | |
<xsl:apply-templates mode="output" select="xs:anyURI(file:toURI(.))"/> | |
</xsl:template> | |
<xsl:template mode="output" match="~xs:anyURI[doc-available(.)]"> | |
<doc href="{.}"/> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment