New output format for PHPWiki
authorarjen <arjen>
Thu, 18 Oct 2007 04:25:44 +0000 (04:25 +0000)
committerarjen <arjen>
Thu, 18 Oct 2007 04:25:44 +0000 (04:25 +0000)
wiki.xsl [new file with mode: 0644]
xml2wiki [new file with mode: 0755]

diff --git a/wiki.xsl b/wiki.xsl
new file mode 100644 (file)
index 0000000..3cabb72
--- /dev/null
+++ b/wiki.xsl
@@ -0,0 +1,156 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns="http://www.w3.org/TR/xhtml1/strict">
+
+<xsl:strip-space elements="doc chapter section para row"/>
+<xsl:output method="text" indent="no" encoding="iso-8859-1"/>
+
+<xsl:template match="doc">
+<xsl:apply-templates/>
+
+------------------------------------------------------------------
+<xsl:apply-templates select="//footnote" mode="footnotes"/>
+</xsl:template>
+
+<xsl:template match="article">
+   <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="book">
+   <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="report">
+   <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="titlepage">
+*********************************************************************************
+   <xsl:apply-templates/>
+*********************************************************************************
+</xsl:template>
+
+<xsl:template match="title">
+<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="date">
+<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="author">
+</xsl:template>
+
+<xsl:template match="docinfo">
+   Document Information
+   <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="infoitem">
+   <xsl:value-of select="@label"/>: <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="abstract">
+
+Abstract:
+
+<xsl:apply-templates/>
+</xsl:template>
+
+
+<xsl:template match="chapter/heading">
+!!!<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="section/heading">
+!!<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="subsection/heading">
+!<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="subsubsection/heading">
+   <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="paragraph/heading">
+   <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="subparagraph/heading">
+   <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="para|quote">
+
+     <xsl:apply-templates/>
+
+</xsl:template>
+
+<xsl:template match="verbatim">
+&lt;pre&gt;
+     <xsl:apply-templates/>
+&lt;/pre&gt;
+</xsl:template>
+
+<xsl:template match="itemize/item">
+* <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="enumerate/item">
+# <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="footnote">(<xsl:number/>)</xsl:template>
+
+<xsl:template match="footnote" mode="footnotes">
+ (<xsl:number/>) <xsl:apply-templates/>
+
+</xsl:template>
+
+<xsl:template match="sub|sup"><xsl:apply-templates/></xsl:template>
+<xsl:template match="emph">_<xsl:apply-templates/>_</xsl:template>
+
+<xsl:template match="strong">*<xsl:apply-templates/>*</xsl:template>
+
+<xsl:template match="code">=<xsl:apply-templates/>=</xsl:template>
+
+<xsl:template match="remark">_<xsl:apply-templates/>_</xsl:template>
+
+<xsl:template match="newline">
+</xsl:template>
+
+<xsl:template match="newpage">
+</xsl:template>
+
+<xsl:template match="table">
+<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="row">
+<xsl:apply-templates/>
+
+</xsl:template>
+
+<xsl:template match="col">
+<xsl:variable name='n' select='position()'/>
+<xsl:for-each select='../col[position() &lt; $n]'><xsl:text>   </xsl:text></xsl:for-each>
+<xsl:apply-templates/><xsl:if test='position()!=last()'> |</xsl:if><xsl:text>
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="picture">
+</xsl:template>
+
+<xsl:template match="reference">
+<xsl:apply-templates/>[<xsl:value-of select="@href"/>]
+</xsl:template>
+
+<xsl:template match="include">
+<xsl:apply-templates select="document(@href)"/>
+</xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/xml2wiki b/xml2wiki
new file mode 100755 (executable)
index 0000000..b165d6f
--- /dev/null
+++ b/xml2wiki
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+XSLDIR=/usr/local/xslt
+
+stylesheet=$XSLDIR/wiki.xsl
+inputs=
+
+while [ $# -gt 0 ]
+do
+   case $1 in
+   -s)
+      stylesheet=$2
+      shift
+   ;;
+
+   -*)
+      echo Usage: $0 [-s stylesheet] file...
+      exit 1
+   ;;
+
+   *)
+      inputs=`echo $inputs $1`
+   ;;
+
+   esac
+   shift
+done
+TMPFILE=`mktemp /tmp/xmldoc.XXXXXX`
+xp $XSLDIR/preprocess.xsl $inputs >$TMPFILE
+xp $stylesheet $TMPFILE