wiki:xlstBeispiel

Beispiel für ein xsl File, dass die nach morphologischer Analyse getaggten Files mit Links zum Dictionary versieht.

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mpiwg="http://www.mpiwg-berlin.mpg.de/namespace">
<xsl:output method="html"/>

<xsl:template match="/">

<html>
  <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
      <link rel="stylesheet" type="text/css" href="http://archimedes.mpiwg-berlin.mpg.de/arch/css/archtexts.css"/>
  </head>

 <body>
    <xsl:apply-templates/>
    
  </body>
</html>
</xsl:template>

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

<mpiwg:s class="{@class}">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
             <xsl:apply-templates/>
</mpiwg:s>
</xsl:template>

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

             <xsl:apply-templates/>
<br/>
</xsl:template>

<xsl:template match="//div">
<div class="{@class}">

             <xsl:apply-templates/>
</div>

</xsl:template>
<xsl:template match="//img">
<img src="{@src}" alt="{@alt}">

             <xsl:apply-templates/>
</img>

</xsl:template>


<xsl:template match="//table">
<table width="{@width}" class="{@class}">
             <xsl:apply-templates/>
</table>
</xsl:template>

<xsl:template match="//tr">
<tr>
             <xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="//td">
<td>

             <xsl:apply-templates/>
</td>
</xsl:template>

<xsl:template match="//span">
<span class="{@class}">

             <xsl:apply-templates/>
</span>
</xsl:template>

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

             <xsl:apply-templates/>
</sub>
</xsl:template>

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

             <xsl:apply-templates/>
</sup>
</xsl:template>


<!-- todo: probably better to convert center to span and handle in css-->


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

             <xsl:apply-templates/>
</center>
</xsl:template>
<xsl:template match="//small">
<small>

             <xsl:apply-templates/>
</small>
</xsl:template>
<xsl:template match="//br">
<br>

             <xsl:apply-templates/>
</br>
</xsl:template>


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

<p class="{@class}">

             <xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="//pb">

<span class="pagenum">
     	      <xsl:value-of select="@pagenum"/>
             <xsl:apply-templates/>
</span>
<br/>
</xsl:template>


<xsl:template match="//mpiwg:w">

<!--
http://perseus.mpiwg-berlin.mpg.de/cgi-bin/morphindex?lang=latin;lookup=
-->
<xsl:variable name="thislang"><xsl:value-of select="@lang"/></xsl:variable>
<!--<xsl:variable name="analysed"><xsl:value-of select="@mpiwg:analysed"/></xsl:variable>  ## auskommentieren dann werden nur analysierte verlinkt-->
<xsl:variable name="analysed">yes</xsl:variable><!-- alle verlinken, analysiert wird immer auf yes gesetzt -->
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test='$analysed="yes"'>
<xsl:choose>

	<xsl:when test='$thislang="nl"'>
<a>
     <xsl:attribute name="href">http://141.14.236.86/cgi-bin/toc/dict?step=remotetable;word=<xsl:value-of select="@mpiwg:form"/>;lang=<xsl:value-of select="@lang"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute><xsl:apply-templates/>

</a>
</xsl:when>
		
<xsl:when test='$thislang="fr"'>
<a>

     <xsl:attribute name="href">http://141.14.236.86/cgi-bin/toc/dict?step=remotetable;word=<xsl:value-of select="@mpiwg:form"/>;lang=<xsl:value-of select="@lang"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute><xsl:apply-templates/>

</a>
</xsl:when>

<xsl:when test='$thislang="de"'>
<a>

     <xsl:attribute name="href">http://141.14.236.86/cgi-bin/toc/dict?step=remotetable;word=<xsl:value-of select="@mpiwg:form"/>;lang=<xsl:value-of select="@lang"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute><xsl:apply-templates/>

</a>
</xsl:when>

<xsl:otherwise>
<a>
     <xsl:attribute name="href">http://141.14.236.86/cgi-bin/toc/dict?step=table;word=<xsl:value-of select="@mpiwg:form"/>;lang=<xsl:value-of select="@lang"/>;pro=<xsl:value-of select="@pro"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute><xsl:apply-templates/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<a>
<xsl:apply-templates/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- form -->

<xsl:template match="//foreign[@lang='greek']">
<G>
             <xsl:apply-templates/>
	</G>
	    
</xsl:template>
<xsl:template match="//foreign[@lang='el']">
<G>
             <xsl:apply-templates/>
	</G>
	    
</xsl:template>



<!-- non-implemented tags after here -->

<!-- author -->

<xsl:template match="//author">
	  <font class="author">
             <xsl:apply-templates/>
	</font>
	    
      </xsl:template>

<!-- ETYM -->
<xsl:template match="//etym">
	  <font class="etym">
             <xsl:apply-templates/>
	</font>
	    
      </xsl:template>

<!-- USG -->


</xsl:stylesheet>

Last modified 17 years ago Last modified on Jan 11, 2007, 8:40:53 PM