prepare_wiki_to_hdoc.xsl 1.41 KB
Newer Older
1 2 3 4
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">

5
    <xsl:output method="xml"/>
6 7 8 9 10 11 12

    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
    <xsl:template match ="/html/body/div/div/div/div[@class='thumb tleft' or @class='thumb tright']" priority="1">

        <div class="{@class}"> 
            <xsl:apply-templates select=".//img" />
            <xsl:apply-templates select=".//div[@class='thumbcaption']" />
            
        </div>
    </xsl:template>

    <xsl:template match="img">
            <img src="http:{@src}" alt="{@alt}"/>
    </xsl:template>
    <xsl:template match="div[@class='thumbcaption']">
            <p class="thumbcaption"> 
                <xsl:apply-templates select="./text() | .//a/text()" mode="thumbcaption"/>
            </p>
    </xsl:template>

    <xsl:template match="text()" mode="thumbcaption">
          <xsl:value-of select="."/>
    </xsl:template>




38 39 40 41
    <!-- Scripts are not useful to us -->
    <xsl:template match="script"/>

    <!-- Ignoring divs that are not useful and that might interfere with the true xslt transformation -->
42
    <xsl:template match="/html/body/div/div/div/div[@class!='mw-highlight mw-content-ltr']"/>
43
</xsl:stylesheet>