Mercurial > hg > mpdl-group
view software/mpdl-services/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXhtml.xsl @ 25:e9fe3186670c default tip
letzter Stand eingecheckt
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 21 May 2013 10:19:32 +0200 |
parents | e845310098ba |
children |
line wrap: on
line source
<?xml version="1.0"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:functx="http://www.functx.com" xmlns:saxon="http://saxon.sf.net/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xhtml="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml" > <xsl:output method="xhtml" encoding="utf-8"/> <xsl:param name="echoFiguresDir"></xsl:param> <xsl:param name="echoPageImgDir"></xsl:param> <xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/> <xsl:template match="*:html"> <xsl:apply-templates/> </xsl:template> <xsl:template match="body"> <xsl:apply-templates mode="html"/> </xsl:template> <!-- html mode: transform html texts --> <xsl:template match="@*|node()" mode="html"> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="html"/> </xsl:copy> </xsl:template> <xsl:template match="s" mode="html"> <xsl:apply-templates select="."/> </xsl:template> <xsl:template match="w" mode="html"> <xsl:apply-templates select="."/> </xsl:template> <xsl:template match="*:expan|*:emph|*:q|*:quote|*:blockquote|*:set-off|*:reg|*:var|*:num|*:figure"> <span> <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </span> </xsl:template> <xsl:template match="*:div"> <xsl:if test="node() or normalize-space()"> <!-- test: contains nodes or is not empty --> <div> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute> <xsl:apply-templates/> </div> </xsl:if> </xsl:template> <xsl:template match="*:p"> <div> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute> <xsl:apply-templates/> </div> </xsl:template> <xsl:template match="pb"> <xsl:variable name="number" select="count(./preceding::*:pb) + 1"/> <xsl:variable name="file" select="$number"/> <span> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute> <span> <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute> <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute> <span> <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute> <xsl:value-of select="$number"/> </span> </span> </span> </xsl:template> <xsl:template match="*:head"> <div> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute> <xsl:apply-templates/> </div> </xsl:template> <!-- MathML --> <xsl:template match="math:*"> <xsl:element name="{name()}" namespace=""> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:element> </xsl:template> <!-- SVG --> <xsl:template match="svg:*"> <xsl:element name="{name()}" namespace=""> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="*:lb"> <br> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute> </br> </xsl:template> <xsl:template match="*:cb"> <br> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute> </br> </xsl:template> <xsl:template match="br"> <br> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'br'"/></xsl:attribute> </br> </xsl:template> <xsl:template match="note"> <span> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute> <xsl:apply-templates/> </span> </xsl:template> <xsl:template match="foreign"> <xsl:variable name="lang" select="@lang"/> <xsl:variable name="xmllang" select="@xml:lang"/> <xsl:variable name="language"> <xsl:choose> <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when> <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when> <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise> </xsl:choose> </xsl:variable> <span> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute> <xsl:apply-templates/> </span> </xsl:template> <xsl:template match="gap"> <span> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute> <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if> <xsl:apply-templates/> </span> </xsl:template> <!-- XHTML: remove the xhtml namespace --> <xsl:template match="xhtml:*"> <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/> <xsl:variable name="isTable" select="name() = 'table'"/> <xsl:choose> <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)"> <xsl:element name="{name()}" namespace=""> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:element> </xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="s"> <span> <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if> <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute> <xsl:apply-templates/> </span> </xsl:template> <!-- words --> <xsl:template match="*:w"> <xsl:variable name="wordLanguage" select="@lang"/> <xsl:variable name="form" select="encode-for-uri(string(@form))"/> <xsl:variable name="dictionary" select="string(@dictionary)"/> <xsl:variable name="displayWordOrig"> <xsl:choose> <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when> <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="displayWordReg"> <xsl:choose> <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when> <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="displayWordNorm"> <xsl:choose> <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when> <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/> <xsl:variable name="dictionaryPart"> <xsl:choose> <xsl:when test="$dictionary = 'true'"> <a class="dictionary"> <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&queryDisplay=', $displayWordUrlEncoded, '&language=', $wordLanguage, '&outputFormat=html', '&outputType=morphCompact&outputType=dictFull')"/></xsl:attribute> <span class="orig"><xsl:sequence select="$displayWordOrig"/></span> <span class="reg"><xsl:sequence select="$displayWordReg"/></span> <span class="norm"><xsl:sequence select="$displayWordNorm"/></span> </a> </xsl:when> <xsl:otherwise> <span class="dictionary"> <span class="orig"><xsl:sequence select="$displayWordOrig"/></span> <span class="reg"><xsl:sequence select="$displayWordReg"/></span> <span class="norm"><xsl:sequence select="$displayWordNorm"/></span> </span> </xsl:otherwise> </xsl:choose> </xsl:variable> <span class="w"> <xsl:sequence select="$dictionaryPart"/> <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span> <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span> <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span> </span> </xsl:template> <xsl:template match="*:hi"> <xsl:choose> <xsl:when test="@type = 'elem'"> <div> <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute> <xsl:apply-templates/> </div> </xsl:when> <xsl:otherwise> <span> <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute> <xsl:apply-templates/> </span> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>