Commits

Anonymous committed f9a67ad

Converted the articles index to be based on a specialized XML grammar.

  • Participants
  • Parent commits 3fb3172

Comments (0)

Files changed (5)

 t2/SFresume_detailed.html.wml : t2/SFresume_base.wml
 	touch $@
 
+t2/philosophy/Index/index.html.wml : lib/article-index/article-index.dtd lib/article-index/article-index.xml lib/article-index/article-index.xsl
+	touch $@
+

lib/article-index/article-index.dtd

+<!ELEMENT index (meta,contents)>
+<!ELEMENT meta EMPTY>
+<!ELEMENT contents (section)+>
+<!ELEMENT section (section|entry)*>
+<!ELEMENT entry (p)+>
+<!ELEMENT p (#PCDATA|a)*>
+<!ELEMENT a (#PCDATA)>
+<!ATTLIST section id ID #REQUIRED title CDATA #REQUIRED>
+<!ATTLIST entry id ID #REQUIRED title CDATA #REQUIRED url CDATA #REQUIRED>
+<!ATTLIST a href CDATA #REQUIRED>

lib/article-index/article-index.xml

+<?xml version='1.0' encoding='utf-8'?>
+<?xml-stylesheet type="text/xml" href="article-index.xsl"?>
+<!DOCTYPE index SYSTEM "article-index.dtd">
+<index>
+<meta>
+</meta>
+<contents>
+<section id="computing" title="Essays and Articles about Computing">
+<entry id="joy_of_perl" title="The Joy of Perl" url="http://www.nntp.perl.org/group/perl.advocacy/2108">
+<p>
+An essay that explains why I like Perl so much. Also see 
+<a href="http://perl.org.il/pipermail/perl/2004-February/004184.html">a 
+discussion of it in perl.org.il</a>
+</p>
+</entry>
+<entry id="cross_unix_portability" title="Cross UNIX Portability - Facts and Myths" url="http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&amp;ixPost=99574">
+<p>
+The title says it all pretty much.
+</p>
+</entry>
+<entry id="lm_solve" title="Solving Puzzles with LM-Solve" url="http://www.perl.com/pub/a/2003/11/17/lmsolve.html">
+<p>
+An article about the 
+<a href="http://vipe.technion.ac.il/~shlomif/lm-solve/">LM-Solve</a> puzzle
+solving framework, and how to utilize it for a new puzzle.
+</p>
+</entry>
+<entry id="version_control_systems_overview" title="The New Breed of Version Control Systems" url="http://www.oreillynet.com/pub/a/onlamp/2004/01/29/scm_overview.html">
+<p>
+An article giving an overview of several prominent open-source version control
+systems that provide an alternative to CVS.
+</p>
+</entry>
+<entry id="wikis_overview" title="Which Open Source Wiki Works For You?" url="http://www.oreillynet.com/pub/a/onlamp/2004/11/04/which_wiki.html">
+<p>
+An article giving a roundup of open-source Wiki implementations which enable
+the user to create a world-editable web-site.
+</p>
+</entry>
+<entry id="devel_linetrace" title="Debug Your Programs with Devel::LineTrace" url="http://www.perl.com/pub/a/2005/03/31/lightning2.html?page=2">
+<p>
+A lightning article about how to insert debugging callbacks into a Perl 
+program without modifying its code.
+</p>
+</entry>
+</section>      
+</contents>
+</index>

lib/article-index/article-index.xsl

+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
+ doctype-public="-//W3C//DTD XHTML 1.1//EN"
+ doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
+ />
+
+<xsl:key name="impl" match="/comparison/meta/implementations/impl" use="@id"/>
+
+<xsl:template match="/index">
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <body>
+<xsl:apply-templates select="contents" mode="toc"/>
+</body>
+<!--http://rafb.net/paste/results/lTurEi25.html-->
+</html>
+</xsl:template>
+
+<xsl:template match="contents">
+</xsl:template>
+<xsl:template match="contents" mode="toc">
+    <ol>
+        <xsl:apply-templates select="section" mode="toc"/>
+    </ol>
+    <xsl:apply-templates select="section"/>
+</xsl:template>
+
+<xsl:template match="section" mode="toc">
+    <li>
+        <a href="#{@id}"><xsl:value-of select="@title"/></a><br />
+        <ol>
+            <xsl:apply-templates select="section|entry" mode="toc"/>
+        </ol>
+    </li>
+</xsl:template>
+
+<xsl:template match="entry" mode="toc">
+    <li>
+        <a href="#{@id}"><xsl:value-of select="@title"/></a>
+    </li>
+</xsl:template>
+
+<xsl:template match="section">
+    <xsl:element name="h{count(ancestor-or-self::section)}">
+        <xsl:attribute name="id">
+            <xsl:value-of select="@id"/>
+        </xsl:attribute>
+        <xsl:value-of select="@title"/>
+    </xsl:element>
+    <xsl:apply-templates select="section|entry"/>
+</xsl:template>
+
+<xsl:template match="entry">
+    <xsl:element name="h{count(ancestor-or-self::section)+count(ancestor-or-self::entry)}">
+        <xsl:attribute name="id">
+            <xsl:value-of select="@id"/>
+        </xsl:attribute>
+        <xsl:element name="a">
+            <xsl:attribute name="href">
+                <xsl:value-of select="@url"/>
+            </xsl:attribute>
+            <xsl:value-of select="@title"/>
+        </xsl:element>
+    </xsl:element>
+    <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="p">
+    <p>
+        <xsl:apply-templates/>
+    </p>
+</xsl:template>
+<xsl:template match="a">
+    <a href="{@href}"><xsl:apply-templates/></a>
+</xsl:template>
+</xsl:stylesheet>

t2/philosophy/Index/index.html.wml

 #include '../template.wml'
 
-#use wml::std::toc style=ol
+<subject "Index to Shlomi Fish' Essays" />
 
-<subject "Index to Shlomi Fish Essays" />
+<:{
+use XML::LibXSLT;
+use XML::LibXML;
 
-<toc />
+my $parser = XML::LibXML->new();
+my $xslt = XML::LibXSLT->new();
 
-<h2>Essays and Articles about Computing</h2>
+my $base_path="../lib/article-index/";
+my $source = $parser->parse_file("$base_path/article-index.xml");
+my $style_doc = $parser->parse_file("$base_path/article-index.xsl");
 
-<h3>The Joy of Perl</a></h3>
+my $stylesheet = $xslt->parse_stylesheet($style_doc);
 
-<p><a href="http://www.nntp.perl.org/group/perl.advocacy/2108">Link</a></p>
+my $results = $stylesheet->transform($source);
 
-<p>
-An essay that explains why I like Perl so much. Also see 
-<a href="http://perl.org.il/pipermail/perl/2004-February/004184.html">a 
-discussion of it in perl.org.il</a>
-</p>
+my $out_string = $stylesheet->output_string($results);
 
-<h3>Cross UNIX Portability - Facts and Myths</h3>
+$out_string =~ s{^.*<body>}{}s;
+$out_string =~ s{</body>.*$}{}s;
 
-<p><a href="http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&amp;ixPost=99574">Link</a></p>
+print $out_string;
+}:>
 
-<p>
-The title says it all pretty much.
-</p>
-
-<h3>Solving Puzzles with LM-Solve </h3>
-
-<p><a href="http://www.perl.com/pub/a/2003/11/17/lmsolve.html">Link</a></p>
-
-<p>
-An article about the 
-<a href="http://vipe.technion.ac.il/~shlomif/lm-solve/">LM-Solve</a> puzzle
-solving framework, and how to utilize it for a new puzzle.
-</p>
-
-<h3>The New Breed of Version Control Systems</h3>
-
-<p><a href="http://www.oreillynet.com/pub/a/onlamp/2004/01/29/scm_overview.html">Link</a></p>
-
-<p>
-An article giving an overview of several prominent open-source version control
-systems that provide an alternative to CVS.
-</p>
-
-<h3>Which Open Source Wiki Works For You?</h3>
-
-<p><a href="http://www.oreillynet.com/pub/a/onlamp/2004/11/04/which_wiki.html">Link</a></p>
-
-<p>
-An article giving a roundup of open-source Wiki implementations which enable
-the user to create a world-editable web-site.
-</p>
-
-<h3>Debug Your Programs with Devel::LineTrace</h3>
-
-<p><a href="http://www.perl.com/pub/a/2005/03/31/lightning2.html?page=2">Link</a></p>
-
-<p>
-A lightning article about how to insert debugging callbacks into a Perl program without modifying its code.
-</p>