[557fe91] | 1 | <?xml version="1.0"?>
|
---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 3 | xmlns:exsl="http://exslt.org/common"
|
---|
| 4 | extension-element-prefixes="exsl"
|
---|
| 5 | version="1.0">
|
---|
| 6 |
|
---|
[63b2859] | 7 | <!-- XSLT stylesheet to create shell scripts from LFS books. -->
|
---|
[557fe91] | 8 |
|
---|
| 9 | <xsl:template match="/">
|
---|
| 10 | <xsl:apply-templates select="//sect1"/>
|
---|
| 11 | </xsl:template>
|
---|
| 12 |
|
---|
| 13 | <xsl:template match="sect1">
|
---|
[c4cf6de] | 14 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 15 | count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
---|
| 16 | <!-- The dirs names -->
|
---|
| 17 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 18 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 19 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 20 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 21 | <!-- The file names -->
|
---|
| 22 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 23 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 24 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 25 | <!-- The build order -->
|
---|
| 26 | <xsl:variable name="position" select="position()"/>
|
---|
| 27 | <xsl:variable name="order">
|
---|
| 28 | <xsl:choose>
|
---|
| 29 | <xsl:when test="string-length($position) = 1">
|
---|
| 30 | <xsl:text>00</xsl:text>
|
---|
| 31 | <xsl:value-of select="$position"/>
|
---|
| 32 | </xsl:when>
|
---|
| 33 | <xsl:when test="string-length($position) = 2">
|
---|
| 34 | <xsl:text>0</xsl:text>
|
---|
| 35 | <xsl:value-of select="$position"/>
|
---|
| 36 | </xsl:when>
|
---|
| 37 | <xsl:otherwise>
|
---|
| 38 | <xsl:value-of select="$position"/>
|
---|
| 39 | </xsl:otherwise>
|
---|
| 40 | </xsl:choose>
|
---|
| 41 | </xsl:variable>
|
---|
| 42 | <!-- Creating dirs and files -->
|
---|
| 43 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
| 44 | <xsl:text>#!/bin/sh

</xsl:text>
|
---|
| 45 | <xsl:apply-templates select=".//screen"/>
|
---|
| 46 | </exsl:document>
|
---|
| 47 | </xsl:if>
|
---|
[557fe91] | 48 | </xsl:template>
|
---|
| 49 |
|
---|
| 50 | <xsl:template match="screen">
|
---|
| 51 | <xsl:if test="child::* = userinput">
|
---|
| 52 | <xsl:choose>
|
---|
| 53 | <xsl:when test="@role = 'nodump'"/>
|
---|
| 54 | <xsl:otherwise>
|
---|
| 55 | <xsl:apply-templates select="userinput"/>
|
---|
[c4cf6de] | 56 | <xsl:if test="position() != last()">
|
---|
| 57 | <xsl:text> &&</xsl:text>
|
---|
| 58 | </xsl:if>
|
---|
| 59 | <xsl:text>
</xsl:text>
|
---|
[557fe91] | 60 | </xsl:otherwise>
|
---|
| 61 | </xsl:choose>
|
---|
| 62 | </xsl:if>
|
---|
| 63 | </xsl:template>
|
---|
| 64 |
|
---|
| 65 | <xsl:template match="userinput">
|
---|
| 66 | <xsl:apply-templates/>
|
---|
| 67 | </xsl:template>
|
---|
| 68 |
|
---|
| 69 | <xsl:template match="replaceable">
|
---|
| 70 | <xsl:text>**EDITME</xsl:text>
|
---|
| 71 | <xsl:apply-templates/>
|
---|
| 72 | <xsl:text>EDITME**</xsl:text>
|
---|
| 73 | </xsl:template>
|
---|
| 74 |
|
---|
| 75 | </xsl:stylesheet>
|
---|