# Build everything necessary to compile the wiki.
-SUBDIRS = posts/yacc2dot
+SUBDIRS = posts/yacc2dot posts/XSLT/chapter posts/XSLT/code
TARGETS = all clean
all :
--- /dev/null
+[[!meta title="eXtensible Style Language Transforms"]]
+
+Often data is stored in
+<abbr title="eXtensible Markup Language">XML</abbr> files must be
+massaged into other formats (e.g. [[DocBook to roff|DocBook 5]]).
+There are well developed procedures for defining such transformations
+([XSLT][]) and a number of tools to apply them (e.g. [xsltproc][]).
+
+Besides the [W3 tutorial][w3], there is also a nice
+[introduction][intro] by Paul Grosso and Norman Walsh. I've copied a
+simple [[example|chapter]] from this intro and also included a
+[[slightly more complicated setup|code]] for generating online help
+for a list of macros.
+
+[XSLT]: http://www.w3.org/TR/xslt
+[w3]: http://www.w3schools.com/xsl/
+[intro]: http://nwalsh.com/docs/tutorials/xsl/xsl/slides.html
+[xsltproc]: http://www.xmlsoft.org/XSLT/
+
+[[!tag tags/tools]]
+[[!tag tags/web]]
--- /dev/null
+[[!inline pages="./chapter/*" archive=yes show=0 quick=yes sort="title"]]
--- /dev/null
+XSLTPROC = xsltproc
+
+all : chapter.html
+
+clean :
+ rm -f chapter.html
+
+chapter.html : style.xsl chapter.xml
+ $(XSLTPROC) $^ > $@
--- /dev/null
+From
+ http://nwalsh.com/docs/tutorials/xsl/xsl/slides.html
+
+style.xsl http://nwalsh.com/docs/tutorials/xsl/xsl/examples/modes.xsl
+chapter.xml http://nwalsh.com/docs/tutorials/xsl/xsl/examples/modes.xml
--- /dev/null
+<?xml version='1.0'?>
+<chapter id="foo"><title>Chapter Title</title>
+
+<para>This chapter is self-referential:
+<xref linkend="foo"/>.</para>
+</chapter>
--- /dev/null
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<xsl:output method="html"/>
+
+<xsl:template match="chapter/title">
+ <h2><xsl:apply-templates/></h2>
+</xsl:template>
+
+<xsl:template match="chapter/title" mode="crossref">
+ <i><xsl:apply-templates/></i>
+</xsl:template>
+
+<xsl:template match="xref">
+ <xsl:variable name="linkend" select="@linkend"/>
+ <xsl:apply-templates select="//*[@id=$linkend]/title"
+ mode="crossref"/>
+</xsl:template>
+
+<xsl:template match="para">
+ <p><xsl:apply-templates/></p>
+</xsl:template>
+
+<xsl:template match="emphasis">
+ <i><xsl:apply-templates/></i>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+[[!inline pages="./code/*" archive=yes show=0 quick=yes sort="title"]]
--- /dev/null
+XSLTPROC = xsltproc
+
+all : index.shtml
+
+clean :
+ rm -f index.shtml
+
+index.shtml : code.xsl index.xml
+ $(XSLTPROC) $^ > $@
--- /dev/null
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+ <xsl:output method="html"/>
+
+ <xsl:template match="page">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="html">
+ <xsl:value-of disable-output-escaping="yes" select="text()" />
+ </xsl:template>
+
+ <xsl:template match="page/title">
+ <h1><xsl:apply-templates/></h1>
+ </xsl:template>
+
+ <xsl:template match="description">
+ <p><xsl:apply-templates/></p>
+ </xsl:template>
+
+ <xsl:template match="file">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="file/name">
+ <h2>
+ <xsl:apply-templates/>
+ </h2>
+ </xsl:template>
+ <xsl:template match="file/description">
+ <xsl:apply-templates/>
+ <br/>
+ </xsl:template>
+
+ <xsl:template match="file/fn_list">
+ <table>
+ <xsl:apply-templates/>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="fn">
+ <tr>
+ <xsl:apply-templates/>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="fn/name">
+ <td><span style="font-family: monospace; font-size: 100%">
+ <xsl:apply-templates/>
+ </span></td>
+ </xsl:template>
+
+ <xsl:template match="fn/description">
+ <td><i>
+ <xsl:apply-templates/>
+ </i></td>
+ </xsl:template>
+
+ <xsl:template match="c">
+ <span style="font-family: monospace; font-size: 100%">
+ <xsl:apply-templates/>
+ </span>
+ </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- Translate with "code.xsl" -->
+<page>
+ <html>
+ <!--#include virtual="/~wking/header.html"-->
+ </html>
+ <title>Debugging macros</title>
+ <c>Something to c</c>
+ <description>
+ I've put together a set of macros to make debugging easier.
+ One day I'll learn how to use external debugging software, but until then...
+ </description>
+ <file>
+ <name>trace_mac.h</name>
+ <description>
+ These macros print their messages when the global <c>tk_debug > level</c>.
+ </description>
+ <fn_list>
+ <fn>
+ <name>PING(level)</name>
+ <description>Prints <c>"PING file.line\n"</c>.</description>
+ </fn>
+ <fn>
+ <name>MSG(level,...)</name>
+ <description>Prints the message <c>...</c> .</description>
+ </fn>
+ <fn>
+ <name>DUMP(level,a,fmt)</name>
+ <description>Dumps a variable <c>a</c> with a given format <c>fmt</c>.</description>
+ </fn>
+ </fn_list>
+ </file>
+ <html>
+ <!--#include virtual="/~wking/footer.html"-->
+ </html>
+</page>