summaryrefslogtreecommitdiff
path: root/doc/xslt
diff options
context:
space:
mode:
authorLuca Falavigna <dktrkranz@debian.org>2014-04-26 15:11:58 +0200
committerLuca Falavigna <dktrkranz@debian.org>2014-04-26 15:11:58 +0200
commita3a0ab66f0da855e75e3a0e2acfb8aa106b46510 (patch)
tree5352edff1387c3d7e5a8b49ec56524f085c22782 /doc/xslt
parent51fa4e4acb6fc8fc7a2af0fbdc21fd1e8feddb3a (diff)
parent140d836e9cd54fb67b969fd82ef7ed19ba574d40 (diff)
Merge tag 'upstream/2.3.1'
Upstream version 2.3.1
Diffstat (limited to 'doc/xslt')
-rw-r--r--doc/xslt/to_docbook.xslt102
-rw-r--r--doc/xslt/xinclude_examples.xslt40
2 files changed, 142 insertions, 0 deletions
diff --git a/doc/xslt/to_docbook.xslt b/doc/xslt/to_docbook.xslt
new file mode 100644
index 0000000..0b39c28
--- /dev/null
+++ b/doc/xslt/to_docbook.xslt
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Changing element names from SCons XSD to real Docbook.
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:scons="http://www.scons.org/dbxsd/v1.0">
+ <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
+
+ <!-- Copy everything unmatched -->
+ <xsl:template match="*">
+ <xsl:element name="{local-name()}">
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates select="node()"/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="text() | comment() | processing-instruction()">
+ <xsl:copy/>
+ </xsl:template>
+
+ <!-- Helper function for replacing strings in strings -->
+ <xsl:template name="string-replace-all">
+ <xsl:param name="text" />
+ <xsl:param name="replace" />
+ <xsl:param name="by" />
+ <xsl:choose>
+ <xsl:when test="contains($text, $replace)">
+ <xsl:value-of select="substring-before($text,$replace)" />
+ <xsl:value-of select="$by" />
+ <xsl:call-template name="string-replace-all">
+ <xsl:with-param name="text"
+ select="substring-after($text,$replace)" />
+ <xsl:with-param name="replace" select="$replace" />
+ <xsl:with-param name="by" select="$by" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- Leaving scons_example empty -->
+ <xsl:template match="scons:scons_example">
+ <xsl:apply-templates select="node()"/>
+ </xsl:template>
+
+ <!-- Changing example_commands to screen -->
+ <xsl:template match="scons:example_commands">
+ <xsl:element name="screen">
+ <xsl:apply-templates select="node()"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Leaving scons_output empty, should already
+ have been handled by xinclude_examples.xslt -->
+ <xsl:template match="scons:scons_output">
+ <xsl:apply-templates select="node()"/>
+ </xsl:template>
+
+ <!-- Leaving scons_output_command empty, should already
+ have been handled by xinclude_examples.xslt.
+ -->
+ <xsl:template match="scons:scons_output_command">
+ </xsl:template>
+
+ <!-- Leaving scons_example_file empty, should already
+ have been handled by xinclude_examples.xslt.
+ -->
+ <xsl:template match="scons:scons_example_file">
+ </xsl:template>
+
+ <!-- Changing file to programlisting if printme == '1' -->
+ <xsl:template match="scons:file">
+ <xsl:if test="@printme='1'">
+ <xsl:element name="programlisting">
+ <xsl:call-template name="string-replace-all">
+ <xsl:with-param name="text" select="node()" />
+ <xsl:with-param name="replace" select="'__ROOT__'" />
+ <xsl:with-param name="by" select="''" />
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- Changing sconstruct to programlisting -->
+ <xsl:template match="scons:sconstruct">
+ <xsl:element name="programlisting">
+ <xsl:call-template name="string-replace-all">
+ <xsl:with-param name="text" select="node()" />
+ <xsl:with-param name="replace" select="'__ROOT__'" />
+ <xsl:with-param name="by" select="''" />
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Leave directory empty -->
+ <xsl:template match="scons:directory">
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/doc/xslt/xinclude_examples.xslt b/doc/xslt/xinclude_examples.xslt
new file mode 100644
index 0000000..50696ac
--- /dev/null
+++ b/doc/xslt/xinclude_examples.xslt
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Changing example command outputs to XIncludes for the UserGuide.
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:scons="http://www.scons.org/dbxsd/v1.0"
+ xmlns:xsi="http://www.w3.org/2001/XInclude">
+ <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
+
+ <!-- Copy everything unmatched -->
+ <xsl:template match="*">
+ <xsl:element name="{name()}" namespace="{namespace-uri()}">
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates select="node()"/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="text() | comment() | processing-instruction()">
+ <xsl:copy/>
+ </xsl:template>
+
+ <!-- Changing scons_output to xinclude -->
+ <xsl:template match="scons:scons_output">
+ <xsl:element name="xsi:include">
+ <xsl:attribute name="href"><xsl:value-of select="concat('../generated/examples/',@example,'_',@suffix,'.xml')"></xsl:value-of></xsl:attribute>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Changing scons_example_file to xinclude -->
+ <xsl:template match="scons:scons_example_file">
+ <xsl:variable name="newfile" select="translate(@name,'/','_')"/>
+ <xsl:element name="programlisting">
+ <xsl:element name="xsi:include">
+ <xsl:attribute name="href"><xsl:value-of select="concat('../generated/examples/',@example,'_',$newfile)"></xsl:value-of></xsl:attribute>
+ <xsl:attribute name="parse">text</xsl:attribute>
+ </xsl:element>
+ </xsl:element>
+ </xsl:template>
+
+</xsl:stylesheet>