MediaWiki:ExtractFirst.xsl

Uit WikiWoordenboek
Ga naar: navigatie, zoeken

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html'/>
<xsl:variable name="dir">ltr</xsl:variable>
<xsl:variable name="more">» Meer</xsl:variable>
<xsl:variable name="error">Fout: </xsl:variable>
<xsl:variable name="copyright"> © <a href="http://nl.wiktionary.org/wiki/">WikiWoordenboek</a>. Vrijgegeven onder <a href="http://creativecommons.org/licenses/by-sa/3.0/deed.nl" rel="license copyright">CC-BY-SA 3.0</a></xsl:variable>
<xsl:variable name="contentLang" select="'nl'"/> 


<xsl:variable name="pageName" select="concat('http://', $contentLang, '.wiktionary.org')"/>
<xsl:template match="/">
<html dir="{$dir}" lang="{$contentLang}" xml:lang="{$contentLang}">
<head>
<meta name="generator" content="Wiktionary Extract XSLT 1.04-NL"/>
<base target='_blank' href="{$pageName}" />

<title> Wiktionary extract</title>

<style>
.disambig-see-also, .disambig-see-also-2 {display:inline;}
#container {background-color:white; padding: 0.5em; border: solid black thin;}
a.new {color: red;}
#error {color: red;font-size:larger;}
</style>
<script type='text/javascript'>
/*<![CDATA[*/
function setup () {
//Stuff to translate:
var preferLang = {'nl': 'Nederlands', 'en': 'Engels', 'qqqAny': null}; //for now.

var extractSeeAlso = /]*>[\s\S]*?([\s\S]*?[\s\S]*?)<\/td>[\s\S]*?<\/table>/; //Modified elsewhere! var see_also_process = function (sa) { return sa[1].replace(/<a[^>]*><img[^>]*\/><\/a>/, );} var missing = 'Could not retrieve definition of $1.'; //Stuff not to translate in general (setup). var pageURL = '/wiki/' +location.search.match(/\&page\=([^&]*)/)[1]; var src = document.getElementById('src'); var display = document.getElementById('word-list'); var loc = location.search.match(/\&page\=([^&]*)/)[1]; var preferLangCode = location.search.match(/\&lang\=([^&]*)/); if (preferLangCode) { preferLangCode = preferLangCode[1]; } else {preferLangCode = 'qqqAny';} src.normalize(); var html = src.firstChild.data; var def = html //may be redefined later. //stuff you might need to translate, but hopefully won't var subSectRegex = new RegExp('

]*>[\\s\\S]*$'); //this is ugly var extractCurLangName = /]*>([\s\S]*?)<\/span>/; //first subexpression try { //this assumes attribute order doesn't change!!! html = html.replace(/

[\s\S]*?<\/div>/, );

 if (preferLangCode && preferLang[preferLangCode]) {
  try {
   //strip off all definitions before tagret lang.
   var subSect = html.match(subSectRegex)[0];

if (subSect.match(/

  1. [\s\S]*?
  2. /)) { //if it has content def = subSect; } } catch (e) { /*alert(e)*/} } var lang = def.match(extractCurLangName)[1]; display.innerHTML = '(' + lang + ') ' + def.match(/
    [\s\S]*?<\/ol>/)[0].replace(/
    [\s\S]*?<\/dl>/g, ).replace(/
    ]*>[\s\S]*?<\/div>/g, ).replace(/
    • [\s\S]*?<\/ul>/g, ).match(/
    • ([\s\S]*?)<\/li>/)[1];
      }
      catch (e) {
       //alert(e)
       //page does not exist, not well formed, these regexs suck, etc
       display.appendChild(document.createTextNode(mising.replace('$1', decodeURIComponent(loc))));
       if (decodeURIComponent(loc).match(/[A-Z]/) && !location.search.match(/\&rd/)) {
        //make sure don't have loops, if first character is for example % encoded.
        //should probably decode it.
        location = location.href.replace(/(^[\s\S]*?\&page\=)[^&]*([\s\S]*$)/, '$1'+ loc.charAt(0).toLowerCase() + loc.substring(1, loc.length) + '$2&rd');
       }
      }
      var sa = html.match(extractSeeAlso);
      if(sa) {
       document.getElementById('see-also').innerHTML = ' (' + see_also_process(sa) + ')' ;
      }
      document.getElementsByTagName('base')[0].href += pageURL; //this doesn't do anything.
      document.getElementById('more-link').href= pageURL;
      
      
      

      }

      /*]]>*/
      </script>
      
      

      </head>

      <body onload='setup()'>
      
      
      <xsl:apply-templates select='api/error'/>
      <a id='more-link'><xsl:value-of select="$more"/></a> <xsl:copy-of select="$copyright"/>
      </body>
      </html>
      
      
      </xsl:template>
      <xsl:template match='api/error'>
      <xsl:value-of select="$error"/> <xsl:value-of select='@info'/>
      </xsl:template>
      
      
      </xsl:stylesheet>
      
Persoonlijke instellingen
Naamruimten
Varianten
Handelingen
Navigatie
Informatie
Zusterprojecten
Hulpmiddelen