Export do Wiki (dokuwiki)

Václav Ovsík vaclav.ovsik na i.cz
Pátek Únor 23 16:26:22 CET 2007


A jeste kolega me poslal tohle

----- Forwarded message from Pavol Luptak <pavol.luptak na i.cz> -----

From: Pavol Luptak <pavol.luptak na i.cz>
Subject: Re: Export do Wiki (dokuwiki)
To: vaclav.ovsik na i.cz
Date: Fri, 23 Feb 2007 15:09:01 +0100

On Fri, Feb 23, 2007 at 12:00:32PM +0100, Václav Ovsík wrote:
> A zkousel jste Googlovat?
> Me vypadlo treba http://wiki.blender.org/index.php/Meta/DocBook_to_Wiki.
> Je to sice k blenderu, ale treba by z toho slo neco pouzit.

Preco to robit v perle, ci pythone, ked XSLT je na transformaciu ako
stvoreny. Ja som pred par rokmi pre interne potreby napisal
jednoduchy styl, ktory transformuje XML DocBook do Wikiwebu
(prikladam v prilohe).

Pavol
----- End Forward -----

-- 
Zito
------------- další část ---------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:text="dont care"
                version="1.0">
<xsl:output method="text" indent="yes" encoding="iso-8859-2"/>

<xsl:template match="/">
# Generated from XML DocBook, any comments send to w na i.cz
<xsl:apply-templates select="articleinfo"/>
<xsl:apply-templates select="article"/>
</xsl:template>

<xsl:template match="articleinfo">
</xsl:template>

<xsl:template match="para">
<xsl:apply-templates select="text()|node()"/><xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="emphasis">
<xsl:choose>
<xsl:when test="@role = 'bold'">*<xsl:value-of select="."/>*</xsl:when>
<xsl:otherwise>'<xsl:value-of select="."/>'</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="ulink">
<xsl:value-of select="."/>(<xsl:value-of select="@url"/>)
</xsl:template>

<xsl:template match="itemizedlist">
<xsl:apply-templates select="listitem" mode="itemized"/>
</xsl:template>

<xsl:template match="orderedlist">
<xsl:apply-templates select="listitem" mode="ordered"/>
</xsl:template>

<xsl:template match="listitem" mode="itemized">
* <xsl:apply-templates select="para"/>
</xsl:template>

<xsl:template match="listitem" mode="ordered">
0 <xsl:apply-templates select="para"/>
</xsl:template>

<xsl:template match="article">
<xsl:apply-templates select="section" mode="layer1"/>
<xsl:apply-templates select="itemizedlist|orderedlist|para"/>
</xsl:template>

<xsl:template match="section" mode="layer1">
= <xsl:value-of select="title"/> =
<xsl:apply-templates select="section" mode="layer2"/>
<xsl:apply-templates select="itemizedlist|orderedlist|para"/>
</xsl:template>

<xsl:template match="section" mode="layer2">
== <xsl:value-of select="title"/> ==
<xsl:apply-templates select="section" mode="layer3"/> 
<xsl:apply-templates select="itemizedlist|orderedlist|para"/>
</xsl:template>

<xsl:template match="section" mode="layer3">
=== <xsl:value-of select="title"/> ===
<xsl:apply-templates select="section" mode="layer4"/> 
<xsl:apply-templates select="itemizedlist|orderedlist|para"/>
</xsl:template>

<xsl:template match="section" mode="layer4">
==== <xsl:value-of select="title"/> ====
<xsl:apply-templates select="section" mode="layer5"/> 
<xsl:apply-templates select="itemizedlist|orderedlist|para"/>
</xsl:template>

<xsl:template match="section" mode="layer5">
===== <xsl:value-of select="title"/> =====
<xsl:apply-templates select="section" mode="layer6"/> 
<xsl:apply-templates select="itemizedlist|orderedlist|para"/>
</xsl:template>

<xsl:template match="section" mode="layer6">
====== <xsl:value-of select="title"/> ======
<xsl:apply-templates select="section" mode="layer6"/> 
<xsl:apply-templates select="itemizedlist|orderedlist|para"/>
</xsl:template>

</xsl:stylesheet>


Další informace o konferenci Docbook