aboutsummaryrefslogtreecommitdiff
path: root/generate.xsl
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-08-23 12:58:32 +0200
committerAdrian Kummerlaender2014-08-23 12:58:32 +0200
commitb942f8ed534e789495b74cc87fd155b0bd2dab0b (patch)
tree29e1cf7ebb10acb7c6708b926c811e06962d05a1 /generate.xsl
parent99b8d15f33ac71fe85bb2fa7001d080931bba7ba (diff)
downloadblog.kummerlaender.eu-b942f8ed534e789495b74cc87fd155b0bd2dab0b.tar
blog.kummerlaender.eu-b942f8ed534e789495b74cc87fd155b0bd2dab0b.tar.gz
blog.kummerlaender.eu-b942f8ed534e789495b74cc87fd155b0bd2dab0b.tar.bz2
blog.kummerlaender.eu-b942f8ed534e789495b74cc87fd155b0bd2dab0b.tar.lz
blog.kummerlaender.eu-b942f8ed534e789495b74cc87fd155b0bd2dab0b.tar.xz
blog.kummerlaender.eu-b942f8ed534e789495b74cc87fd155b0bd2dab0b.tar.zst
blog.kummerlaender.eu-b942f8ed534e789495b74cc87fd155b0bd2dab0b.zip
Revamped source tree traversion
* this was done to be able to implement directory symlinking * the generation process is now split into three transformations ** the actual work is performed by "list.xsl" and "traverse.xsl" respecitively ** "make.xsl" wraps these two transformations *** i.e. generation is now launched by executing "ixslt --transformation make.xsl" * checked background images into VCS
Diffstat (limited to 'generate.xsl')
-rw-r--r--generate.xsl205
1 files changed, 0 insertions, 205 deletions
diff --git a/generate.xsl b/generate.xsl
deleted file mode 100644
index bac0288..0000000
--- a/generate.xsl
+++ /dev/null
@@ -1,205 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet
- version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:dyn="http://exslt.org/dynamic"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:InputXSLT="function.inputxslt.application"
- exclude-result-prefixes="dyn xalan InputXSLT"
->
-
-<xsl:import href="utility/helper.xsl"/>
-
-<xsl:output
- method="xml"
- omit-xml-declaration="yes"
- encoding="UTF-8"
- indent="yes"
-/>
-
-<xsl:template name="generate">
- <xsl:param name="input"/>
- <xsl:param name="transformation"/>
- <xsl:param name="target"/>
-
- <xsl:copy-of select="InputXSLT:generate(
- $input,
- $transformation,
- $target
- )/self::generation"/>
-</xsl:template>
-
-<xsl:template name="merge_datasource">
- <xsl:param name="main"/>
- <xsl:param name="support"/>
-
- <datasource>
- <xsl:copy-of select="$main"/>
- <xsl:copy-of select="$support"/>
- </datasource>
-</xsl:template>
-
-<xsl:template name="resolve_datasource">
- <xsl:param name="datasource"/>
-
- <xsl:for-each select="$datasource">
- <xsl:element name="{./@target}">
- <xsl:choose>
- <xsl:when test="./@mode = 'full'">
- <xsl:copy-of select="InputXSLT:read-file(./@source)/self::file/*/*"/>
- </xsl:when>
- </xsl:choose>
- </xsl:element>
- </xsl:for-each>
-</xsl:template>
-
-<xsl:template name="resolve_target">
- <xsl:param name="prefix"/>
- <xsl:param name="target"/>
- <xsl:param name="datasource"/>
-
- <xsl:choose>
- <xsl:when test="$target/@mode = 'plain'">
- <xsl:value-of select="concat($prefix, '/', $target/@value)"/>
- </xsl:when>
- <xsl:when test="$target/@mode = 'xpath'">
- <xsl:value-of select="concat($prefix, '/', dyn:evaluate($target/@value))"/>
- </xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="compile">
- <xsl:param name="main"/>
- <xsl:param name="support"/>
- <xsl:param name="transformation"/>
- <xsl:param name="target_prefix"/>
- <xsl:param name="target"/>
-
- <xsl:variable name="datasource">
- <xsl:call-template name="merge_datasource">
- <xsl:with-param name="main" select="$main"/>
- <xsl:with-param name="support">
- <xsl:call-template name="resolve_datasource">
- <xsl:with-param name="datasource" select="$support"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="resolved_target">
- <xsl:call-template name="resolve_target">
- <xsl:with-param name="prefix" select="$target_prefix"/>
- <xsl:with-param name="target" select="$target"/>
- <xsl:with-param name="datasource" select="$datasource"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:call-template name="generate">
- <xsl:with-param name="input" select="$datasource"/>
- <xsl:with-param name="transformation" select="$transformation"/>
- <xsl:with-param name="target" select="$resolved_target"/>
- </xsl:call-template>
-</xsl:template>
-
-<xsl:template name="process">
- <xsl:param name="file"/>
- <xsl:param name="target"/>
-
- <xsl:variable name="transformation" select="InputXSLT:read-file($file/full)/self::file/*"/>
- <xsl:variable name="meta" select="$transformation/self::*[name() = 'xsl:stylesheet']/*[name() = 'xsl:variable' and @name = 'meta']"/>
- <xsl:variable name="main_source" select="$meta/datasource[@type = 'main']"/>
- <xsl:variable name="support_source" select="$meta/datasource[@type = 'support']"/>
-
- <xsl:choose>
- <xsl:when test="$main_source/@mode = 'full'">
- <xsl:call-template name="compile">
- <xsl:with-param name="main">
- <xsl:element name="{$main_source/@target}">
- <xsl:copy-of select="InputXSLT:read-file($main_source/@source)/self::file/*/*"/>
- </xsl:element>
- </xsl:with-param>
- <xsl:with-param name="support" select="$support_source"/>
- <xsl:with-param name="transformation" select="$transformation"/>
- <xsl:with-param name="target_prefix" select="$target"/>
- <xsl:with-param name="target" select="$meta/target"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$main_source/@mode = 'iterate'">
- <xsl:for-each select="InputXSLT:read-file($main_source/@source)/self::file/*/entry">
- <xsl:call-template name="compile">
- <xsl:with-param name="main">
- <xsl:element name="{$main_source/@target}">
- <xsl:copy-of select="."/>
- </xsl:element>
- </xsl:with-param>
- <xsl:with-param name="support" select="$support_source"/>
- <xsl:with-param name="transformation" select="$transformation"/>
- <xsl:with-param name="target_prefix" select="$target"/>
- <xsl:with-param name="target" select="$meta/target"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="compile">
- <xsl:with-param name="support" select="$support_source"/>
- <xsl:with-param name="transformation" select="$transformation"/>
- <xsl:with-param name="target_prefix" select="$target"/>
- <xsl:with-param name="target" select="$meta/target"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="traverse">
- <xsl:param name="source"/>
- <xsl:param name="target"/>
- <xsl:param name="path"/>
-
- <xsl:variable name="entries" select="InputXSLT:read-directory(
- concat($source, '/', $path)
- )/entry"/>
-
- <xsl:for-each select="$entries">
- <xsl:choose>
- <xsl:when test="@type = 'directory'">
- <xsl:call-template name="traverse">
- <xsl:with-param name="source" select="$source"/>
- <xsl:with-param name="target" select="$target"/>
- <xsl:with-param name="path" select="concat($path, '/', ./name)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="./extension = '.xsl'">
- <xsl:call-template name="process">
- <xsl:with-param name="file" select="."/>
- <xsl:with-param name="target" select="concat($target, '/', $path)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="./extension = '.css'">
- <xsl:call-template name="linker">
- <xsl:with-param name="from" select="./full"/>
- <xsl:with-param name="to" select="concat($target, '/', $path, '/', ./name, ./extension)"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
-</xsl:template>
-
-<xsl:template match="/">
- <xsl:variable name="source">source</xsl:variable>
- <xsl:variable name="target">target</xsl:variable>
-
- <xsl:call-template name="cleaner">
- <xsl:with-param name="path" select="$target"/>
- </xsl:call-template>
-
- <xsl:call-template name="traverse">
- <xsl:with-param name="source" select="$source"/>
- <xsl:with-param name="target" select="$target"/>
- </xsl:call-template>
-</xsl:template>
-
-</xsl:stylesheet>