xsl and css for KSSS-2500 meniji on lexonomy.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

361 lines
12 KiB

<?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"/>
<!-- ********************************
Javascript logic goes here
Please dont polute xslt with it
******************************** -->
<xsl:variable name="global_script">
<script type='text/javascript'>
var more_txt = "▼ več";
var less_txt = "▲ manj";
$(document).ready(function() {
$(".morelessbutton").click(function() {
var parent_with_hideable = $(this).parent().parent().parent();
var examples_div = parent_with_hideable.find('.hideable').first();
if(examples_div.is(":hidden")) {
$(this).text(less_txt);
} else {
$(this).text(more_txt);
}
examples_div.slideToggle();
});
$(".morelessbutton").text(more_txt);
});
</script>
</xsl:variable>
<!-- ********************************
Here go css styles
Please dont polute xslt with it
******************************** -->
<xsl:variable name="global_style">
<style type="text/css">
:root {
--light-gray: #999999;
--dark-gray: #666666;
--dark-dark-gray: #444444;
--light-red: #dd8899;
--dark-red: #cc3366;
--dark-blue: #00008b;
--green: #22bb44;
}
.xslt-clanek {
font-family: Verdana, sans-serif;
font-size: 1rem;
line-height: 1.5em;
}
.xslt-iztocnica {
font-size: 1.15em;
color: var(--dark-red);
font-weight: bold;
}
.xslt-besedna-vrsta {
color: var(--dark-gray);
font-style: italic;
}
.xslt-pomen-top {
border-top: 1px dotted var(--light-gray);
padding-top: 0.5em;
margin-top: 0.5em;
}
.xslt-pomen-number {
margin-left: 0.5em;
}
.xslt-indicator {
color: var(--dark-dark-gray);
font-weight: bold;
}
.xslt-skladenjska-struktura {
margin: 0.5em 0;
border-left: 8px solid #eeeeee;
padding: 0 0 0 0.75em;
}
.xslt-zgledi {
list-style-type: circle;
float: left;
margin-left: 0em;
color: var(--dark-gray);
margin: 0.5em 0;
}
.xslt-zgled-highlight-k {
font-weight: bold;
}
.xslt-zgled-highlight-i {
color: var(--light-red);
}
.xslt-morelessbutton-div {
padding-left: 2em;
display: inline;
}
.xslt-morelessbutton-div:after {
content: ' ';
display: block;
}
.xslt-podpomen {
margin: 0.5em 2em;
}
.xslt-number {
float: left;
color: var(--dark-gray);
font-weight: bold;
}
.xslt-kolokacija-head {
color: var(--dark-red);
display: block;
}
.xslt-r-kolokacija-head {
color: var(--green);
display: block;
}
.xslt-oznaka {
color: var(--dark-blue);
}
.xslt-def-head {
color: var(--dark-gray);
}
.xslt-def-head:before {
content: ' ';
display: block;
}
.xslt-def-head:after {
content: ': ';
}
.xslt-def-body {
color: var(--light-gray);
}
.xslt-clear {
clear:both;
font-size:0;
}
</style>
</xsl:variable>
<!-- ********************************
Pomen/podpomen logic
******************************** -->
<xsl:template name="pomen_podpomen_logic">
<xsl:apply-templates select="indikator | oznaka"/>
<div class="xslt-morelessbutton-div">
<a class="morelessbutton" href="javascript:void(null)"></a>
</div>
<xsl:apply-templates select="pomenska_shema | definicija1 | definicija2"/>
<div> <!-- needed since button goes to third parent... -->
<div class="hideable" style="display: none;">
<xsl:apply-templates select="skladenjske_skupine"/>
</div>
</div>
</xsl:template>
<!-- ********************************
Pomenska shema/definicija template
******************************** -->
<xsl:template name="definicija_pomenska_shema">
<xsl:param name="left_side"/>
<xsl:choose>
<xsl:when test="text() != ''">
<span class="xslt-def-head"><xsl:value-of select="$left_side"/></span>
<span class="xslt-def-body"><xsl:apply-templates/></span>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- ********************************
kolokacija / r_kolokacija template
******************************** -->
<xsl:template name="r_nor_kolokacija">
<xsl:param name="class-name"/>
<div>
<span class="{$class-name}">
<xsl:apply-templates select="ks | p | i | k | vz"/>
<div class="xslt-morelessbutton-div">
<a class="morelessbutton" href="javascript:void(null)"></a>
</div>
</span>
<xsl:text xml:space="preserve"> </xsl:text>
<div class="hideable" style="display: none;">
<xsl:apply-templates select="zgledi"/>
</div>
</div>
</xsl:template>
<!-- ********************************
Here are all of xslt rules
Please dont polute xslt with it
******************************** -->
<!-- Tags to skip -->
<xsl:template match="zapis | korpusi | korpus | frek_lemma | opombe | struktura"/>
<!-- root tag, includes global script and tag -->
<xsl:template match="clanek">
<xsl:copy-of select="$global_script" />
<xsl:copy-of select="$global_style" />
<div class="xslt-clanek">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="glava">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="iztocnica">
<xsl:text xml:space="preserve"> </xsl:text>
<span class="xslt-iztocnica">
<xsl:apply-templates/>
</span>
<xsl:text xml:space="preserve"> </xsl:text>
</xsl:template>
<xsl:template match="besedna_vrsta">
<xsl:text xml:space="preserve"> </xsl:text>
<span class="xslt-besedna-vrsta">
<xsl:apply-templates/>
</span>
<xsl:text xml:space="preserve"> </xsl:text>
</xsl:template>
<!-- END of HEAD (glava), go to BODY (geslo) -->
<xsl:template match="pomen">
<div class="xslt-pomen-top">
<div class="xslt-pomen-number xslt-number">
<xsl:number />
</div>
<div style="margin-left: 2em;">
<xsl:call-template name="pomen_podpomen_logic"/>
<xsl:apply-templates select="podpomen"/>
</div>
<div style="clear: left;"></div>
</div>
</xsl:template>
<xsl:template match="podpomen">
<xsl:variable name="pomenNum">
<xsl:number count="pomen" level="any"/>
</xsl:variable>
<div> <!-- without this div, number and rest is not aligned vertically... -->
<div class="xslt-number">
<xsl:value-of select="$pomenNum"/>.<xsl:number/>
</div>
<div class="xslt-podpomen">
<xsl:call-template name="pomen_podpomen_logic"/>
</div>
</div>
</xsl:template>
<xsl:template match="skladenjska_struktura">
<div class="xslt-skladenjska-struktura">
<xsl:apply-templates/>
</div>
</xsl:template>
<!-- r_kolokacija is green,... -->
<xsl:template match="r_kolokacija">
<xsl:variable name="class-name">xslt-r-kolokacija-head</xsl:variable>
<xsl:call-template name="r_nor_kolokacija">
<xsl:with-param name="class-name" select="$class-name"/>
</xsl:call-template>
</xsl:template>
<!-- ... kolokacija red -->
<xsl:template match="kolokacija">
<xsl:variable name="class-name">xslt-kolokacija-head</xsl:variable>
<xsl:call-template name="r_nor_kolokacija">
<xsl:with-param name="class-name" select="$class-name"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="kolokacija/ks | r_kolokacija/ks">
<xsl:text xml:space="preserve"> (</xsl:text>
<xsl:apply-templates/>
<xsl:text xml:space="preserve">) </xsl:text>
</xsl:template>
<!-- divide k/r_k within (r_)kolokacija using , -->
<xsl:template match="ks/v | ks/v">
<xsl:text>,</xsl:text>
</xsl:template>
<!-- ' ' in front of k/vz for when <k> right after <i> or <vz> before <i> etc. -->
<xsl:template match="kolokacija//k | r_kolokacija//k | kolokacija//vz | r_kolokacija//vz">
<xsl:text> </xsl:text>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="pomen/indikator | podpomen/indikator | indikator/oznaka">
<xsl:text xml:space="preserve"> </xsl:text>
<span class="xslt-indicator">
<xsl:apply-templates/>
</span>
<xsl:text xml:space="preserve"> </xsl:text>
</xsl:template>
<!-- oznaka outside of indikator mark differently -->
<xsl:template match="pomen/oznaka | podpomen/oznaka">
<span class="xslt-oznaka"><xsl:apply-templates/></span>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:template>
<!-- Three simmilar rules -->
<xsl:template match="definicija1">
<xsl:variable name="left_side">Definicija 1</xsl:variable>
<xsl:call-template name="definicija_pomenska_shema">
<xsl:with-param name="left_side" select="$left_side"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="definicija2">
<xsl:variable name="left_side">Definicija 2</xsl:variable>
<xsl:call-template name="definicija_pomenska_shema">
<xsl:with-param name="left_side" select="$left_side"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="pomenska_shema">
<xsl:variable name="left_side">Pomenska shema</xsl:variable>
<xsl:call-template name="definicija_pomenska_shema">
<xsl:with-param name="left_side" select="$left_side"/>
</xsl:call-template>
</xsl:template>
<!-- zgledi stuff -->
<xsl:template match="zgledi">
<ul class="xslt-zgledi" >
<xsl:apply-templates/>
</ul>
<div class="xslt-clear"></div>
</xsl:template>
<xsl:template match="zgled">
<li><xsl:apply-templates/></li>
</xsl:template>
<!-- hightlighting i/k inside zgled elements -->
<xsl:template match="zgled//i">
<xsl:text xml:space="preserve"> </xsl:text>
<span class="xslt-zgled-highlight-i"><xsl:apply-templates/></span>
</xsl:template>
<xsl:template match="zgled//k">
<xsl:text xml:space="preserve"> </xsl:text>
<span class="xslt-zgled-highlight-k"><xsl:apply-templates/></span>
</xsl:template>
</xsl:stylesheet>