Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/current/include/dslc-base.xsl')
-rw-r--r--src/current/include/dslc-base.xsl90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/current/include/dslc-base.xsl b/src/current/include/dslc-base.xsl
new file mode 100644
index 0000000..53a3195
--- /dev/null
+++ b/src/current/include/dslc-base.xsl
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Additional functionality provided by dslc
+
+ XSL does not provide every feature suitable for compilation (which is no
+ suprise, since this was not its intended use case). As such, dslc provides
+ additional features that are defined/abstracted within this file; every
+ template that is intended for use with dslc should include this.
+-->
+<xsl:stylesheet version="1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+
+<!--
+ Package source path, stripped of its extension
+
+ XSL does not provide a means of exposing the file path (nor should it,
+ really). This param will hold the source path of the package, sans its
+ extension, relative to the project root that was used during compilation.
+
+ I.e., given this source path:
+ suppliers/common/foo.xml
+ we would expect this value for __srcpkg:
+ suppliers/common/foo
+
+ By stripping the extension, we have the benefit of being void of any semantics
+ that may be associated with it (e.g. xml vs xmlo vs xmle); rather, that
+ information should be derived from the structe of the document itself and the
+ path can be used as an identifier to describe the document as a whole,
+ regardless of what form it is in.
+
+ Consequently, no two files are able to have the same __srcpkg string; this
+ value may therefore be used for disambiguation.
+-->
+<xsl:param name="__srcpkg" />
+
+
+<!--
+ Relative path to project root
+
+ The project root is determined entirely by __srcpath by repeating the string
+ "../" for the number of occurrances of "/".
+-->
+<xsl:param name="__relroot" />
+
+
+<!--
+ Random value that may be used to seed random values
+
+ XSLT is deterministic and does not offer support for generating random values;
+ its generate-id() function is not sufficient for cross-package generation.
+-->
+<xsl:param name="__rseed" />
+
+
+<!--
+ Root node of template on which stylesheet was invoked
+
+ This points to the original, unprocessed document. This is especially
+ important for `document' function calls, which use nodes as a reference
+ point for resolving relative paths.
+-->
+<xsl:variable name="__entry-root" select="/" />
+
+
+
+<!--
+ Apply relative root to PATH
+
+ If PATH is an absolute path, it will be prefixed with the relative root
+ with the leading path delimiter stripped; otherwise, it will be echoed
+ as-is.
+-->
+<xsl:template name="__apply-relroot">
+ <xsl:param name="path" />
+
+ <xsl:choose>
+ <xsl:when test="starts-with( $path, '/' )">
+ <xsl:value-of select="$__relroot" />
+ <xsl:value-of select="substring-after( $path, '/' )" />
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="$path" />
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>