[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 |
|
---|
[db9cec6] | 9 | <xsl:param name="testsuite" select="0"/>
|
---|
| 10 |
|
---|
[557fe91] | 11 | <xsl:template match="/">
|
---|
| 12 | <xsl:apply-templates select="//sect1"/>
|
---|
| 13 | </xsl:template>
|
---|
| 14 |
|
---|
| 15 | <xsl:template match="sect1">
|
---|
[c4cf6de] | 16 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 17 | count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
---|
| 18 | <!-- The dirs names -->
|
---|
| 19 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 20 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 21 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 22 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 23 | <!-- The file names -->
|
---|
| 24 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 25 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 26 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 27 | <!-- The build order -->
|
---|
| 28 | <xsl:variable name="position" select="position()"/>
|
---|
| 29 | <xsl:variable name="order">
|
---|
| 30 | <xsl:choose>
|
---|
| 31 | <xsl:when test="string-length($position) = 1">
|
---|
| 32 | <xsl:text>00</xsl:text>
|
---|
| 33 | <xsl:value-of select="$position"/>
|
---|
| 34 | </xsl:when>
|
---|
| 35 | <xsl:when test="string-length($position) = 2">
|
---|
| 36 | <xsl:text>0</xsl:text>
|
---|
| 37 | <xsl:value-of select="$position"/>
|
---|
| 38 | </xsl:when>
|
---|
| 39 | <xsl:otherwise>
|
---|
| 40 | <xsl:value-of select="$position"/>
|
---|
| 41 | </xsl:otherwise>
|
---|
| 42 | </xsl:choose>
|
---|
| 43 | </xsl:variable>
|
---|
| 44 | <!-- Creating dirs and files -->
|
---|
| 45 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
| 46 | <xsl:text>#!/bin/sh

</xsl:text>
|
---|
[db9cec6] | 47 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
[c4cf6de] | 48 | </exsl:document>
|
---|
| 49 | </xsl:if>
|
---|
[557fe91] | 50 | </xsl:template>
|
---|
| 51 |
|
---|
| 52 | <xsl:template match="screen">
|
---|
| 53 | <xsl:if test="child::* = userinput">
|
---|
| 54 | <xsl:choose>
|
---|
| 55 | <xsl:when test="@role = 'nodump'"/>
|
---|
| 56 | <xsl:otherwise>
|
---|
[db9cec6] | 57 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
[b8bf2f8] | 58 | <xsl:if test="position() != last() and
|
---|
| 59 | not(contains(string(),'EOF'))">
|
---|
[c4cf6de] | 60 | <xsl:text> &&</xsl:text>
|
---|
| 61 | </xsl:if>
|
---|
| 62 | <xsl:text>
</xsl:text>
|
---|
[557fe91] | 63 | </xsl:otherwise>
|
---|
| 64 | </xsl:choose>
|
---|
| 65 | </xsl:if>
|
---|
| 66 | </xsl:template>
|
---|
| 67 |
|
---|
[db9cec6] | 68 | <xsl:template match="para/userinput">
|
---|
[c355ad1] | 69 | <xsl:if test="$testsuite = '0' and (contains(string(),'test') or
|
---|
| 70 | contains(string(),'check'))">
|
---|
[db9cec6] | 71 | <xsl:apply-templates/>
|
---|
| 72 | <xsl:text> &&
</xsl:text>
|
---|
| 73 | </xsl:if>
|
---|
| 74 | </xsl:template>
|
---|
| 75 |
|
---|
| 76 | <xsl:template match="userinput" mode="screen">
|
---|
[557fe91] | 77 | <xsl:apply-templates/>
|
---|
| 78 | </xsl:template>
|
---|
| 79 |
|
---|
| 80 | <xsl:template match="replaceable">
|
---|
| 81 | <xsl:text>**EDITME</xsl:text>
|
---|
| 82 | <xsl:apply-templates/>
|
---|
| 83 | <xsl:text>EDITME**</xsl:text>
|
---|
| 84 | </xsl:template>
|
---|
| 85 |
|
---|
| 86 | </xsl:stylesheet>
|
---|