You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by dr...@apache.org on 2007/05/24 15:43:33 UTC
svn commit: r541301 - in /labs/boardcast: Proposal data/ scripts/
scripts/generateList.pl templates/ templates/atom2report.xsl
Author: dreid
Date: Thu May 24 06:43:32 2007
New Revision: 541301
URL: http://svn.apache.org/viewvc?view=rev&rev=541301
Log:
First pass at some simple xslt foo.
To play...
1. create some data files in 'data'
2. ./scripts/generateList.pl > files.list
3. xsltproc templates/atom2report.xsl files.list
I know it's perl, but it's a language I know and so was
quick. This needs to allow for using a file to provide
external links in the same way that external.xml does for
people.a.o, but that can easily be added.
Added:
labs/boardcast/data/
labs/boardcast/scripts/
labs/boardcast/scripts/generateList.pl (with props)
labs/boardcast/templates/
labs/boardcast/templates/atom2report.xsl
Modified:
labs/boardcast/Proposal
Modified: labs/boardcast/Proposal
URL: http://svn.apache.org/viewvc/labs/boardcast/Proposal?view=diff&rev=541301&r1=541300&r2=541301
==============================================================================
--- labs/boardcast/Proposal (original)
+++ labs/boardcast/Proposal Thu May 24 06:43:32 2007
@@ -45,7 +45,7 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
- <id>tag:apace.org,2007-05-22:Test_Post</id>
+ <id>tag:apace.org,2007-05-22T21-00:Test_Post</id>
<author>
<name>david reid</name>
</author>
@@ -64,8 +64,11 @@
david: Using tag: appears to be the current "best practice", so how
about
- tag:<project domain>,<date>:<title>
+ tag:<project domain>,<date/time>:<title>
Title would have spaces replaced by underscores.
+ david: we should use the first portion of the tag as the filename
+ in order to avoid collisions. This is why I think including the
+ time is a requirement.
o What categories should we have?
@@ -100,4 +103,6 @@
development and ease of changing direction during development.
Python seems to have the most traction and would be a new
challenge for me :-)
+
+o What format should the content take? Should we allow HTML or XHTML?
Added: labs/boardcast/scripts/generateList.pl
URL: http://svn.apache.org/viewvc/labs/boardcast/scripts/generateList.pl?view=auto&rev=541301
==============================================================================
--- labs/boardcast/scripts/generateList.pl (added)
+++ labs/boardcast/scripts/generateList.pl Thu May 24 06:43:32 2007
@@ -0,0 +1,21 @@
+#! /usr/bin/env perl
+
+use Cwd qw( realpath );
+use File::Spec::Functions;
+
+my $dirToWalk = realpath($ARGV[0] || '.');
+
+##print "Processing directory '$dirToWalk'\n";
+
+print <<EOT;
+<?xml version="1.0"?>
+<fileList>
+EOT
+opendir(my $dH, $dirToWalk) || die("Failed to open directory\n$!");
+while (my $f = readdir($dH)) {
+ next if $f =~ /^\.|~$/;
+ $f = catfile($dirToWalk, $f);
+ print " <file>$f</file>\n";
+}
+closedir($dH);
+print "</fileList>\n";
Propchange: labs/boardcast/scripts/generateList.pl
------------------------------------------------------------------------------
svn:executable = *
Added: labs/boardcast/templates/atom2report.xsl
URL: http://svn.apache.org/viewvc/labs/boardcast/templates/atom2report.xsl?view=auto&rev=541301
==============================================================================
--- labs/boardcast/templates/atom2report.xsl (added)
+++ labs/boardcast/templates/atom2report.xsl Thu May 24 06:43:32 2007
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version = "1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:Atom="http://www.w3.org/2005/Atom"
+ xmlns:exsl="http://exslt.org/common"
+ xmlns:date="http://exslt.org/dates-and-times"
+ extension-element-prefixes="exsl date"
+ exclude-result-prefixes="xsl">
+
+ <xsl:output method="text" indent="yes" encoding="UTF-8"
+ omit-xml-declaration="yes" />
+
+ <xsl:variable name="newLine">
+ <xsl:text>
+</xsl:text>
+ </xsl:variable>
+
+ <xsl:template match="/">
+ <xsl:apply-templates select="fileList" />
+ </xsl:template>
+
+ <!-- Process each 'file' entry within the fileList element.
+ Each 'file' elemtn contains a filename, so we need to process
+ these and read them before use (using the document() function).
+ To make sure we have the ability to process more than once we
+ create a variable with a slightly modified copy of each Atom:entry
+ element.
+ To make grouping easier we then create a sorted copy of the
+ variable and process that.
+ -->
+ <xsl:template match="fileList">
+
+ <xsl:variable name="entries">
+ <xsl:for-each select="file">
+ <anEntry>
+ <xsl:apply-templates select="document(.)/Atom:entry" mode="copyAll" />
+ </anEntry>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:variable name="sortedEntries">
+ <xsl:for-each select="exsl:node-set($entries)/anEntry">
+ <xsl:sort select="project" />
+ <xsl:sort select="Atom:entry/Atom:category/@term" />
+ <xsl:sort select="Atom:entry/Atom:updated" />
+ <xsl:apply-templates select="." mode="copy" />
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:for-each select="exsl:node-set($sortedEntries)/anEntry">
+ <xsl:variable name="this" select="project" />
+ <xsl:variable name="thisCat" select="Atom:entry/Atom:category/@label" />
+
+ <!-- New project? Insert a project header -->
+ <xsl:if test="not(preceding-sibling::anEntry[project = $this])">
+ <xsl:apply-templates select="." mode="insertHeader" />
+ </xsl:if>
+
+ <!-- if we have a category change or have just had a change of
+ project, insert a category header.
+ -->
+ <xsl:if test="not(preceding-sibling::anEntry[1]/Atom:entry/Atom:category/@label = $thisCat) or not(preceding-sibling::anEntry[1]/project = $this)">
+ <xsl:apply-templates select="." mode="insertCategoryHeader" />
+ </xsl:if>
+
+ <!-- Display the item -->
+ <xsl:value-of select="$newLine" />
+ <xsl:value-of select="Atom:entry/Atom:title" />
+ <xsl:value-of select="$newLine" />
+ <xsl:value-of select="Atom:entry/Atom:content" />
+ <xsl:value-of select="$newLine" />
+
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template match="anEntry" mode="insertHeader">
+ <xsl:value-of select="$newLine"/>
+ <xsl:text>Project </xsl:text>
+ <xsl:value-of select="project" />
+ <xsl:value-of select="$newLine"/>
+ </xsl:template>
+
+ <xsl:template match="anEntry" mode="insertCategoryHeader">
+ <xsl:value-of select="$newLine"/>
+ <xsl:text>Category </xsl:text>
+ <xsl:value-of select="Atom:entry/Atom:category/@label" />
+ <xsl:value-of select="$newLine"/>
+ </xsl:template>
+
+ <!-- Utility templates -->
+ <xsl:template match="Atom:entry" mode="copyAll">
+ <project><xsl:value-of select="substring-before(substring-after(Atom:id, 'tag:'), ',')"/></project>
+ <xsl:apply-templates select="." mode="copy" />
+ </xsl:template>
+
+ <xsl:template match="@*|node()" mode="copy">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()" mode="copy"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org