Started XSL redo.
This commit is contained in:
parent
9c9775f7c4
commit
3778352091
1 changed files with 163 additions and 64 deletions
177
LFS/lfs.xsl
177
LFS/lfs.xsl
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
<!-- XSLT stylesheet to create shell scripts from LFS books. -->
|
<!-- XSLT stylesheet to create shell scripts from LFS books. -->
|
||||||
|
|
||||||
|
<!-- ####################### PARAMETERS ################################### -->
|
||||||
|
|
||||||
<!-- Run test suites?
|
<!-- Run test suites?
|
||||||
0 = none
|
0 = none
|
||||||
1 = only chapter06 Glibc, GCC and Binutils testsuites
|
1 = only chapter06 Glibc, GCC and Binutils testsuites
|
||||||
|
@ -36,84 +38,181 @@
|
||||||
<!-- Page size -->
|
<!-- Page size -->
|
||||||
<xsl:param name="page" select="letter"/>
|
<xsl:param name="page" select="letter"/>
|
||||||
|
|
||||||
<!-- Locale settings -->
|
<!-- Locale setting -->
|
||||||
<xsl:param name="lang" select="C"/>
|
<xsl:param name="lang" select="C"/>
|
||||||
|
|
||||||
<xsl:template match="/">
|
<!-- ####################################################################### -->
|
||||||
<xsl:apply-templates select="//sect1"/>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
<xsl:template match="sect1">
|
<!-- ########################### NAMED TEMPLATES ########################### -->
|
||||||
<xsl:if test="(../@id='chapter-temporary-tools' or
|
|
||||||
../@id='chapter-building-system' or
|
<!-- Chapter directory name (the same used for HTML output) -->
|
||||||
../@id='chapter-bootscripts' or
|
<xsl:template name="dirname">
|
||||||
../@id='chapter-bootable') and
|
<xsl:variable name="pi-dir" select="processing-instruction('dbhtml')"/>
|
||||||
count(descendant::screen/userinput) > 0 and
|
|
||||||
count(descendant::screen/userinput) >
|
|
||||||
count(descendant::screen[@role='nodump'])">
|
|
||||||
<!-- The dirs names -->
|
|
||||||
<xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
|
||||||
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
||||||
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
||||||
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
||||||
<!-- The file names -->
|
<xsl:value-of select="$dirname"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Base file name (the same used for HTML output) -->
|
||||||
|
<xsl:template name="filename">
|
||||||
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
||||||
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
||||||
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
||||||
<!-- The build order -->
|
<xsl:value-of select="$filename"/>
|
||||||
<xsl:variable name="position" select="position()"/>
|
</xsl:template>
|
||||||
<xsl:variable name="order">
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="string-length($position) = 1">
|
<!-- Script header -->
|
||||||
<xsl:text>00</xsl:text>
|
<xsl:template name="header">
|
||||||
<xsl:value-of select="$position"/>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:when test="string-length($position) = 2">
|
|
||||||
<xsl:text>0</xsl:text>
|
|
||||||
<xsl:value-of select="$position"/>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select="$position"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:variable>
|
|
||||||
<!-- Creating dirs and files -->
|
|
||||||
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@id='ch-system-creatingdirs' or
|
<xsl:when test="@id='ch-system-creatingdirs' or
|
||||||
@id='ch-system-createfiles' or
|
@id='ch-system-createfiles' or
|
||||||
@id='ch-system-strippingagain'">
|
@id='ch-system-strippingagain'">
|
||||||
<xsl:text>#!/tools/bin/bash
set +h
</xsl:text>
|
<xsl:text>#!/tools/bin/bash
</xsl:text>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:text>#!/bin/bash
set +h
</xsl:text>
|
<xsl:text>#!/bin/bash
</xsl:text>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
|
||||||
|
<xsl:text>set +h
</xsl:text>
|
||||||
|
|
||||||
<xsl:if test="not(@id='ch-tools-stripping') and
|
<xsl:if test="not(@id='ch-tools-stripping') and
|
||||||
not(@id='ch-system-strippingagain')">
|
not(@id='ch-system-strippingagain')">
|
||||||
<xsl:text>set -e
</xsl:text>
|
<xsl:text>set -e
</xsl:text>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
|
||||||
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Extra previous commands needed by the book but not inside screen tags -->
|
||||||
|
<xsl:template name="pre_commands">
|
||||||
<xsl:if test="sect2[@role='installation']">
|
<xsl:if test="sect2[@role='installation']">
|
||||||
<xsl:text>cd $PKGDIR
</xsl:text>
|
<xsl:text>cd $PKGDIR
</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
<xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
|
<xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
|
||||||
<xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
<xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:if>
|
</xsl:template>
|
||||||
<xsl:apply-templates select=".//screen"/>
|
|
||||||
|
|
||||||
|
<!-- Extra post commands needed by the book but not inside screen tags -->
|
||||||
|
<xsl:template name="post_commands">
|
||||||
<xsl:if test="$testsuite='3' and @id='ch-tools-glibc'">
|
<xsl:if test="$testsuite='3' and @id='ch-tools-glibc'">
|
||||||
<xsl:copy-of select="//userinput[@remap='locale-test']"/>
|
<xsl:copy-of select="//userinput[@remap='locale-test']"/>
|
||||||
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Script footer -->
|
||||||
|
<xsl:template name="footer">
|
||||||
<xsl:if test="not(@id='ch-system-chroot') and
|
<xsl:if test="not(@id='ch-system-chroot') and
|
||||||
not(@id='ch-system-revisedchroot')">
|
not(@id='ch-system-revisedchroot')">
|
||||||
<xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"
</xsl:text>
|
<xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"
</xsl:text>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
|
||||||
<xsl:text>exit
</xsl:text>
|
<xsl:text>exit
</xsl:text>
|
||||||
</exsl:document>
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- ######################################################################## -->
|
||||||
|
|
||||||
|
<!-- ############################# MATCH TEMPLATES ########################## -->
|
||||||
|
|
||||||
|
<!-- Root element -->
|
||||||
|
<xsl:template match="/">
|
||||||
|
<xsl:apply-templates select="//chapter"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- chapter -->
|
||||||
|
<xsl:template match="chapter">
|
||||||
|
<xsl:if test="@id='chapter-temporary-tools' or @id='chapter-building-system'
|
||||||
|
or @id='chapter-bootscripts' or @id='chapter-bootable'">
|
||||||
|
|
||||||
|
<!-- The dir name -->
|
||||||
|
<xsl:variable name="dirname">
|
||||||
|
<xsl:call-template name="dirname"/>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<!-- The chapter order position -->
|
||||||
|
<xsl:variable name="ch_position" select="position()"/>
|
||||||
|
<xsl:variable name="ch_order">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="string-length($ch_position) = 1">
|
||||||
|
<xsl:text>0</xsl:text>
|
||||||
|
<xsl:value-of select="$ch_position"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$ch_position"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:apply-templates select="sect1">
|
||||||
|
<xsl:with-param name="ch_order" select="$ch_order"/>
|
||||||
|
<xsl:with-param name="dirname" select="$dirname"/>
|
||||||
|
</xsl:apply-templates>
|
||||||
|
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- sect1 -->
|
||||||
|
<xsl:template match="sect1">
|
||||||
|
|
||||||
|
<!-- Inherited chapter order -->
|
||||||
|
<xsl:param name="ch_order" select="foo"/>
|
||||||
|
|
||||||
|
<!-- Inherited dir name -->
|
||||||
|
<xsl:param name="dirname" select="foo"/>
|
||||||
|
|
||||||
|
<xsl:if test="count(descendant::screen/userinput) > 0 and
|
||||||
|
count(descendant::screen/userinput) >
|
||||||
|
count(descendant::screen[@role='nodump'])">
|
||||||
|
|
||||||
|
<!-- Base file name -->
|
||||||
|
<xsl:variable name="filename">
|
||||||
|
<xsl:call-template name="filename"/>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<!-- Sect1 order position -->
|
||||||
|
<xsl:variable name="sect1_position" select="position()"/>
|
||||||
|
<xsl:variable name="sect1_order">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="string-length($sect1_position) = 1">
|
||||||
|
<xsl:text>0</xsl:text>
|
||||||
|
<xsl:value-of select="$sect1_position"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$sect1_position"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<!-- Script build order -->
|
||||||
|
<xsl:variable name="order" select="concat($ch_order,'_',$sect1_order)"/>
|
||||||
|
|
||||||
|
<!-- Creating dirs and files -->
|
||||||
|
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
||||||
|
<xsl:call-template name="header"/>
|
||||||
|
<xsl:call-template name="pre_commands"/>
|
||||||
|
<xsl:apply-templates select=".//screen"/>
|
||||||
|
<xsl:call-template name="post_commands"/>
|
||||||
|
<xsl:call-template name="footer"/>
|
||||||
|
</exsl:document>
|
||||||
|
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<xsl:template match="screen">
|
<xsl:template match="screen">
|
||||||
<xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
<xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
||||||
<xsl:apply-templates select="userinput" mode="screen"/>
|
<xsl:apply-templates select="userinput" mode="screen"/>
|
||||||
|
|
Reference in a new issue