On Sat, Mar 1, 2008 at 10:15 AM, George Makrydakis <[EMAIL PROTECTED]> wrote:
> This means that the entire design should focus on the fact that you are > dealing with a database by itself, not a book. Seems like a much simpler solution would be to transform the book into something else an automated tool can use. Like nALFS. See the attached for a start on an XSLT approach to this - it will convert the lastest SVN version of the LFS docbook sources into a profile - and if you start nALFS with the --display-comments, you'll see the text of the book as comments separate from the commands - isn't this what Gerard was picturing at the start of all these posts? (WARNING - don't try to run the profile if you do load it in nALFS - I promise this POC it won't build a system successfully!) . On a further note, I've also mostly implemented this in C++, with my own lightweight XML processor - and in the end I'm going to end up with C++ templates that look just like XSLT, so might as well try the XSLT approach before carrying the C++ approach any further. And a thought for all to consider (and something I'm probably going to work on regardless the response here): During the course of coding this conversion tool, I've come to ask myself many times - wouldn't this be much easier if nALFS could just act directly on the docbook XML instead of using it's own DTD? If that were the case, then the book would also be your automation scripts!
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="book"> <alfs version="3.1" xmlns:xi="http://www.w3.org/2001/XInclude"> <xsl:text>
</xsl:text> <xsl:apply-templates select="part"/> </alfs> </xsl:template> <xsl:template match="part"> <stage name="{title}"> <xsl:text>
</xsl:text> <xsl:apply-templates select="chapter"/> </stage> <xsl:text>
</xsl:text> </xsl:template> <xsl:template match="chapter"> <stage name="[EMAIL PROTECTED] - {title}"> <xsl:text>
</xsl:text> <xsl:apply-templates select="sect1"/> </stage> <xsl:text>
</xsl:text> </xsl:template> <xsl:template match="sect1"> <stage name="{title}"> <xsl:text>
</xsl:text> <xsl:call-template name="addComments"/> <xsl:apply-templates select="sect1info" mode="commands"/> <xsl:apply-templates select="screen" mode="commands"/> <xsl:apply-templates select="[EMAIL PROTECTED]'installation']" mode="commands"/> </stage> <xsl:text>
</xsl:text> </xsl:template> <xsl:template name="addComments"> <xsl:comment> <xsl:apply-templates select="node()" mode="comments"/> </xsl:comment> </xsl:template> <xsl:template match="text()" mode="comments"> <xsl:value-of select="translate(., '--', ' -')"/> </xsl:template> <xsl:template match="ulink" mode="comments"> <xsl:value-of select="@url"/> </xsl:template> <xsl:template match="sect1info" mode="commands"> <package name="{productname}" version="{productnumber}" /> </xsl:template> <xsl:template match="[EMAIL PROTECTED]'installation']" mode="commands"> <stage name="[EMAIL PROTECTED]"> <xsl:text>
</xsl:text> <xsl:apply-templates select="screen" mode="commands"/> </stage> <xsl:text>
</xsl:text> </xsl:template> <xsl:template match="screen" mode="commands"> <xsl:if test="not(@role='nodump')"> <xsl:apply-templates select="userinput" mode="commands"/> </xsl:if> </xsl:template> <xsl:template match="userinput" mode="commands"> <execute command="{.}"/> <xsl:text>
</xsl:text> </xsl:template> </xsl:stylesheet>
-- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page