Makefile.am added simple XSL transformation to generate fortunes for

2004-08-26  Sven Neumann  <sven@gimp.org>

	* Makefile.am
	* fortunes.xsl: added simple XSL transformation to generate
	fortunes for wiki.gimp.org from gimp-tips.xml.in.
This commit is contained in:
Sven Neumann 2004-08-26 18:15:10 +00:00 committed by Sven Neumann
parent f1d0db6d99
commit 10dd89960c
4 changed files with 73 additions and 0 deletions

View File

@ -4,6 +4,7 @@ Makefile
Makefile.in
POTFILES
*.pot
fortunes
gimp-tips.xml
gimp-tips.xml.in.h
messages

View File

@ -1,3 +1,9 @@
2004-08-26 Sven Neumann <sven@gimp.org>
* Makefile.am
* fortunes.xsl: added simple XSL transformation to generate
fortunes for wiki.gimp.org from gimp-tips.xml.in.
2004-08-24 Sven Neumann <sven@gimp.org>
* Makefile.am (tips_POFILES): added pa.po (Punjabi).

View File

@ -47,6 +47,7 @@ EXTRA_DIST = \
$(tipsdata_DATA) \
$(tips_in_files) \
gimp-tips.dtd \
fortunes.xsl \
update.sh
MAINTAINERCLEANFILES = $(GETTEXT_PACKAGE)-tips.pot $(tipsdata_DATA)
@ -86,4 +87,12 @@ if HAVE_XMLLINT
( echo "* gimp-tips.xml INVALID *"; exit 1; )
endif
fortunes: gimp-tips.xml.in fortunes.xsl
if HAVE_XSLTPROC
$(XSLTPROC) fortunes.xsl $< > $(@) || rm -f $(@)
else
@echo "xsltproc is needed to build fortunes"; exit 1;
endif
dist-hook: validate

57
tips/fortunes.xsl Normal file
View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This simple XSL transformation creates a text version from
gimp-tips.xml.in which can then be used to seed
http://wiki.gimp.org/gimp/FortuneCookies in the GIMP Wiki. -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:apply-templates select="//_thetip" />
</xsl:template>
<xsl:template match="_thetip">
* <xsl:apply-templates />
</xsl:template>
<xsl:template match="tt">
<xsl:text>{{{</xsl:text>
<xsl:apply-templates />
<xsl:text>}}}</xsl:text>
</xsl:template>
<!-- this sucks
but I don't seem to get xsl:strip-space to work with xsltproc -->
<xsl:template match="text()">
<xsl:call-template name="search-and-replace">
<xsl:with-param name="input" select="." />
<xsl:with-param name="search-string" select="' '" />
<xsl:with-param name="replace-string" select="' '" />
</xsl:call-template>
</xsl:template>
<xsl:template name="search-and-replace">
<xsl:param name="input" />
<xsl:param name="search-string" />
<xsl:param name="replace-string" />
<xsl:choose>
<xsl:when test="$search-string and contains($input, $search-string)">
<xsl:value-of select="substring-before($input, $search-string)" />
<xsl:value-of select="$replace-string" />
<xsl:call-template name="search-and-replace">
<xsl:with-param name="input"
select="substring-after($input, $search-string)" />
<xsl:with-param name="search-string" select="$search-string" />
<xsl:with-param name="replace-string" select="$replace-string" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$input" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>