Indentation clean-up.

Removed vervosity in xsltproc run.
Added dump-commands.xsl.
This commit is contained in:
Manuel Canales Esparcia 2005-09-25 16:56:00 +00:00
parent fbb6b78eca
commit 557fe91345
2 changed files with 225 additions and 139 deletions

84
dump-commands.xsl Normal file
View file

@ -0,0 +1,84 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- XSLT stylesheet to extract commands from [B,H]LFS books. -->
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
<xsl:template match="sect1">
<!-- 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="quote-dir" select="substring($pi-dir-value,1,1)"/>
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
<!-- The file names -->
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
<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')"/>
<!-- The build order -->
<xsl:variable name="position" select="position()"/>
<xsl:variable name="order">
<xsl:choose>
<xsl:when test="string-length($position) = 1">
<xsl:text>00</xsl:text>
<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:apply-templates select=".//screen"/>
</exsl:document>
</xsl:template>
<xsl:template match="screen">
<xsl:if test="child::* = userinput">
<xsl:choose>
<xsl:when test="@role = 'nodump'"/>
<xsl:when test="@role = 'root'">
<xsl:text>&#xA;</xsl:text>
<xsl:text># Run this as root</xsl:text>
<xsl:apply-templates select="userinput"/>
<xsl:text># End root commands</xsl:text>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="userinput"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="userinput">
<xsl:text>&#xA;</xsl:text>
<xsl:if test=".//replaceable">
<xsl:text># This block must be edited to suit your needs.</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
<xsl:if test=".//replaceable">
<xsl:text># End of editable block.</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:template>
<xsl:template match="replaceable">
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
<xsl:text>EDITME**</xsl:text>
</xsl:template>
</xsl:stylesheet>

20
jhalfs
View file

@ -1,11 +1,13 @@
#!/bin/sh
version="
jhalfs 0.1
jhalfs 0.2
Written by Jeremy Huntwork.
Maintained by Manuel Canales Esparcia.
This program is published under the \
Gnu General Public License, Version 2."
Gnu General Public License, Version 2.
"
usage="\
Usage: $0 [OPTION]
@ -106,6 +108,7 @@ if [ -z $BUILDDIR ] ; then BUILDDIR=/mnt/lfs ; fi
JHALFSDIR=$BUILDDIR/jhalfs
LOG=build.log
MKFILE=$JHALFSDIR/Makefile
XSL=dump-commands.xsl
get_book() {
# Check for Subversion instead of just letting the script hit 'svn' and fail.
@ -151,10 +154,9 @@ extract_commands() {
if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
echo -n "Extracting commands... "
# Use Manuel's stylesheet to dump the commands in text form from the LFS book.
xsltproc -v --nonet --xinclude -o ./commands/ \
lfs-$LFSVRS/stylesheets/dump-commands.xsl lfs-$LFSVRS/index.xml \
>>$JHALFSDIR/$LOG 2>&1
# Dump the commands in text form from the LFS book.
xsltproc --nonet --xinclude -o ./commands/ $XSL \
lfs-$LFSVRS/index.xml >>$JHALFSDIR/$LOG 2>&1
# Move the text files out from the chapter directories, and dump them
# all into the 'commands' directory.
@ -262,8 +264,8 @@ build_Makefile() {
>$MKFILE.tmp
for i in * ; do
# First append each name of the command files to a list (this will become the names
# of the targets in the Makefile
# First append each name of the command files to a list (this will become
# the names of the targets in the Makefile
list="$list $i"
# Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
@ -328,6 +330,6 @@ if [ ! -d $JHALFSDIR ] ; then
fi
>$JHALFSDIR/$LOG
cp $0 $JHALFSDIR/
cp $0 $XSL $JHALFSDIR/
get_book
build_Makefile