Added XSLT post.
authorW. Trevor King <wking@drexel.edu>
Tue, 5 Oct 2010 19:18:38 +0000 (15:18 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 5 Oct 2010 19:18:38 +0000 (15:18 -0400)
Makefile
posts/XSLT.mdwn [new file with mode: 0644]
posts/XSLT/chapter.mdwn [new file with mode: 0644]
posts/XSLT/chapter/Makefile [new file with mode: 0644]
posts/XSLT/chapter/README [new file with mode: 0644]
posts/XSLT/chapter/chapter.xml [new file with mode: 0644]
posts/XSLT/chapter/style.xsl [new file with mode: 0644]
posts/XSLT/code.mdwn [new file with mode: 0644]
posts/XSLT/code/Makefile [new file with mode: 0644]
posts/XSLT/code/code.xsl [new file with mode: 0644]
posts/XSLT/code/index.xml [new file with mode: 0644]

index aca34844aecea685b3c86dd7d2bad3be795c0c31..d79c957a917e183311c283c318686fa9869ebc93 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Build everything necessary to compile the wiki.
 
-SUBDIRS = posts/yacc2dot
+SUBDIRS = posts/yacc2dot posts/XSLT/chapter posts/XSLT/code
 TARGETS = all clean
 
 all :
diff --git a/posts/XSLT.mdwn b/posts/XSLT.mdwn
new file mode 100644 (file)
index 0000000..512c744
--- /dev/null
@@ -0,0 +1,21 @@
+[[!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]]
diff --git a/posts/XSLT/chapter.mdwn b/posts/XSLT/chapter.mdwn
new file mode 100644 (file)
index 0000000..a8ef009
--- /dev/null
@@ -0,0 +1 @@
+[[!inline pages="./chapter/*" archive=yes show=0 quick=yes sort="title"]]
diff --git a/posts/XSLT/chapter/Makefile b/posts/XSLT/chapter/Makefile
new file mode 100644 (file)
index 0000000..72094c2
--- /dev/null
@@ -0,0 +1,9 @@
+XSLTPROC = xsltproc
+
+all : chapter.html
+
+clean :
+       rm -f chapter.html
+
+chapter.html : style.xsl chapter.xml
+       $(XSLTPROC) $^ > $@
diff --git a/posts/XSLT/chapter/README b/posts/XSLT/chapter/README
new file mode 100644 (file)
index 0000000..c5c6bce
--- /dev/null
@@ -0,0 +1,5 @@
+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
diff --git a/posts/XSLT/chapter/chapter.xml b/posts/XSLT/chapter/chapter.xml
new file mode 100644 (file)
index 0000000..80f080a
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version='1.0'?>
+<chapter id="foo"><title>Chapter Title</title>
+
+<para>This chapter is self-referential:
+<xref linkend="foo"/>.</para>
+</chapter>
diff --git a/posts/XSLT/chapter/style.xsl b/posts/XSLT/chapter/style.xsl
new file mode 100644 (file)
index 0000000..51e2c67
--- /dev/null
@@ -0,0 +1,29 @@
+<?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>
diff --git a/posts/XSLT/code.mdwn b/posts/XSLT/code.mdwn
new file mode 100644 (file)
index 0000000..7eaf4d8
--- /dev/null
@@ -0,0 +1 @@
+[[!inline pages="./code/*" archive=yes show=0 quick=yes sort="title"]]
diff --git a/posts/XSLT/code/Makefile b/posts/XSLT/code/Makefile
new file mode 100644 (file)
index 0000000..bbc89ae
--- /dev/null
@@ -0,0 +1,9 @@
+XSLTPROC = xsltproc
+
+all : index.shtml
+
+clean :
+       rm -f index.shtml
+
+index.shtml : code.xsl index.xml
+       $(XSLTPROC) $^ > $@
diff --git a/posts/XSLT/code/code.xsl b/posts/XSLT/code/code.xsl
new file mode 100644 (file)
index 0000000..6a837b4
--- /dev/null
@@ -0,0 +1,67 @@
+<?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>
diff --git a/posts/XSLT/code/index.xml b/posts/XSLT/code/index.xml
new file mode 100644 (file)
index 0000000..6bc8b4f
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- Translate with "code.xsl" -->
+<page>
+ <html>
+  &lt;!--#include virtual="/~wking/header.html"--&gt;
+ </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>
+  &lt;!--#include virtual="/~wking/footer.html"--&gt;
+ </html>
+</page>